watir browser.attach 覆盖以前的浏览器对象

发布于 2024-10-26 22:52:12 字数 552 浏览 7 评论 0原文

我需要在我的网站上使用 facebook connect 测试登录。单击“使用 Facebook 进行连接”按钮时,会打开一个弹出窗口。

我使用 ie = Watir::Browser.attach(:title, 'Login | Facebook') 将此新窗口分配给新对象。但不知何故,以前的浏览器对象也引用了新对象。

b = Watir::Browser.start( "http://www.pstom.com" )
b.link(:text, "Connect with Facebook").click
irb(main):081:0> puts b.title
PSToM - Home
=> nil
ie = Watir::Browser.attach(:title, 'Login | Facebook')
 puts b.title
Login | Facebook
=> nil
irb(main):085:0> puts ie.title
Login | Facebook
=> nil

出了什么问题(我正在 Ubuntu 中的 IRB 中进行测试)

I need to test login using facebook connect on my site. When clicking on connect using facebook button, a pop is open.

I use ie = Watir::Browser.attach(:title, 'Login | Facebook') to assign this new window to a new object. But somehow it the previous browser object also refrences the new object.

b = Watir::Browser.start( "http://www.pstom.com" )
b.link(:text, "Connect with Facebook").click
irb(main):081:0> puts b.title
PSToM - Home
=> nil
ie = Watir::Browser.attach(:title, 'Login | Facebook')
 puts b.title
Login | Facebook
=> nil
irb(main):085:0> puts ie.title
Login | Facebook
=> nil

What is going wrong (I'm testing in IRB in Ubuntu)

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

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

发布评论

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

评论(2

乙白 2024-11-02 22:52:12

我认为 firewatir gem 和附加存在问题。尝试使用 watir-webdriver gem 进行相同的操作(它可以驱动 Firefox)。

github: https://github.com/jarib/watir-webdriver
rubygems: https://rubygems.org/gems/watir-webdriver
安装:
https://github.com/zeljkofilipin/watirbook/blob/master/installation -ubuntu.md
https://github.com/zeljkofilipin/watirbook/downloads

I think there was a problem with firewatir gem and attaching. Try the same with watir-webdriver gem (it can drive Firefox).

github: https://github.com/jarib/watir-webdriver
rubygems: https://rubygems.org/gems/watir-webdriver
installation:
https://github.com/zeljkofilipin/watirbook/blob/master/installation-ubuntu.md
https://github.com/zeljkofilipin/watirbook/downloads

淑女气质 2024-11-02 22:52:12

我在 Windows/IE 上得到了正确的行为。你们有哪些版本?我有 ruby​​ 1.8.7 和 watir 1.7.1

irb(main):001:0> require 'watir'
=> true
irb(main):002:0> a = Watir::Browser.attach(:title, 'Google')
=> #<Watir::IE:0x4ecfde0 url="http://www.google.com/" title="Google">
irb(main):003:0> puts a.title
Google
=> nil
irb(main):004:0> b = Watir::Browser.attach(:title, 'Bing')
=> #<Watir::IE:0x4ea59d8 url="http://www.bing.com/" title="Bing">
irb(main):005:0> puts b.title
Bing
=> nil
irb(main):006:0> puts a.title
Google
=> nil
irb(main):007:0>

I got the correct behavior on Windows/IE. What versions do you have? I have ruby 1.8.7 and watir 1.7.1

irb(main):001:0> require 'watir'
=> true
irb(main):002:0> a = Watir::Browser.attach(:title, 'Google')
=> #<Watir::IE:0x4ecfde0 url="http://www.google.com/" title="Google">
irb(main):003:0> puts a.title
Google
=> nil
irb(main):004:0> b = Watir::Browser.attach(:title, 'Bing')
=> #<Watir::IE:0x4ea59d8 url="http://www.bing.com/" title="Bing">
irb(main):005:0> puts b.title
Bing
=> nil
irb(main):006:0> puts a.title
Google
=> nil
irb(main):007:0>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文