I use QUnit and jQuery and want to check the user interface of my site. My webapp is in an iframe. I want to click on the navigation link, then wait for the new page to load, and then I want to select several elements through jQuery to make sure the correct page is loaded.
How to do it?
I read about setTimeout (), delay (), ajaxSetup (), setInterval (), so far: without success.
Here is the code snippet:
test("Klick Unternehmen, checke Ueberschrift", function() {
var mes = "test: Klick Unternehmen, checke Ueberschrift;";
var exp = "Unternehmen";
jQuery.ajaxSetup({ async: false });
jQuery('#testframe').attr('src', './../index/unternehmen/').delay(3000);
var t = setTimeout('doNothing()', 2000);
var act = jQuery('h1').eq(1);
equal(act, exp, mes);
});
UPDATE: I was able to call ressource using ajax. In any case, I still do not know how to call click () - wait () - compare ().
test("Klick Unternehmen, checke Ueberschrift", function() {
jQuery.ajax({
url: "./../index/unternehmen/",
async: false,
success: function(response){
if (response){
jQuery('#ajaxcontent').html(response);
}
},
context: document.body,
type: "POST"
});
var mes = "test: Klick Unternehmen, checke Ueberschrift;";
var exp = "Unternehmen";
var act = jQuery('#ajaxcontent h1').eq(0).text();
equal(act, exp, mes);
});
source
share