How to implicitly wait for Protractor to interact with explicit wait?

Misunderstanding occurs when implicit waiting is less than explicit:

var timeOut = 5000;
var search = element(by.xpath(`//*[@name='qwer']`));
browser.manage().timeouts().implicitlyWait(4000);
browser.ignoreSynchronization = true;

describe('Protractor Test', function () {
    beforeEach(function () {
        browser.get('https://www.google.com.ua');
    });
    it('EC', function () {
        console.log('START');
        // browser.sleep(timeOut);
        browser.wait(protractor.ExpectedConditions.presenceOf(search), timeOut);
    });
});

Total time: 8.613 seconds. Install implicitly. Wait a second below: 3000, and the result is 6.865 seconds. How does it work under the hood? Thank you very much in advance!

+6
source share
3 answers

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

, !

+12

Selenium. browser.wait() - , implicit wait - browser.manage().timeouts().implicitlyWait()

, , . .

. . . , 10 15 , 20 .

+1

: . 4 , 4 1 . , 4 . 8 (2 ) 5 , , , 3 . , Implicit 8 17, 8 * 3 = 24 . , script , , , , .

0

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


All Articles