如何让 watir-webdriver 和 safariwatir 一起工作?

发布于 2024-11-14 08:44:02 字数 1223 浏览 2 评论 0 原文

早上好,

我正在设置 watirgrid,并且已经部分成功,但是我在让所有提供程序使用我的 ruby​​ 脚本时遇到问题。

在我的 Mac 上,我使用以下命令从命令行设置了一个提供程序:

provider -d safariwatir -c druby://192.168.0.1:11235

然后在我的 Ubuntu 机器上,我设置了另一个提供程序

provider -d webdriver -c druby://192.168.0.1:11235

现在,如果我使用以下 ruby​​ 代码:

require 'rubgygems'
require 'watirgrid'

Watir::Grid.control(:controller_uri => 'druby://192.168.0.1:11235', :browser_type => 'firefox'_ do |browser, id|
    puts "Browser id is #{i}"
    browser.goto("http://www.google.co.uk")
    puts browser.title
end

这种情况下,两个浏览器都会启动并转到所选页面。但是,我不想将“firefox”指定为浏览器类型,因为我想定位网格中的所有浏览器(Windows 上的 IE、Mac 上的 FF 等)。因此,然后我尝试从 Grid.control 命令中取出“firefox”,当“Safari”启动时,我从第二个浏览器收到错误,因为我猜测它不知道要运行什么。

(抱歉,我不在我的机器上重新创建错误并将其发布在这里。我会尽可能更新该帖子)。

我尝试使用 -b 开关启动 webdriver 提供程序:

provider -d webdrive -c druby://192.168.0.1:11235 -b firefox

然后再次运行相同的 ruby​​ 代码,而不使用浏览器类型,但我得到了相同的错误。

我在这里错过了什么吗?

我认为在具有多个浏览器的计算机上运行多个提供程序是正常的,只是在不同的端口上。

我在这方面取得了一些成功,我已经让 Chrome 在一台独立的机器上与 webdriver 一起工作,我认为这对我的 web 开发确实有帮助,我只需要解决这个问题,所以感谢您的帮助。我希望这一切都有意义。

谢谢,拉塞尔

Good morning,

I am setting up watirgrid and I have been partly successful, however I am having problems getting all the providers to work with my ruby script.

On my Mac I have setup a provider from the command line using:

provider -d safariwatir -c druby://192.168.0.1:11235

and then on my Ubuntu machine I setup another provider thus

provider -d webdriver -c druby://192.168.0.1:11235

Now if I use the following ruby code:

require 'rubgygems'
require 'watirgrid'

Watir::Grid.control(:controller_uri => 'druby://192.168.0.1:11235', :browser_type => 'firefox'_ do |browser, id|
    puts "Browser id is #{i}"
    browser.goto("http://www.google.co.uk")
    puts browser.title
end

This sort of works in that both browsers start up and goto the selected page. However I do not want to have to specify 'firefox' as a browser type as I want to target all browsers in the grid (IE on Windows, FF on Mac etc). So I then try to take out 'firefox' from the Grid.control command and whilst 'Safari' starts up I get an error from the second browser as it does not know what to run I am guessing.

(Apologies but I am not at my machines to recreate the error and post it here. I will update the post with this when I can).

I have tried to start the webdriver provider with the -b switch:

provider -d webdrive -c druby://192.168.0.1:11235 -b firefox

and then run the same ruby code again, without the browser type, but i get the same error.

Am I missing something here?

I assume that it is normal to run multiple providers on a machine that has several browser, just on different ports.

I have had some success with this, I have got Chrome working with the webdriver on an isolated machine, and I think it will really help with my web development, I just need to get past this problem so thanks for any help. I hope this all make sense.

Thanks, Russell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巾帼英雄 2024-11-21 08:44:02

有趣的用例,我没有想到这一点(在同一台机器上具有不同的浏览器和不同的驱动程序类型)

看看最新的版本

gem install watirgrid --pre

这里有一个 rspec 的例子:
https://github.com/90kts/watirgrid/blob/master/spec /grid_mixed_spec.rb

如果您要在同一台计算机上启动多个提供程序,请确保使用 -p 参数通过不同的端口将它们分隔开。我还修复了一个错误,因此如果您指定 -b browser_type 如果未在 Watir::Grid 参数中显式定义它,它将默认为该浏览器类型。

让我知道你怎么样了...

Interesting use case, I hadn't thought of that (on the same machine with different browsers AND different driver types)

Have a look at the latest build

gem install watirgrid --pre

There's an example in rspec here:
https://github.com/90kts/watirgrid/blob/master/spec/grid_mixed_spec.rb

If you're going to start more than one provider on the same machine, make sure they're separated using the -p argument by unqiue ports. I've also fixed a bug so that if you specify -b browser_type it will default to that browser type if not explicitly defining it in Watir::Grid params.

Let me know how you go...

蝶舞 2024-11-21 08:44:02

现在 Webdriver 添加了对 Safari 的支持,这可能会更容易一些,

请参阅此处了解更多信息:http://watirmelon.com/2012/04/17/using-watir-webdriver-with-safari-at-last/

This might be a bit easier now that Webdriver has added support for Safari

See here for more info: http://watirmelon.com/2012/04/17/using-watir-webdriver-with-safari-at-last/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文