Avinash Duggirala
Avinash Duggirala

Reputation: 371

Unable to fill a text box which is read only and in iframe using watir webdriver

I have a read only text field inside an iframe to be filled. Please find the navigation below.

  1. URL is "http://www.broadwaylofts.com/apartments/unitLevel.do?lid=en_US&pid=3015&uid=1866117&msud=Q%20&adAction=initial"

  2. Click on "Monthly Price" button.

  3. 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:

  1. 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
  1. 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
  1. 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

Answers (1)

Smooyk
Smooyk

Reputation: 409

Your code should looks like this:

b.execute_script("window.frames[0].document.getElementById('actionForm_moveindate').value = '03/20/2015';")

Upvotes: 2

Related Questions