Reputation: 8717
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)
Upvotes: 2
Views: 799
Reputation: 57282
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
Upvotes: 4
Reputation: 2016
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>
Upvotes: 0