Reputation: 371
I have a read only text field inside an iframe to be filled. Please find the navigation below.
Click on "Monthly Price" button.
You will be able to see a text box on overlay.
I am trying to fill that text box but I am unable to
Below are the ways I tried:
b.iframe(:class => "lb_iframe_pricegrid").execute_script("window.document.getElementById('actionForm_moveindate').value = '03/20/2015';")
It throws the following error
Selenium::WebDriver::Error::JavascriptError: window.document.getElementById(...) is null
b.execute_script("window.document.getElementById('actionForm_moveindate').value = '03/20/2015';")
It throws the following error
Selenium::WebDriver::Error::JavascriptError: window.document.getElementById(...) is null
b.iframe(:class => "lb_iframe_pricegrid").text_field.set "02/20/2015"
Below is the error I am facing
Watir::Exception::ObjectReadOnlyException: object is read only {:tag_name=>"input or textarea", :type=>"(any text type)"}
from /Library/Ruby/Gems/2.0.0/gems/watir-webdriver-0.6.10/lib/watir-webdriver/elements/element.rb:553:in `assert_writable'
from /Library/Ruby/Gems/2.0.0/gems/watir-webdriver-0.6.10/lib/watir-webdriver/user_editable.rb:12:in `set'
from (irb):19
from /usr/bin/irb:12:in `<main>'
Any thoughts or suggestion that make it work?
Upvotes: 2
Views: 695
Reputation: 409
Your code should looks like this:
b.execute_script("window.frames[0].document.getElementById('actionForm_moveindate').value = '03/20/2015';")
Upvotes: 2