Skip to content
Browse files

#execute_script hides result element before adding it to the DOM

  • Loading branch information...
1 parent 33275ab commit 028d580049a7a7f04dac22125520889d2632fdbc @jarmo jarmo committed Jan 28, 2012
Showing with 3 additions and 8 deletions.
  1. +1 −3 watir/lib/watir/frame.rb
  2. +2 −5 watir/lib/watir/ie-class.rb
View
4 watir/lib/watir/frame.rb
@@ -55,9 +55,7 @@ def execute_script(source)
wrapper = "_watir_helper_div_#{Time.now.to_i}"
cmd = "var e = document.createElement('DIV'); e.style.display = 'none'; e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
document.parentWindow.execScript(cmd)
- wrapper_obj = document.getElementById(wrapper)
- result_value = wrapper_obj.innerHTML
- result_value
+ document.getElementById(wrapper).wrapper_obj.innerHTML
end
end
View
7 watir/lib/watir/ie-class.rb
@@ -417,12 +417,9 @@ def execute_script(source)
rescue WIN32OLERuntimeError, NoMethodError #if eval fails we need to use execScript(source.to_s) which does not return a value, hence the workaround
escaped_src = source.to_s.gsub(/[\r\n']/) {|m| "\\#{m}"}
wrapper = "_watir_helper_div_#{rand(100000)}"
- cmd = "var e = document.createElement('DIV'); e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
+ cmd = "var e = document.createElement('DIV'); e.style.display='none'; e.id='#{wrapper}'; e.innerHTML = eval('#{escaped_src}'); document.body.appendChild(e);"
document.parentWindow.execScript(cmd)
- wrapper_obj = document.getElementById(wrapper)
- result_value = wrapper_obj.innerHTML
- wrapper_obj.style.display = 'none'
- result_value
+ document.getElementById(wrapper).innerHTML
end
# clear the list of urls that we have visited

0 comments on commit 028d580

Please sign in to comment.
Something went wrong with that request. Please try again.