require 'watir'

 

#定义调用JS的类方法
class Watir::IE
  def run_script(js)
    ie.Document.parentWindow.execScript(js)
  end
end

 

ie = Watir::IE.new  
ie.goto("http://www.google.cn")  

js_string =  "alert(\"测试调用Javascript!\");"      

#调用类方法  
ie.run_script(js_string)

 

相关文章:

  • 2021-06-14
  • 2021-11-15
  • 2021-12-20
  • 2021-07-24
  • 2022-01-04
  • 2021-08-13
  • 2021-12-23
猜你喜欢
  • 2021-08-25
  • 2021-12-17
  • 2021-08-18
  • 2022-01-17
  • 2021-08-04
  • 2021-09-12
  • 2021-12-22
相关资源
相似解决方案