#Get the first link (or any element you want) element = browser.div(:id => 'topnavTut').link   #Check element's initial target attribute puts element.attribute_value('target') #=> "_top"   #Execute javascript to change the attribute script = "return arguments[0].target = 'foo'" browser.execute_script(script, element)   #Check that the target attribute has changed puts element.attribute_value('target') #=> "foo"