Execute js Code in watir-webdriver
In fact, some people will ask, watir-webdriver are all so many ways, why js is required, but watir is never without great power, and some things are still
Javascript convenience is required. For example, it is impossible for watir to solve the problem of counting all html tags,
browser.execute_script(“js brabrabra”)
Execute the JS script. If you want to return a value, add return to the script.
browser.execute_script(“return js brabrabra”)
For more js Code can refer to this: http://www.w3school.com.cn/htmldom/dom_obj_document.asp
The following are pending and unverified
If a confirmation window is displayed in the browser, you can do this.
browser.executeScript("window.confirm = function(msg) { returntrue; }");
Here also has a post specifically introduced this question: http://topic.csdn.net/u/20110218/13/e6b2a94c-1690-487f-85d0-0c16ec80d632.html? Seed = 1069168318 & r = 76443652 # r_76443652
If terraform is located and you want to prohibit only submission, you can use the form submit method instead of the button method.
Browser. form (: name, "f1"). submit