Good question. A lot of the good QA automation guys got their head on this.
Implicit expectations
driver.findElement(...)
.
webdriver (js, python, java) NoSuchElementException, DOM . driver.findElement
, , . NoSuchElementException findElement
.
0
. browser.manage().timeouts().implicitlyWait(3000)
webdriver try/catch , . 3 (-), DOM - NoSuchElementException.
:
DOM (99,999% -), DOM, 1-3 . , .
:
, DOM. .findElement
, , :
expect($('NON-EXIST-ELEMENT').isPresent()).toBeFalsy()
implicitWait
. 3 , isPresent(), false ( ). , 3 ! implicitWait(0)
, ( ).
- , , . 1-5 ( -). , - - reset 0, .
, , , . protractorjs, - , browser.wait()
. (, true/false, ). Webdriver , - ( ). , .
, - . . ExpectedConditions true/false , .
browser.wait(ExpectedConditions.visibilityOf($('NON-EXISTING-ELEMENT')), 3000, 'error message')
:
. , , - .
, .
:
, browser.sleep()
, . browser.sleep()
, 99% browser.wait()
.
, , .
:
browser.manage().timeouts().implicitlyWait(10000)
browser.wait(EC.stalenessOf($('NON-EXIST-ELEMENT')), 5000) //waiting for 5 seconds for element to disappear
:
Wait stalenessOf()
. driver.findElement()
. , - 10 , - , NoSuchElementException. , , 10 ! TimeOutException, 5 . , .
, JS - Event Loop. - 5200 5000 ( ). :)
- - 4000 .
- - 5000 .
- . -
presenceOf()
- webdriverjs -
driver.findElement(By.xpath('//*[@name='qwer']'))
- wait , throw.
- 4000 . .
- false
- 1000 - .
- . 4000 -
- false
- , - - 8000 , ,
- - jasminejs
, !