3

the html part looks like this:

...
<form action="/upload/select-single/" method="post" enctype="multipart/form-data">
  <input type="hidden" name="csrfmiddlewaretoken" value="U3Uh3EAYWXaWEiNaWC3zcCQutQe8hGM53u4BTx810o08t1GwOfIJI2ayHCFQFySw">
  <p>
    <label for="id_file_field">File field:</label>
    <input id="id_file_field" name="file_field" type="file" multiple="" required="">
  </p>
  <input id="submit" type="submit" value="submit">
</form>
...

the selenium test like this:

...
btn_choose_file = self.browser.find_element_by_id("id_file_field")
# write file path to field
# to check that I really selected the field, I tried btn_choose_file.click() -> and it works
btn_choose_file.send_keys('/path/to/file')  # -> THIS is the line which seems to cause the problem
# click submit
self.browser.find_element_by_id("submit").click()
...

unfortunately when the test is executed this error is raised

selenium.common.exceptions.WebDriverException: Message: File not found: /path/to/file

this due to the part where the file path is send to the input element with btn_choose_file.send_keys('/path/to/file')

note: the real '/path/to/file' is the following

  • /Users/udos/development/trails/processfile/gpx_data/test_data/suite 001 - val poschiavo/Bernina - Le Prese.gpx (the file exists and I copied the path from the IDE)

very odd behaviour. this test was running before, somehow I managed to break it...

any suggestions what the cause could be?

UPDATE
downgrading Firefox from version 55.0.2 to 54.0.1 "fixed" the issue.
see -> https://stackoverflow.com/a/45753912/420953

6
  • 1
    Just a suggestion. You may try to remove spaces from path. Commented Aug 17, 2017 at 18:55
  • appreciated! I tried that with '/Users/udos/development/trails/processfile/gpx_data/test_data/other/data.gpx', same error :| Commented Aug 17, 2017 at 19:00
  • Can you show us the exact HTML and your exact line of code along with the exact error? Commented Aug 18, 2017 at 5:18
  • sure. just did. sorry about that. and I also added some comments to the selenium test as well Commented Aug 18, 2017 at 5:49
  • 1
    Put the file in "/tmp" and without space and try again with a smaller name? Commented Aug 18, 2017 at 7:01

3 Answers 3

3

One way to work around the issue is to replace all "/" occurances in the filename with "\" ("\\" in python).

This work at least on Windows.

Sign up to request clarification or add additional context in comments.

Comments

2

After this bug i installed and used chromewebdriver. Worked like firefox driver and all my tests run smoothly. I suggest you try it at least it worked like a charm for me

Comments

1

this error was due to an update of Firefox to version 55.0.2 (which automatically happened 2 days ago because I have automatic updates configured)

the following geckodriver issue pointed me into this direction

I then downgraded my Firefox version to 54.0.1 as described in article

with this, the selenium tests are running again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.