Reputation: 107
I have HTML that looks like this:
<html>
<head></head>
<body>
<a class="xyxyxy" href="" onclick="window.open('https://iogossip.com/Disclosure.pdf', '_blank')">DISCLOSURE</a>
</body>
</html>
I need to put the 'https://iogossip.com/Disclour.pdf' to the screen. or put the whole thing like "window.open('https://iogossip.com/Disclosure.pdf', '_blank')" to the screen. when I do this:
puts browser.a.onclick
I am getting this error:
NoMethodError: undefined method `onclick' for #<Watir::Anchor:0x29fc448>
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.2/lib/watir
-webdriver/elements/element.rb:553:in `method_missing'
from (irb):6
from C:/Ruby193/bin/irb:12:in `<main>'
thanks,
Upvotes: 1
Views: 224
Reputation: 46836
You can get attribute values using the Element#attribute_value
method (which should be supported in watir 2.0.3):
puts browser.a.attribute_value('onclick')
#=> "window.open('https://iogossip.com/Disclosure.pdf', '_blank')"
Upvotes: 2