“NoSuchSessionError: This driver instance does not have a valid session ID” when running a simple Selenium Runner test

前端 未结 1 1377
有刺的猬
有刺的猬 2021-01-14 01:53

I just installed the latest version of Selenium Runner

npm install -g selenium-side-runner

on my Mac High Sierra. I\'m running node v14.1.

相关标签:
1条回答
  • 2021-01-14 02:25

    invalid session id

    The invalid session ID error is a WebDriver error that occurs when the server does not recognize the unique session identifier. This happens if the session has been deleted or if the session ID is invalid.

    A WebDriver session can be deleted through either of the following ways:

    • Explicit session deletion: A WebDriver session is explicitly deleted when explicitly invoking the quit() method.

    • Implicit session deletion: A WebDriver session is implicitly deleted when you close the last window or tab invoking close().

    You can find a detailed discussion in selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python


    This usecase

    I don't see any such error within your code block. However your main error seems to be...

    Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 300000ms timeout specified by jest.setTimeout.Error:
    

    ...which implies that the Async callback being referred to in the error is getting timedout even with timeout set as 300000:

    jest.setTimeout(300000);
    

    The real issue is with the url of KarmaDecay which contains a hCaptcha to keep off automated bots.

    • URL Snapshot:

    hCaptcha_Karmadecay


    Conclusion

    As per your test setup to execute the selenium-side-runner within the website http://karmadecay.com/ first you have to interact with the captcha to get authenticated and then run your tests.

    You can find a couple of relevant discussions on how to interact with recaptcha in:

    • How to identify the 32 bit data-sitekey of ReCaptcha V2 to obtain a valid response programmatically using Selenium and Python Requests?
    • Find the reCAPTCHA element and click on it — Python + Selenium
    • How to click on the reCaptcha using Selenium and Java

    Another aspect

    If the initial tests works fine but for the rest of your tests you get a session ID error most possibly the Selenium WebDriver controled Browsing Context is getting detected and hence blocking the next requests.

    There are different reasons for the WebDriver controled Web Browser to get detected and simultaneously get blocked. You can find a couple of detailed discussion in:

    • Can a website detect when you are using selenium with chromedriver?
    • Selenium webdriver: Modifying navigator.webdriver flag to prevent selenium detection
    0 讨论(0)
提交回复
热议问题