Get Elements By Attributes
i will be short. As far as i know watir library provides two methods for getting html elements. Almost for each element (div, button, table, li, etc) watir provides two methods: .
Solution 1:
Juan,
your script has several problems:
- You say you want to flash all links, but then you use
watir_instance.divs
. It should bewatir_instance.links
- you pass arguments to
divs
method:watir_instance.divs(:id, 'my_link_id')
. It should be justwatir_instance.divs
Your example is also strange:
i want to flash all the links with id:my_link_id
As far as I know, id should be unique at the page.
So, here are different examples:
1) Flash all links on this page:
require"watir"
b = Watir::IE.start "http://stackoverflow.com/questions/1434697"
b.links.each do|link|
link.flash
end
2) Flash all links on this page that have questions
in URL (bonus: scroll the page so the link that is flashed is visible):
require"watir"
b = Watir::IE.start "http://stackoverflow.com/questions/1434697"
b.links.each do|link|if link.href =~ /questions/
link.document.scrollintoview
link.flash
endend
Post a Comment for "Get Elements By Attributes"