google-chrome - Selenium::WebDriver 等待(Ruby、Chrome)

标签 google-chrome ubuntu selenium webdriver

我有一个可以打开浏览器的 ruby​​ 脚本。如果FF由于某种原因失败,我将它设置为先打开Firefox,然后再打开Chrome——比如FF得到更新而Selenium还没有 catch 。

等待功能/定义适用于 FF,但总是会破坏 Chrome。下面是Chrome浏览器启动的相关代码:

b = Selenium::WebDriver.for :chrome
b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT

我对 Selenium 还是很陌生,我在声明如下内容后使用了 wait.until 命令:
wait = Selenium::WebDriver::Wait.new(:timeout => $BROWSER_EXPLICIT_WAIT)

上面的代码行在 Firefox 中运行良好。但是,我想用 FF 和 Chrome 运行我的脚本。有没有办法在 Chrome 和 FF 中做到这一点?

谢谢

最佳答案

现在看到您提供了更容易解决的错误。

原因是 - 您已将 selenium 驱动程序实例命名为 b
但将隐式时间定义为
b.driver.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT
即与b.DRIVER ,因此错误消息 - undefined method 'driver' for
将您的命令更改为

b.manage.timeouts.implicit_wait = $BROWSER_IMPLICIT_WAIT

关于google-chrome - Selenium::WebDriver 等待(Ruby、Chrome),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11087368/

相关文章:

java - 无法通过 Heroku 中的 Selenium webdriver(Java) 调用 headless chrome 驱动程序

opengl - 在 Ubuntu 中安装 OpenGL 和 OpenAL

linux - Ubuntu Linux - 从本地存储库安装软件包

python - 同一行中表格单元格的 XPath?

java - 使用 Cucumber、Jmeter 和 FailSafe 的自动化框架是否需要 ThreadLocal?

html - Flexbox 在 Internet Explorer 中有效,但在 Chrome 中无效

css - 子菜单在 Chrome 中敏感,但在 Firefox 中很好

javascript - 使用全屏 API 触发全屏时,双指缩放在 macOS (Chrome) 上不起作用

ubuntu - 如何在 txt 文件中附加 find 的输出和字符串?

python - 当我在构建机器人时尝试包含登录按钮的 HTML 详细信息时,收到 "NoSuchElementException"