如何在 ruby​​ 中为 Selenium MS Edge 驱动程序设置选项? [英] How do I set options for the Selenium MS Edge driver in ruby?

查看:70
本文介绍了如何在 ruby​​ 中为 Selenium MS Edge 驱动程序设置选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Windows 上使用 Selenium::WebDriver::Edge::Driver 打开浏览器.我能够打开浏览器,但我的会话立即因此错误而崩溃:

I am trying to open a browser with the Selenium::WebDriver::Edge::Driver on Windows. I am able to open the browser but my session immediately crashes with this error:

unknown command: Cannot call non W3C standard command while in W3C mode 
(Selenium::WebDriver::Error::UnknownCommandError)

如何在 selenium ruby​​ 中关闭 W3C 模式?我试图按照文档here 做:

How would I turn off W3C mode in selenium ruby? I have tried to follow the docs here by doing:

webdriver_options = Selenium::WebDriver::Edge::Options.new(opts: {w3c: false})

在实例化 webdriver 之前.然而,这似乎并没有什么不同 - 我怀疑我设置的选项错误.有没有人见过这个问题?谢谢.

before instantiating the webdriver. However this does not seem to make a difference - I suspect I am setting the options wrong. Has anyone seen this issue before? Thanks.

推荐答案

如果您使用的是 Edge Chromium,我认为选项就像 Chrome 的一样.您可以参考 这个线程并添加以下代码然后将其传递给驱动程序:

If you're using Edge Chromium, I think the options are like the Chrome's. You could refer to this thread and add the following code then pass it into the driver:

capabilities = { "edgeOptions" => {'w3c' => false} }

这篇关于如何在 ruby​​ 中为 Selenium MS Edge 驱动程序设置选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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