hi,
how can i make my program to wait until it chooses an element from the
combo box? It’s choosing an element from the combo box.
RAJ
hi,
how can i make my program to wait until it chooses an element from the
combo box? It’s choosing an element from the combo box.
RAJ
Do you mean selecting an option within the element’s list, or do you
mean selecting the element itself?
It should wait anyway while selecting something. What is it doing
instead?
yeah yeah it is waiting, I did some mistake here. Just I realized.
hi, i used this code to handle this pop up.
def modalDialog(flg)
begin
#Watir::wait($browser.modal_dialog().enabled)
if(flg ==1)
puts “modalDialog called”
errLog=$browser.modal_dialog().td(:class,“PopupMsgTitleMenu”).text
$browser.modal_dialog().table(:id,“OK”).click
else
$browser.modal_dialog().table(:id,"OK").click
errLog =""
end
return errLog
rescue Exception => e
$logger.error " modalDialog - #{e.message}"
end
end
Thank you
hi,
My browser is loading very slowly, due to that I am having this error,
C:/Ruby187/lib/ruby/gems/1.8/gems/watir-classic-3.2.0/lib/watir-classic/ie-class.rb:606:in
`attach_browser_window’: Unable to locate a window with url of
http://localhost/login.do
(Watir::Exception::NoMatchingWindowFoundException)
how could I rectify this?
RAJ
Sorry, these are both outside my area of expertise. Maybe some other
kind soul will be able to help
Thank you.
hi
I have another question, Server is overloaded when I automated this web
page application, if i look into the server, many thread hasn’t been
closed and remains idle,consequently,server gets overloaded very soon,
Can i make sure that whether all thread are closed once I run the
program. And I haven’t created any Thread program,but it still there is
a message in server says many thread remains idle. How can i make sure
threads are closed.?
RAJ
hi,
puts $browser.windows.count
$browser.windows.each do |w|
puts w.title
w.close
end
The above code of yours prints the title but it’s not closing the
window. You asked me to check whether it is a Javascript window,I
checked that,it is not JavaScript alert,I have used your code of below
puts $browser.alert.text
$browser.alert.close
It’s not working since it’s not JavaScript window. I told you I started
to use the Model dialog box, But somehow it’s having some problem
thereby I couldn’t continue with that. So can you give me the solution
why it’s not closing the window, and also you have written the code of
below
$browser.windows.last.use do
$browser. (code to read the message here)
end
Do i need to use like
$browser.windows.last.use do
$browser.window.text
end
to print the string in the pop up?And the pop up consist of OK and
cancel button, now i need to have a way to press the both the buttons
according to my requirement. Can you give me any solution to resolve
this problem?
And also I can’t use the developer tool to view the elements in the pop
up window, is there any way, can i know the id of the elements in the
pop up window?
RAJ
Ok,
how can I use choose the last window
for an instance you have given this code
“$browser.windows.last.use do”
Now how can i use this code to close the window?
I used like $browser.windows.last.close. But it is not working.
RAJ
Does it work with just a blank new window?
irb(main):106:0> require ‘watir-webdriver’
=> true
irb(main):107:0> b = Watir::Browser.new
=> #<Watir::Browser:0x…fcee16076 url=“about:blank” title="">
irb(main):108:0> b.windows.last.close
=> #<Watir::Window:0x…fad045588 located=true>
The above worked perfectly for me.
If that doesn’t work for you, what gem version & browser version are you
working with?
hi,
I tried in the way you tried (i.e)through irb, I met up with pop
problem, and then I open many browser and then I tried to close using
this comment
b.windows.last.close,all other windows are closed expect the one which
consist of pop up. What could be the reason?
And I executed your above code, when I use watir-webdriver it opens the
Firebox and when i use watir it opens the internet explorer, and it’s
closing also. But it is not closing when the window is having a pop up.
RAJ
Works for me:
irb(main):001:0> require ‘watir-webdriver’
=> true
irb(main):002:0> b = Watir::Browser.new
=> #<Watir::Browser:0x…fb514d2a0 url=“about:blank” title=“”>
irb(main):003:0> b.goto ‘google.com’
=> “http://www.google.co.uk/”
#Here I manually opened a new window from that session.
irb(main):004:0> b.windows.count
=> 2
irb(main):005:0> b.windows.each do |w|
irb(main):006:1* puts w.title
irb(main):007:1> end
Google
Gmail: Email from Google
=> [#<Watir:0x…fb49b4dbe located=true>,
#<Watir:0x…fd178cb4a located=true>]
irb(main):008:0> b.windows.each do |w|
irb(main):009:1* w.close
irb(main):010:1> end
=> [#<Watir:0x…fb49b4dbe located=true>,
#<Watir:0x…fd178cb4a l
ocated=true>]
#All Windows closed!
Perhaps there’s some Javascript code preventing the window from closing
until you’ve made a selection. In which case you’ll need to interact
with the window before closing it. The same principle applies, you just
transfer control to the popup until you’re done with it.
When you use this:
$browser.windows.last.use do
The variable “$browser” will refer to the last window (or whichever one
you choose in that line) until it reaches “end”. It should just be a
matter of interacting with the selected window in the same way as you
normally would.
I am using IE so i will try to reattach and also Can I read the message
from the pop up?if so, what code do I need to return?
RAJ
Raj pal wrote in post #1102781:
all other windows are closed expect the one which
consist of pop up.it is not closing when the window is having a pop up.
Then it’s something to do with the way the popup is created. I’d guess
that the popup doesn’t have watir attached to it.
If you don’t have watir’s control of the popup, then you have a few
options.
For IE you can use the COM object, or just use Watir to re-attach to it.
For Firefox you can either target the window, using the various ways of
dealing with a window regardless of what it contains; or you could use
the process library to kill the underlying process once you’ve finished
with the browser, thereby terminating all windows.
These approaches would also work with IE, but they should be second
choice to using its COM object.
But how can I attach the pop ? why i am asking is, when I attach the
window I use this code
b= Watir::IE.attach(:url,“www.google.com”)
But in the case of pop up I am not aware of url, If so, how would I
attach the pop up?
RAJ
In the version of Watir I have, you can just keep iterating via index.
Something like this:
100.times { |t|
puts ( Watir::Browser.attach( :index, t ) ).title rescue break
}
The way you read the message depends on exactly what the popup contains.
Once you attach to it it’s just the same as a normal window, so treat it
as such.
hi, I am using that model dialog box again where again I am having this
attaching problem, I have written your code of below, It’s perfectly
working, thank you very much, But I couldn’t able to understand how this
code is working, each and every time you are passing value through 1 to
100. But what is exactly happening when it encounters
Watir::Browser.attach(:index, 1) or Watir::Browser.attach( :index, 2 ) )
? could you explain me?
100.times { |t|
puts ( Watir::Browser.attach( :index, t ) ).title rescue break
}
RAJ
This is how it works if you have 2 IE windows open:
do…
Watir::Browser.attach( :index, 0 ) #Grab the first window
puts .title #Output the window title
loop #Onward to index 1!
Watir::Browser.attach( :index, 1 ) #Grab the second window
puts .title #Output the window title
loop #Sally forth to index 2!
Watir::Browser.attach( :index, 2 ) #Oh no, there’s no 3rd window!
rescue #Catch the error caused by not finding a window
break #Exit the loop
end
And that’s how it works.
It’s not an ideal solution as you will get a delay before timing out on
grabbing the non-existent upper indexed window, but given that you don’t
know how many windows are open, that’s the best I could come up with on
short notice.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs