×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Ruby
Posted by: Mandisi Makwakwa
Added: May 24, 2018 12:49 PM
Views: 3127
Tags: no tags
  1. #Get the first link (or any element you want)
  2. element = browser.div(:id => 'topnavTut').link
  3.  
  4. #Check element's initial target attribute
  5. puts element.attribute_value('target')
  6. #=> "_top"
  7.  
  8. #Execute javascript to change the attribute
  9. script = "return arguments[0].target = 'foo'"
  10. browser.execute_script(script, element)
  11.  
  12. #Check that the target attribute has changed
  13. puts element.attribute_value('target')
  14. #=> "foo"