Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用QUnit、JQuery和iframe进行UI测试-如何等待新页面加载?_Jquery_Wait_Qunit - Fatal编程技术网

使用QUnit、JQuery和iframe进行UI测试-如何等待新页面加载?

使用QUnit、JQuery和iframe进行UI测试-如何等待新页面加载?,jquery,wait,qunit,Jquery,Wait,Qunit,我正在使用QUnit和JQuery,想测试我网站的用户界面。我的webapp驻留在iframe中。我想单击导航链接,然后等待新页面加载,然后我想通过JQuery选择一些项目,以确保加载了正确的页面 如何做到这一点 我读过关于setTimeout()、delay()、ajaxSetup()、setInterval(),到目前为止:没有成功 以下是一段代码片段: // Klick auf Unternehmen und vergleiche h1-Ueberschrift. test

我正在使用QUnit和JQuery,想测试我网站的用户界面。我的webapp驻留在iframe中。我想单击导航链接,然后等待新页面加载,然后我想通过JQuery选择一些项目,以确保加载了正确的页面

如何做到这一点

我读过关于setTimeout()、delay()、ajaxSetup()、setInterval(),到目前为止:没有成功

以下是一段代码片段:

// Klick auf Unternehmen und vergleiche h1-Ueberschrift.
        test("Klick Unternehmen, checke Ueberschrift", function() {
            var mes = "test: Klick Unternehmen, checke Ueberschrift;";
            var exp = "Unternehmen";
            jQuery.ajaxSetup({ async: false }); //turn off async so tests will wait for ajax results
            jQuery('#testframe').attr('src', './../index/unternehmen/').delay(3000);
            var t = setTimeout('doNothing()', 2000);
            //alert('now');
            var act = jQuery('h1').eq(1);
            //var act = "Unternehmen";
            //console.log(mes);
            equal(act, exp, mes);
        });
更新:我能够通过ajax调用ressource。无论如何,仍然不知道如何调用click()-wait()-compare()

你应该试试

$("#yourIframeID").load(function(){
    //do your testing stuff here..

})
QUnit
中还有一种异步测试方法,但我不确定它是否适用于您的案例(
asyncTest(name,expected,test)

$("#yourIframeID").load(function(){
    //do your testing stuff here..

})