Running JavaScript in watchir-webdriver

I am trying to run the following javascript code snippet in my rubir script browser (watir webdriver). I am trying to set read-only element values:

@browser.execute_script("oFormObject = document.forms['/order/orders']; oFormElement = oFormObject.elements[\"order[begin_string]\"];") 

When I do this, I get an error, oFormObject is undefined.
But during the execution of the following code, I did not get any errors:

 @browser.execute_script("oFormObject = document.forms['/order/orders'];") 

I want to get form elements after that when I get an error. How should I run multiple lines of JS code in my watir script. How to select a form, get a form element, and then set the value of this form element.

+6
source share
1 answer
 @browser.execute_script <<-JS oFormObject = document.forms['/order/orders']; oFormElement = oFormObject.elements[\"order[begin_string]\"]; JS 
+10
source

Source: https://habr.com/ru/post/908527/


All Articles