无法访问 WebDriverJS 在 Protractor 和 CoffeeScript 中等待“直到" [英] Can't access WebDriverJS wait 'until' in Protractor and CoffeeScript

查看:33
本文介绍了无法访问 WebDriverJS 在 Protractor 和 CoffeeScript 中等待“直到"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要等待模式关闭,所以我正在等待没有元素.我正在尝试做这样的事情:

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')

不幸的是,Coffeescript 保留了 直到.所以我尝试使用:

Unfortunately Coffeescript has reserved until. So I tried using:

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

但它是未定义的(直到就是).browser.driver 存在,但不包含 until.

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

如何访问 until 对象?另外,还有其他方法可以等到页面上不再存在元素吗?

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

推荐答案

你可以使用isPresent() 函数:

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

注意: isPresent() 在完成隐式等待元素之前不会返回 false,所以如果你设置了 browser.manage().timeouts().implicitlyWait 属性非常高,您可能需要暂时降低其值.

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.

这篇关于无法访问 WebDriverJS 在 Protractor 和 CoffeeScript 中等待“直到"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆