how to fix "SessionNotCreatedException: session not created: DevToolsActivePort file doesn't exist"

Zhao, Tina SIEP-PTX/D/S 0 Reputation points
2024-03-27T14:11:15.93+00:00

Dear MS,
I'm following this link to try to use selenium and python to usewebdriver for edge

https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=python

And I followed the first example from the site

from selenium import webdriver from selenium.webdriver.common.by import By import time driver = webdriver.Edge() driver.get('https://bing.com') element = driver.find_element(By.ID, 'sb_form_q') element.send_keys('WebDriver') element.submit() time.sleep(5) driver.quit()

However, I got the following error:

File ~\AppData\Local\anaconda3\envs\snowpy\Lib\site-packages\selenium\webdriver\remote\errorhandler.py:229 in check_response

raise exception_class(message, screen, stacktrace)

SessionNotCreatedException: session not created: DevToolsActivePort file doesn't exist

How to fix it?

Thanks.

TX

Microsoft Edge Microsoft Edge development
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-03-28T03:33:05.86+00:00

    Hi @Zhao, Tina SIEP-PTX/D/S

    Which version of Edge and Edge WebDriver do you use? Which version of Selenium do you use?

    You could try the following possible solutions:

    1. Make sure you are using the latest version of Microsoft Edge and Edge driver.
    2. Make sure you are using Selenium 4.
    3. Kill all the processes of Microsoft Edge in Task Manager before you run the code and test again.
    4. Add options like below:
         edge_options = webdriver.EdgeOptions()
         edge_options.add_argument("no-sandbox")
         edge_options.add_argument("disable-dev-shm-usage")
         driver = webdriver.Edge(options = edge_options)   
      

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Yu Zhou

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.