This is the code which I am running in Google colab:
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
from selenium.webdriver.edge.service import Service
# 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
webdriver_path = "/usr/local/bin/microsoft-edgedriver.exe" # Replace with the actual path
# Create a new instance of the Service object
# service = webdriver.Service(webdriver_path)
# Start the service
# service.start()
edge_options = webdriver.EdgeOptions()
# Create a new instance of the Microsoft Edge driver
driver = webdriver.Edge(executable_path=webdriver_path, options=edge_options)
# Maximize the browser window (optional)
driver.maximize_window()
# Navigate to the Microsoft sign-in page
driver.get("https://login.live.com/")
# Wait until the username field is visible
username_field = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.NAME, "loginfmt"))
)
# Enter the username
username_field.send_keys(username)
username_field.send_keys(Keys.RETURN)
# Wait until the password field is visible
password_field = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.NAME, "passwd"))
)
# Enter the password
password_field.send_keys(password)
password_field.send_keys(Keys.RETURN)
# Wait until the search box is visible
search_box = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.NAME, "q"))
)
# Enter the search query
search_box.send_keys("hello")
search_box.send_keys(Keys.RETURN)
# Close the browser
driver.quit()
This is the full error block which I received
WebDriverException Traceback (most recent call last)
<ipython-input-24-4739c578a60b> in <cell line: 30>()
28 # driver = webdriver.Edge(service=service)
29 # driver = webdriver.Edge(service=Service(EdgeDriverManager().install()))
---> 30 driver = webdriver.Edge(executable_path=webdriver_path, options=edge_options)
31
32 # Maximize the browser window (optional)
5 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 0x5586b70e7f93 <unknown>
#1 0x5586b6df48c1 <unknown>
#2 0x5586b6e20cdf <unknown>
#3 0x5586b6e1c1ed <unknown>
#4 0x5586b6e5cea5 <unknown>
#5 0x5586b6e54043 <unknown>
#6 0x5586b6e27941 <unknown>
#7 0x5586b6e28b5e <unknown>
#8 0x5586b70b4536 <unknown>
#9 0x5586b70b8049 <unknown>
#10 0x5586b70b7b39 <unknown>
#11 0x5586b70b8505 <unknown>
#12 0x5586b70bf9db <unknown>
#13 0x5586b70b88ae <unknown>
#14 0x5586b709218c <unknown>
#15 0x5586b70d3d08 <unknown>
#16 0x5586b70d3e44 <unknown>
#17 0x5586b70e1766 <unknown>
#18 0x7fefa654d609 start_thread
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