Can't access WebDriverJS wait 'until'

2019-05-15 04:46发布

问题:

I need to wait for a modal to close so I am waiting for the absence of an element. I'm trying to do something like this:

browser.driver.wait until.stalenessOf(By.css '.modal-header')

Unfortunately Coffeescript has reserved until. So I tried using:

browser.driver.wait browser.driver.until.stalenessOf(By.css '.modal-header')

but it is undefined (until that is). browser.driver exists but it doesn't contain until.

How can I access the until object? Also, is there another way to wait until an element is no longer on the page?

回答1:

You can use the isPresent() function instead:

browser.wait ->
  not element(By.css '.modal-header').isPresent()
,
  5000

NOTE: isPresent() will not return false until it has finished implicitly waiting for the element, so if you have set the browser.manage().timeouts().implicitlyWait property very high you may want to temporarily decrease its value.