2

The common problem in Selenium is typing a text into the input element (type="file"). This action cannot be done using JavaScript due to security reasons.

Normally (with other input, or with a file input but using Selenium IDE) this would be:

driver.find_element_by_id("inputFileId").send_keys("/tmp/tmp.txt")

But this doesn't work at all.

Some solution I found are:

  • Use *chrome environment type rather than *firefox or *iexplore.
  • Set your singed.applets.codebase_principal_support to true in your Mozilla configuration.

None of them worked for me.

Is there any way to avoid this security restriction on Firefox in order to be able to run these tests?

Cairnarvon
  • 25,981
  • 9
  • 51
  • 65
Leandro
  • 499
  • 1
  • 5
  • 13
  • Question has been asked a few times on SO, here's one that seems to have worked: http://stackoverflow.com/a/10472542/1257773 – kenki Nov 09 '12 at 20:15
  • Thanks you your answer, but that does not work at all. The answer there is the one detailed above, which does not work. I couldn't find any solution for this. It is an actual restriction of JavaScript due to security reasons, therefore calling a JavaScript will not work neither. – Leandro Nov 12 '12 at 12:19
  • I use the method you described to upload files with no problem whatsoever – Bob Evans Nov 16 '12 at 23:02
  • Are you using python client and firefox? Can you share a piece of code please? It works using selenium iDE, but not running a test a python script, using selenium RC. Please confirm this. Thanks – Leandro Nov 20 '12 at 11:31

0 Answers0