While creating an automation script using Ruby with Selenium, Watir, and Cucumber, I encountered a test failure caused by a change in a text field. The issue arose because a Javascript function was triggered upon interacting with the field, restricting input to numeric KeyCodes, decimals, and pasting. After this modification, only "." could be entered into the field, making it impossible to input any other value. I tried converting inputs to numerical values using methods like "to_i" and "to_f", as well as alternative approaches such as:
browser.text_field(:id, "rate").set(val)
or
browser.text_field(:id, "rate").value=(val)
or
browser.text_field(:id, "rate").send_keys :numpad1
Unfortunately, none of these methods resulted in anything appearing in the text field except for the decimal. I am struggling to find a solution to bypass or deactivate the interfering Javascript temporarily so that I can enter values programmatically, then reactivate it to maintain the integrity of the overall environment. My inquiries are: 1) Has anyone encountered a similar issue and managed to resolve it? If not, 2) How can I disable JavaScript dynamically to input values and enable it back again seamlessly?