If I want to use implicitlyWait
, where I should put browser.manage().timeouts().implicitlyWait(5000);
in the test?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Add it in the
onPrepare()
function of your protractor's conf.js file. The reason to addimplicitlyWait()
there is because implicit wait is the default time that protractor waits before passing or throwing an error for an action. Letting protractor know what the implicit wait time is, even before the tests start is the best way to make use of it andonPrepare()
function runs before all test suites and only once.Example scenario:
Suppose you have the below line of code -
in your test spec and protractor executes it after initiating the automation on page. Now, if the element with the locator specified is not found on the page, then protractor doesn't throw an error immediately, but it waits for the
implicit
wait time to complete. Meanwhile until implicit timeouts, it checks if the element can be located on the DOM. At the end of theimplicit
wait time if the element is not found, then the protractor throws the respective error. So for all the operations that you perform it is necessary to let protractor know the implicit wait time well before hand.Usage: