Is there anyway could I able to print the index of the current browser?
If you mean take all of the windows and find the index of one, yes:
irb(main):009:0> b1.windows.index b1
irb(main):010:0> b1.windows.index b2
yes this is what I want. Thank you so much.
it gives me NoMethodError
So I used the way which I’ve given below.
puts $browser.windows.count - 1
Now I am getting the index of the window
You need to pass an argument to #index: the browser object you want the
if i write the code like
then it throws this error
You still haven’t shown the error message, despite mentioning it twice.
if i print $browser.windows.index then it’s printing
“browser” as a method does not appear anywhere in the code you have
shown. This is referring to a line of code you haven’t posted here.
oh extremely sorry. I was about to paste the error message but
mistakenly pasted puts statement twice. Here it is,
NoMethodError: undefined method `browser’ for #Watir::IE:0x43895e8
The error message is incomplete, and so is your code.
Please attach the code file and post the complete error message
including line number, or this is impossible to diagnose.
==': undefined methodbrowser’ for #Watir::IE:0x118d9a18
from C:/WATIR/Life/Main/Test.rb:24:in `index’
I don’t have that version of watir-classic. Can you try updating the gem
and see if the problem persists?
I am very sorry to say that Updation to the higher version of Ruby or
watir is not possible for me since I have already been in a project
where I am using Ruby 1.8.7 and Watir 3.0.0 and watir-classic-3.0.0.
This looks like a bug which was fixed at some point between 3.0.0 and
Oh ok thank you. I will try to update in future as soon as this project
comes to end.
ok i have written the below code
it writes in the console