question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

4.0.0.b1 fails when testing file uploads

See original GitHub issue

🐛 Bug Report

4.0.0.b1 fails when testing file uploads. This worked in 4.0.0a7.

Test script or set of commands reproducing this issue

Baseline successful build on 2021-01-28 with selenium-4.0.0a7: https://github.com/Pylons/deformdemo/runs/1783717797?check_suite_focus=true

Failed build on 2021-02-22 with selenium-4.0.0b1: https://github.com/Pylons/deformdemo/runs/1949937935?check_suite_focus=true

Final successful build on 2021-02-22 with selenium-4.0.0a7: https://github.com/Pylons/deformdemo/runs/1950522237?check_suite_focus=true

Stacktrace of one of four similar test failures:

______________________ FileUploadTests.test_submit_filled ______________________

self = <deformdemo.test.FileUploadTests testMethod=test_submit_filled>

    def test_submit_filled(self):
        # submit one first
        path, filename = _getFile()
>       findcss("input[type=file]").send_keys(path)

deformdemo/test.py:1466: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py:520: in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
.tox/py/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py:664: in _execute
    return self._parent.execute(command, params)
.tox/py/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py:344: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f8c94fb6850>
response = {'status': 400, 'value': '{"value":{"error":"invalid argument","message":"File not found: /home/runner/work/deformdemo...//marionette/content/error.js:310:5\\ninteraction.uploadFiles@chrome://marionette/content/interaction.js:509:13\\n"}}'}

    def check_response(self, response):
        """
        Checks that a JSON response from the WebDriver does not have an error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get('status', None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get('value', None)
            if value_json and isinstance(value_json, str):
                import json
                try:
                    value = json.loads(value_json)
                    if len(value.keys()) == 1:
                        value = value['value']
                    status = value.get('error', None)
                    if not status:
                        status = value["status"]
                        message = value["value"]
                        if not isinstance(message, str):
                            value = message
                            message = message.get('message')
                    else:
                        message = value.get('message', None)
                except ValueError:
                    pass
    
        if status in ErrorCode.NO_SUCH_ELEMENT:
            exception_class = NoSuchElementException
        elif status in ErrorCode.NO_SUCH_FRAME:
            exception_class = NoSuchFrameException
        elif status in ErrorCode.NO_SUCH_WINDOW:
            exception_class = NoSuchWindowException
        elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
            exception_class = StaleElementReferenceException
        elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
            exception_class = ElementNotVisibleException
        elif status in ErrorCode.INVALID_ELEMENT_STATE:
            exception_class = InvalidElementStateException
        elif status in ErrorCode.INVALID_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
            exception_class = InvalidSelectorException
        elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
            exception_class = ElementNotSelectableException
        elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
            exception_class = ElementNotInteractableException
        elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
            exception_class = InvalidCookieDomainException
        elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
            exception_class = UnableToSetCookieException
        elif status in ErrorCode.TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.SCRIPT_TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.UNKNOWN_ERROR:
            exception_class = WebDriverException
        elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
            exception_class = UnexpectedAlertPresentException
        elif status in ErrorCode.NO_ALERT_OPEN:
            exception_class = NoAlertPresentException
        elif status in ErrorCode.IME_NOT_AVAILABLE:
            exception_class = ImeNotAvailableException
        elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
            exception_class = ImeActivationFailedException
        elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
            exception_class = MoveTargetOutOfBoundsException
        elif status in ErrorCode.JAVASCRIPT_ERROR:
            exception_class = JavascriptException
        elif status in ErrorCode.SESSION_NOT_CREATED:
            exception_class = SessionNotCreatedException
        elif status in ErrorCode.INVALID_ARGUMENT:
            exception_class = InvalidArgumentException
        elif status in ErrorCode.NO_SUCH_COOKIE:
            exception_class = NoSuchCookieException
        elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
            exception_class = ScreenshotException
        elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
            exception_class = ElementClickInterceptedException
        elif status in ErrorCode.INSECURE_CERTIFICATE:
            exception_class = InsecureCertificateException
        elif status in ErrorCode.INVALID_COORDINATES:
            exception_class = InvalidCoordinatesException
        elif status in ErrorCode.INVALID_SESSION_ID:
            exception_class = InvalidSessionIdException
        elif status in ErrorCode.UNKNOWN_METHOD:
            exception_class = UnknownMethodException
        else:
            exception_class = WebDriverException
        if not value:
            value = response['value']
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and 'message' in value:
            message = value['message']
    
        screen = None
        if 'screen' in value:
            screen = value['screen']
    
        stacktrace = None
        st_value = value.get('stackTrace') or value.get('stacktrace')
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split('\n')
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = self._value_or_default(frame, 'lineNumber', '')
                        file = self._value_or_default(frame, 'fileName', '<anonymous>')
                        if line:
                            file = "%s:%s" % (file, line)
                        meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                        if 'className' in frame:
                            meth = "%s.%s" % (frame['className'], meth)
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if 'data' in value:
                alert_text = value['data'].get('text')
            elif 'alert' in value:
                alert_text = value['alert'].get('text')
            raise exception_class(message, screen, stacktrace, alert_text)
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.InvalidArgumentException: Message: File not found: /home/runner/work/deformdemo/deformdemo/deformdemo/test.py
E       Stacktrace:
E       WebDriverError@chrome://marionette/content/error.js:181:5
E       InvalidArgumentError@chrome://marionette/content/error.js:310:5
E       interaction.uploadFiles@chrome://marionette/content/interaction.js:509:13

Environment

OS: Ubuntu 18.04 and 20.04 LTS Browser: Firefox Browser version: Selenium/Firefox Browser Driver version: GeckoDriver 0.29.0 Language Bindings version: Python 3 Selenium Grid version (if applicable): See above

Deform and Deformdemo are open source projects. I am happy to share whatever information may be helpful to isolate the cause.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
pythobotcommented, Apr 10, 2021

I think this issue began here:

https://github.com/SeleniumHQ/selenium/commit/85ae06e1d29485fd627b40bf685a03da70c3c6b1#diff-167af39a13c2c1c011a621b7b0f0ff5a76a6bd965a0d077e611d02de2992945cL539

I was also having problem when uploading a file and found that was the issue. I fixed it and it works OK now.

1reaction
stevepiercycommented, Jun 9, 2021

@GeyseR what would I do without you? Thank you! I completely forgot I added that deliberately failing test. Removing that test yields a fully successful build. 🎉

It guess the fix for this issue actually did make it into the release. I didn’t see a change history file in the root of the repo, and I am not familiar with the release process. Apologies for my misunderstanding.

Closing as resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems after upgrading to 4.10.5 - GlobaLeaks Support Forum
Hi, after upgrading i get the following error message: Ouch! The installation failed. COMBINED STDOUT/STDERR OUTPUT OF FAILED COMMAND:
Read more >
deleteinstance - Rocket Software Documentation
Deletes an instance of a component.
Read more >
pytest Documentation - Read the Docs
The first test passed and the second failed. You can easily see the intermediate values in the assertion to help you under-.
Read more >
Bug listing with status RESOLVED with resolution TEST ...
Bug:233 - "Emacs segfaults when merged through the sandbox." status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not ...
Read more >
plone.app.discussion 4.0.0 - PyPI
Fix tests failing for Plone 6, deprecate Plone 4 and older. ... This fixes the accidentally triggered file upload when a comment is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found