Reputation: 69
I'm trying to test, using watir, a web app that we are developing and am running into a confusing error.
The HTML in question is
<td>
<div class="filter-container">
<input name="PersonName" type="text">
</div>
</td>
The command that chokes is:
b.text_field(:name, "PersonName").set "Robert"
And the error that irb gives back is:
Selenium::WebDriver::Error::InvalidElementStateError: Element is not currently interactable and may not be manipulated
from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
from /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.31.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
(There are several more lines, but I think the above is the relevant stuff)
The text box is "interactable" using the mouse and keyboard, so I don't know why watir is balking. Any ideas?
Upvotes: 3
Views: 6459
Reputation: 17576
This happens to me a lot, looks like it's trying to access an element too early. Example code for a page having dynamic modal with two Ok/Cancel buttons:
Doesn't work:
$this->getSession()->getPage()->pressButton('Cancel');
Works well in my case:
sleep(1);
$this->getSession()->getPage()->pressButton('Cancel');
Sadly I didn't found any Selenium solution to wait until an element is "interactable".
Upvotes: 0
Reputation: 1
I was encountering the same type of selenium error message and discovered clearing all the browser history (Browsing & Download History, Form & Search history, Cookies, Cache, Active Logins, Offline Website Data, and Site Preferences) before I ran the code allowed it to work as expected.
It's not a great solution because I have to clear everything every time I run the code. Not elegant but functional.
Note: I'm invoking selenium via splinter and using firefox as my splinter browser, in case that matters.
Upvotes: 0
Reputation: 31345
Check to ensure Selenium is not finding a second hidden element on the page with the same name.
Upvotes: 1
Reputation: 494
Is it possible that there might be more than one text field on the page with the input name of PersonName? Maybe somewhere hidden on the page? Selenium might be targeting the other text field and reporting that it is disabled. Try using:
b.div(:class, "filter-container").text_field(:name, "PersonName").set "Robert"
Upvotes: 3