Where to put implicitlyWait in Protractor?

If I want to use implicitlyWait , where should I put browser.manage().timeouts().implicitlyWait(5000); in the test?

+5
source share
1 answer

Add it to the onPrepare() function of the onPrepare() file of your protractor. The reason for adding implicitlyWait() is that implicit wait is the default time that the transporter waits before passing or throwing an error for the action. Letting the protractor know what an implicit wait time is, even before testing starts, this is the best way to use it, and the onPrepare() function runs before all test suites and only once.

Example script:

Suppose you have the bottom line of code -

 element(LOCATOR).getText(); 

in your test specification and the protractor performs it after starting the automation on the page. Now, if the element with the specified locator is not found on the page, the protractor does not throw an error immediately, but waits for the implicit timeout to complete. Meanwhile, before implicit timeouts, it checks if the element can be located on the DOM. At the end of the implicit timeout, if the item is not found, then the protractor will throw the corresponding error. Thus, for all operations that you perform, it is imperative that the protractor knows the implicit wait time well in advance.

Application:

 onPrepare: function(){ browser.manage().timeouts().implicitlyWait(5000); }, 
+11
source

Source: https://habr.com/ru/post/1234355/


All Articles