Question

I am using the ruby gem selenium-webdriver (2.39.0) to automate testing of a website.

There is a web page with a hidden input tag, which, when a user clicks a different element, is populated with the path from the system file selection dialog.

We had been able to use element.send_keys to remote upload a file for the input dialog. However, this broke on IE recently - we now get an "element not visible" error when using send_keys. After reading about the design goal of selenium 2 to only mirror user interactions I expect this to break for other browsers at some point as well.

Since the selenium 1 execute_script() method does not seem to be available in this gem, I can't modify the input tag to be visible.

I assume others have solved this - how can I perform the file upload?

Était-ce utile?

La solution

The same method exist on that version of selenium-webdriver gem

driver.execute_script("document.getElementById('hidden').value = #{value};")

Here's the documentation:

http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/Driver.html#execute_script-instance_method

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top