NoSuchWindowError: Browsing context has been discarded with GeckoDriver Firefox and Protractor(Selenium)

后端 未结 2 1738

I\'m trying to run a simple test script using protractor.

Environment:

Node Version: v9.8.0
Protractor Version: 5.4.1
Angular Version: 1.x
Browser(s)         


        
相关标签:
2条回答
  • 2020-12-06 21:37

    This error message...

    Failed: Browsing context has been discarded
    

    ...implies that the communication between GeckoDriver and Marionette was broken.

    Some more information regarding the GeckoDriver binary version would have given us some clues about whats wrong happening. However this issue can happen due to multiple factors as follows:

    • As per Hang when navigation request removes the current browsing context if you have used driver.navigate().back(); when Selenium's focus was within an <iframe> this error is observed.
    • As per Crash during command execution results in "Internal Server Error: Failed to decode response from marionette" this issue can also occur due to ctypes checks for NULL pointer derefs.
      • You can find the Selenium testcase here. Perhaps instead of panicking, it would have been better to handle this more gracefully by clearing any state and returning geckodriver to accept new connections again.
    • As per Failed to decode response from marionette - Error to open Webdriver using python this issue can also occur if you are not using the complient version of the binaries.

    This usecase

    The root cause of this issue seems to be MemoryUsage. As per Intermittent awsy\test_memory_usage.py TestMemoryUsage.test_open_tabs | NoSuchWindowException: Browsing context has been discarded which is intermittent in nature. This issue was once marked as RESOLVED then again REOPENED.

    As @Madhan mentioned while working with AngularJS applications and Protractor always include:

    waitForAngularEnabled(true);
    

    Finally, as per best practices while working with GeckoDriver, Selenium and Firefox Browser follow the below compatibility chart:

    Supported platforms

    supported_platforms_geckodriver_24

    0 讨论(0)
  • 2020-12-06 21:56

    Was able to fix this issue with below configuration.

    - Protractor: v5.4.1 
    - Selenium JAR driver: selenium-server-standalone-3.141.59.jar 
    - geckodriver:geckodriver-v0.20.0-linux64
    

    Also we need to give path of geckodrvier in protractor conf file.

    geckoDriver: 'node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.20.0'
    

    By default webdriver-manager will download latest version of geckodriver which is 0.24.0. But the needed geckdriver is v0.20.0, so I downloaded this manually and placed it inside node_modules/protractor/node_modules/webdriver-manager/selenium/ directory.

    Hope this helps to people facing similar issue.

    0 讨论(0)
提交回复
热议问题