Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When I run this Code in GoogleColab

import os
from seleniumbase import BaseCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class MyTestCase(BaseCase):
    def test_login_and_search(self):
        # Prompt the user for Microsoft Edge browser sign-in credentials
        username = input("Enter your username: ")
        password = input("Enter your password: ")

        # Set the path to the Microsoft Edge WebDriver executable directory
        webdriver_directory = "/usr/local/bin/"  # Replace with the actual directory

        # Add the WebDriver directory to the PATH environment variable
        os.environ["PATH"] += os.pathsep + webdriver_directory

        # Create a new instance of the Microsoft Edge driver
        self.driver = webdriver.Edge()

        # Maximize the browser window (optional)
        self.driver.maximize_window()

        # Navigate to the Microsoft sign-in page
        self.open("https://login.live.com/")

        # Wait until the username field is visible and enter the username
        self.wait_for_element_visible("name:loginfmt")
        self.type("name:loginfmt", username)
        self.press_key("name:loginfmt", Keys.RETURN)

        # Wait until the password field is visible and enter the password
        self.wait_for_element_visible("name:passwd")
        self.type("name:passwd", password)
        self.press_key("name:passwd", Keys.RETURN)

        # Wait until the search box is visible and enter the search query
        self.wait_for_element_visible("name:q")
        self.type("name:q", "hello")
        self.press_key("name:q", Keys.RETURN)

        # Close the browser
        self.driver.quit()

# Run the test case
MyTestCase().test_login_and_search()


What I have tried:

It give this Error
WebDriverException                        Traceback (most recent call last)
<ipython-input-17-f43b2023c7bb> in <cell line: 49>()
     47 
     48 # Run the test case
---> 49 MyTestCase().test_login_and_search()

6 frames
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
    243                 alert_text = value["alert"].get("text")
    244             raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
--> 245         raise exception_class(message, screen, stacktrace)

WebDriverException: Message: unknown error: Microsoft Edge failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from msedge location /usr/bin/microsoft-edge is no longer running, so msedgedriver is assuming that msedge has crashed.)
Stacktrace:
#0 0x5559aab68013 <unknown>
#1 0x5559aa8748c1 <unknown>
#2 0x5559aa8a0cdf <unknown>
#3 0x5559aa89c1ed <unknown>
#4 0x5559aa8dcea5 <unknown>
#5 0x5559aa8d4043 <unknown>
#6 0x5559aa8a7941 <unknown>
#7 0x5559aa8a8b5e <unknown>
#8 0x5559aab345b6 <unknown>
#9 0x5559aab380c9 <unknown>
#10 0x5559aab37bb9 <unknown>
#11 0x5559aab38585 <unknown>
#12 0x5559aab3fa5b <unknown>
#13 0x5559aab3892e <unknown>
#14 0x5559aab1220c <unknown>
#15 0x5559aab53d88 <unknown>
#16 0x5559aab53ec4 <unknown>
#17 0x5559aab617e6 <unknown>
#18 0x7f6dd80d4609 start_thread


Note: I have used same version of edgedriver and microsoft edge ,and the path is also correct and the selenium version is also latest But I still getting Error . I have also used chmod +x msedgedriver for permission for execution
Posted
Updated 11-Jun-23 0:52am

1 solution

1. Your code might run a redundant Edge Driver copy. Search for any redundant Edge Driver using keywords like "msedgedriver" or "MicrosoftWebDriver" tp locate older versions and delete those.
2. You can specify the actual path by changing -
Quote:
self.driver = webdriver.Edge()
to -
self.driver = webdriver.Edge(executable_path='/path/to/msedgedriver')

3. You can back up your User Data folder in the same path and use that folder in selenium.
4. Try running without headless mode running it without headless mode enabled. Headless mode can sometimes cause compatibility issues. Comment out or remove the line that sets headless mode -
Quote:
options.add_argument('--headless')
if used.

See these 2 solutions which might help solve your issue -
MSEdge failed to start: crashed (chrome not reachable)[^]
Selenium failing[^]

Not my field of expertise so I hope the above from Google helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900