Reputation: 454
In the below as you can see that the browser.sleep is supposed to be executed if the client is XYZ, but still it is not getting executed.
If i put any console.log after the browser.sleep statement, that statement is getting executed (i can see the statement) but the browser.sleep is not really waiting even though how much the sleep time i increase.
Why is the browser.sleep is not working? How do i make it wait if the client XYZ?
if (testproperties.client == 'ABC'){
browser.ignoreSynchronization = false;
browser.waitForAngular();
browser.ignoreSynchronization = true;
}
else if (testproperties.client == 'XYZ'){
browser.sleep('35000');
};
Upvotes: 10
Views: 36810
Reputation: 169
browser.sleep() should be executed with sync mode instead of async
Upvotes: 0
Reputation: 1
If you launch protractor with headless
parameter browser.sleep()
cannot works.
Remove this parameter and enjoy.
Upvotes: 0
Reputation: 1980
Please give it a try with below code sample .
//For none angular sites
browser.driver.ignoreSynchronization = true;
browser.waitForAngularEnabled(false);
//browser.get('url');
//If normal browser.sleep(7000); didnt work try
browser.driver.sleep(8000);
//click using ID instead of Javasctipt
element(by.id('next')).click()
Upvotes: 0
Reputation: 51
put await in front of browser and pass a parameter to sleep (time in ms).
await browser.sleep(5000);
Upvotes: 2
Reputation: 2047
Try resolving the promise.
browser.sleep(35000).then(
function(){
console.log("Waiting");
}
)
Or update protractor to the last version
npm install protractor@latest --save
Upvotes: 1
Reputation: 1226
Try following answer.
if (testproperties.client == 'ABC'){
browser.ignoreSynchronization = false;
browser.driver.sleep(2000);
browser.ignoreSynchronization = true;
}
else if (testproperties.client == 'XYZ'){
browser.driver.sleep(2000);
};
Hope this helps. :)
Upvotes: 0
Reputation: 3091
Do you passing int type as parameter? Seems like it is string. Try
browser.sleep(35000)
Also check why you might need such huge browser sleep? Maybe you want browser.wait()
instead?
Upvotes: 12