Skip to content

File upload broken #9292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nijel opened this issue Mar 17, 2021 · 9 comments
Closed

File upload broken #9292

nijel opened this issue Mar 17, 2021 · 9 comments
Labels
C-py Python Bindings J-awaiting answer Question asked of user; a reply moves it to triage again

Comments

@nijel
Copy link
Contributor

nijel commented Mar 17, 2021

🐛 Bug Report

A clear and concise description of what the bug is.

File upload with Chrome and Selenium 4.0.0b2 fails with:

File "/home/nijel/weblate/weblate/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 768, in _upload
    raise e
  File "/home/nijel/weblate/weblate/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 759, in _upload
    return self._execute(Command.UPLOAD_FILE, {'file': content})['value']
  File "/home/nijel/weblate/weblate/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 693, in _execute
    return self._parent.execute(command, params)
  File "/home/nijel/weblate/weblate/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 369, in execute
    self.error_handler.check_response(response)
  File "/home/nijel/weblate/weblate/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 236, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown command: unknown command: session/ef65ec6962b7f875385bacdb072ee837/se/file
Stacktrace:
#0 0x562d9d555069 <unknown>
#1 0x562d9d4f72d3 <unknown>
#2 0x562d9d281946 <unknown>
#3 0x562d9d2d575a <unknown>
#4 0x562d9d2d5574 <unknown>
#5 0x562d9d257d75 <unknown>
#6 0x562d9d258fa3 <unknown>
#7 0x562d9d522bc4 <unknown>
#8 0x562d9d5315ea <unknown>
#9 0x562d9d5312de <unknown>
#10 0x562d9d53598a <unknown>
#11 0x562d9d531e8b <unknown>
#12 0x562d9d517ff0 <unknown>
#13 0x562d9d257bdf <unknown>
#14 0x7f58aaa96d0a __libc_start_main
#15 0x562d9d25672a _start

There are already some related issues like #7666 or #8735, but they really don't give any hints how to address this.

It is broken since #8588, removing the se/ prefix from the Command.UPLOAD_FILE fixes the behavior.

To Reproduce

Detailed steps to reproduce the behavior:

        element.send_keys(element._upload("screenshot.png"))

Expected behavior

The upload would work.

Test script or set of commands reproducing this issue

Reproducible in https://github.com/WeblateOrg/weblate CI: https://github.com/WeblateOrg/weblate/runs/2124766327?check_suite_focus=true

Environment

OS: Linux
Browser: Chrome
Browser version:89.0.4389.82
Browser Driver version: ChromeDriver 89.0.4389.82
Language Bindings version: Python 4.0.0b2
Selenium Grid version (if applicable):

@ghost ghost added the A-needs-triaging A Selenium member will evaluate this soon! label Mar 17, 2021
nijel added a commit to WeblateOrg/weblate that referenced this issue Mar 17, 2021
We need 4.0, but the recent releases always had some issues.

See SeleniumHQ/selenium#9292
@AutomatedTester
Copy link
Member

AutomatedTester commented Mar 17, 2021 via email

@diemol
Copy link
Member

diemol commented Mar 17, 2021

Also, are you using Grid or running those tests locally?

@diemol diemol added J-awaiting answer Question asked of user; a reply moves it to triage again and removed A-needs-triaging A Selenium member will evaluate this soon! labels Mar 17, 2021
@AutomatedTester AutomatedTester added the C-py Python Bindings label Mar 17, 2021
@nijel
Copy link
Contributor Author

nijel commented Mar 17, 2021

Running locally. I can reproduce this both on my system and on GitHub Actions.

@diemol
Copy link
Member

diemol commented Mar 17, 2021

A code snippet would be helpful, could you please post it here?

@nijel
Copy link
Contributor Author

nijel commented Mar 17, 2021

This is what fails with 4.0.0b2 and worked in 4.0.0a6.post2 (I could not use versions in between due to other issues):

https://github.com/WeblateOrg/weblate/blob/e8451e7ddc1321743fb5463fef2c94a6ae9f9ae2/weblate/trans/tests/test_selenium.py#L508

Here the webdriver is constructed:

https://github.com/WeblateOrg/weblate/blob/e8451e7ddc1321743fb5463fef2c94a6ae9f9ae2/weblate/trans/tests/test_selenium.py#L111-L139

It might be that we're doing something wrong, but it worked just fine for several years and broke now.

@AutomatedTester
Copy link
Member

You appear to be calling an internal method here on that line, why are you not just calling send_keys as is. See https://github.com/SeleniumHQ/selenium/blob/trunk/py/test/selenium/webdriver/common/upload_tests.py which have tests passing as expected.

@nijel
Copy link
Contributor Author

nijel commented Mar 17, 2021

Honestly, I don't recall why we're doing that, it might be a relict from the past when we used SauceLabs and did not run the browser locally.

nijel added a commit to WeblateOrg/weblate that referenced this issue Mar 17, 2021
@nijel
Copy link
Contributor Author

nijel commented Mar 17, 2021

Thanks for pointing me into that direction, removing usage of internal method seems to work. Feel free to close this if it behaves as intended.

@AutomatedTester
Copy link
Member

glad you got it sorted!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-py Python Bindings J-awaiting answer Question asked of user; a reply moves it to triage again
Projects
None yet
Development

No branches or pull requests

3 participants