Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor browser.sleep() is not getting executed

Tags:

protractor

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');
            };
like image 782
prav kum Avatar asked Jul 01 '16 19:07

prav kum


3 Answers

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?

like image 114
Xotabu4 Avatar answered Nov 06 '22 02:11

Xotabu4


put await in front of browser and pass a parameter to sleep (time in ms).

await browser.sleep(5000);
like image 26
Pranawa Mishra Avatar answered Nov 06 '22 02:11

Pranawa Mishra


Try resolving the promise.

browser.sleep(35000).then(
  function(){
     console.log("Waiting");
  }
)

Or update protractor to the last version

npm install protractor@latest --save
like image 1
Oscar Avatar answered Nov 06 '22 02:11

Oscar