Several times I spend several hours to identify an element, the element is there, but watir can not find it.
I click a link and a new IE window comes up, and forget to attach the new IE window, so watir and me are looking for elements on different windows.
Bellow is the code to refresh a browser using watir:
ie77.refresh
Related Blogs
Bellow is the code to choose the second option from a select box:
ie77.select_list(:class,’inputboxb’).select_item_in_select_list(:index,1)
Related Blogs
- Related Blogs on select_list
I tried to input data to the inner html of iframe by watir for several months, and posted questions to many forums but got no answer.
Yesterday an idea came into my mind, and I found a solution, following is the code:
ie77.frame(:id, /Editor/).document.body.innertext = “good and better”
Related Blogs
- Related Blogs on innerpage
I found by chance that we can use the text property to locate a link in watir, the following is the syntax I used:
ie77.link(:text => /the text in a link/).click
Related Blogs
I used to close some browsers by following code:
puts “to close a certain previous browser”
Watir::IE.attach(:title, /google/).close
puts “to close a certain previous browser”
Watir::IE.attach(:title, /Internet/).close
puts “to close a certain previous browser”
Watir::IE.attach(:title, /Internet/).close
but when 2 or more watir programs run together, they stalled there. I don’t know the reason, so I tried the following code which worked ok:
sleep 1
puts “to close all the other browsers”
ie77.close_others
sleep 1
puts “to close current browser”
ie77.close