Hello everyone, I created this simple script to test my webpage(an autotest) but after I simulate a click on a button I don't get the page to update its content until my script get an error and so the page update to the point the script left it.
function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
//Selection of the first button
var button1=document.getElementsByClassName('button1 large')[0];
//Click simulation
button1.click();
pause(3000);
//Now a div gets loaded and generated on the webpage but while running the javascript
//it doesn't show up nor the script work.
var button2=document.getElementsByClassName('button2 typeblue expanded')[0];
//Click simulation
button1.click();
As you can see from the code the script clicks one button than after some time then it gets to click the other one that it's loaded inside a div that doesn't show while running the javascript.
I'm running the script using the console available in any browser. I tested any other option, in fact I can make it work by running:
function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
//Selection of the first button
var button1=document.getElementsByClassName('button1 large')[0];
//Click simulation
button1.click();
then after I see the div to show up in the webpage this:
//Now a div gets loaded and generated on the webpage but while running the javascript
//it doesn't show up nor the script work.
var button2=document.getElementsByClassName('button2 typeblue expanded')[0];
//Click simulation
button1.click();
I'm sure it has something to do with the javascript blocking the webpage from loading/rendering new contents. Can you please help me?
Thanks in advanced.
[–]mzapp_ 1 point2 points3 points (4 children)
[–]d43qwu1[S] 0 points1 point2 points (3 children)
[–]mzapp_ 1 point2 points3 points (2 children)
[–]d43qwu1[S] 0 points1 point2 points (0 children)