Not Able to open Edge browser directly after adding the edge driver to the system variables | Selenium Python Forum
A
Anand komiripalem Posted on 09/10/2020

After adding the edge driver to system variables. if i'm trying to launch the edge browser it is giving the following error. but the same is working fine if i give the path in driver object. can any one suggest what i should do to directly open the edge browser.

 

 

 

Traceback (most recent call last):
File "C:\Users\Devdas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Devdas\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Devdas\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Devdas\eclipse-workspace\demo\basic.py", line 4, in <module>
driver = webdriver.Edge()
File "C:\Users\Devdas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 56, in __init__
self.edge_service.start()
File "C:\Users\Devdas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'MicrosoftWebDriver.exe' executable needs to be in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687

 


0
09914040666 Replied on 09/10/2020

Hey, 

The error clearly shows what the issue is "FileNotFoundError: [WinError 2] The system cannot find the file specified". After adding the driver into system variable, system needs to be restarted for the changes to be applied. 

The way is to restart the system after adding driver to system variables and after restart try running your script.


A
Anand komiripalem Replied on 10/10/2020

Hi Jaspreet, 

 

I have done restart after adding the system variables. it is working fine with the firefox and chrome, but with edge i'm the facing the same error every time i try to access the browser through the program. 


0
09914040666 Replied on 10/10/2020

Hey, 

Kindly attach the code so that i can check.


A
Anand komiripalem Replied on 10/10/2020

in the below program if im removing the path of edge, it is giving me the error.

 

from selenium import webdriver

browsername = input("Enter the Browser to Execute the code: ")

browser = browsername.lower()

if browser == 'chrome':
       driver = webdriver.Chrome()

elif browser == 'firefox':
       driver = webdriver.Firefox()

elif browser == 'edge':
       path = "C:\\edgedriver\\msedgedriver.exe"
       driver = webdriver.Edge(executable_path=path)
else:
      print("browser not supported")

try:
   if browser != None:
   driver.get("https://flipkart.com")
   driver.quit()
except:
   print("Sorry cannot go further")


0
09914040666 Replied on 10/10/2020

Hey, 

If driver of Edge is named with this "msedgedriver.exe", then please rename it to "MicrosoftWebDriver.exe" and then try to run without passing the path in arguments.


Related Posts