watir browser.attach 覆盖以前的浏览器对象
我需要在我的网站上使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 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
我在 Windows/IE 上得到了正确的行为。你们有哪些版本?我有 ruby 1.8.7 和 watir 1.7.1
I got the correct behavior on Windows/IE. What versions do you have? I have ruby 1.8.7 and watir 1.7.1