python-selenium.common.exceptions.WebDriverException: Message: Unknown error - python

I'm up with python 3.8 and selenium but recently I downloaded the latest edge web driver zip file and runned the mswdedriver.exe from that and typed this code in my ide:
from selenium import webdriver
browser = webdriver.Edge('‪F:\za\python\Assistant\msedgedriver.exe')
browser.maximize_window()
browser.get(url='http://seleniumhq.org/')
but I see this error:
selenium.common.exceptions.WebDriverException: Message: 'MicrosoftEdgeDriver' executable needs to be
in PATH. Please download from http://go.microsoft.com/fwlink/?LinkId=619687
Can you help me friends?
Thanks in advance.

You need to give a path to the webdriver executable when you load a webdriver, or have it stored as an environment variable:
webdriver.Edge(executable_path="path/to/executable")
A web driver is essentially a special browser application, you must install that application before you can run anything with it.
Here's Edge's web driver download page. Or you can use the link from the error message http://go.microsoft.com/fwlink/?LinkId=619687
Here's a similar question Python Selenium Chrome Webdriver

The backslashes in the executable path need to be escaped, per Python syntax:
browser = webdriver.Edge('‪F:\\za\\python\\Assistant\\msedgedriver.exe')

This problem appears to me
you must put in "Bin Folder" the file "MicrosoftWebDriver.exe" as is , edit the previous name of edge webdriver to be "MicrosoftWebDriver.exe" and put it in the "Bin Folder"

You need to download the browser driver from here
After the download completes, extract the driver executable to your preferred location. Add the folder where the executable is located to your PATH environment variable.

Related

How to solve Selenium WebDriver Error using Python?

I am learning Python to tried to do an extraction of data from another website. However, I wrote a simple code to try to open a Chrome browser window and display google on my web browser.
I have seen in other videos that it is only needed to write the following code to get this to work:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.google.com")
However, when I try to run it on my PyCharm, I got plenty of error lines. The same happen if I try to run it through my command prompt (both stating the same error - pictures below). I do not know what I am missing, but I should mention that I have downloaded the packages pip, selenium, selenium-chromedriver and I have also downloaded ChromeDriver separetely from the website https://chromedriver.chromium.org/
Could anyone please guide me through this issue? Thanks a lot everyone for your precious help and your time!
Kind regards,
Salvador
ChromeDriver_executable_location
Command_prompt
Python_codeError1
Python_codeError2
Packages_installed
Please post the errors so we can see what it is tell you is wrong.
I am also new to selenium and learning python.
First, make sure your Chromedriver is located in the same folder as your script.
Second, make sure your version of Chrome and Chromedriver are compatible.
Also, when the script is finish it will close the browser immediately.
I ran your posted code and it works for me. Did you have any errors when installing the packages?
I'm not sure why you get an error, but I know a workaround that might work for you.
Instead of using the webdriver file, you can use a service to install it for you, like this:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
You need to install the webdriver_manager library first using pip
Hope this helps
You could place the Chromedriver in system path and try to execute.
Go to Advanced System Settings.
Click on Environment variables.
Select Path variable and click on Edit.
Add the Chromedriver folder path.
Suppose the path for chromedriver.exe file is - C:/project/Chromedriver/chromedriver.exe, place C:/project/Chromedriver in the Path variable.
Restart the computer and then try to execute below lines:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.google.com")

For Python, why does Selenium not read Geckodriver yet read Chromedriver?

So basically, I added geckodriver.exe to the environment variables Path on Windows 10, yet trying
from selenium import webdriver
driver=webdriver.Firefox()
still resulted in the error message that "Geckodriver" executables need to be installed on Path
Now, I installed Chrome and the chromedriver.exe file off the web and ran chromedriver on Selenium just fine
from selenium import webdriver
browser=webdriver.Chrome(r'c:\chromedriver\chromedriver.exe')
This works and Google Chrome is open, so now I try to add the path in Firefox and when the path suggestions are showing up, selenium doesn't even recognize the geckodriver.exe exists, and pathlib does recognize the Path('c:/geckodriver/geckodriver.exe').exists()==True.
browser=webdriver.Firefox(r'c:\geckodriver\geckodriver.exe')
NotADirectoryError
So selenium is saying that the .exe file that clearly exists does not exist. How do I solve this problem?
For FireFox webdriver you'll need to set the path like this:
browser=webdriver.Firefox(executable_path=r'c:\geckodriver\geckodriver.exe')

Selenium - Chromedriver filenotfound error message

I am trying to use selenium to test a webpage I am building.
I downloaded chrome driver and placed the executable in the path below.
I know the path is correct.
driver = webdriver.Chrome(executable_path=r'C:\Python\chromedriver.exe')
What can I do to address this or what am I missing?
Try calling the file without the ".exe" extension.
I use chromedriver but I never need to call the extension.
driver = webdriver.Chrome('C:\Python\chromedriver')

why wont selenium module work properly for me

I installed the selenium module with pip installer. Then I tried to make the code to open firefox, then open a new tab to go to google.
Code:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com")
The expected result should have opened firefox and then go to google.com.
But what actually happened was the program didn't produce any error, it just didn't open firefox, and the screen wasn't frozen either.
Download a matching version of Geckodriver and unpack the geckodriver.exe to the location where current user can execute programs from (normally it's any place inside your home folder)
Amend your code to include the location of the aforementioned geckodriver like:
driver = webdriver.Firefox(executable_path="/path/to/the/geckodriver/binary")
If this doesn't help - provide the path to the Firefox executable as well:
driver = webdriver.Firefox(executable_path="/path/to/the/geckodriver/binary", firefox_binary="/path/to/firefox/binary")
Instead of steps 2 and 3 you can add both firefox and geckodriver to your OS PATH
References:
Selenium with Python - Getting Started
Selenium With Python
Selenium using Python - Geckodriver executable needs to be in PATH

Selenium is not accessing drivers properly

I am trying to access a browser using Selenium.
My first Python code try is this:
from selenium import webdriver
browser = webdriver.Chrome()
It gives me the error message:
'chromedriver' executable needs to be in PATH.
Some other answers on here suggest I point to the path manually. So I try:
from selenium import webdriver
chromedriver_loc = '/usr/local/bin'
driver = webdriver.Chrome(executable_path=chromedriver_loc)
This gives me the error message:
'bin' executable may have wrong permissions.
I am using a Mac and running an Anaconda Spyder environment.
The chromedriver file is in the /usr/local/bin. When I use GetInfo from the Finder program, the 'locked' selection is unchecked, but grayed out so I can't check or uncheck it.
The same error messages appear if I substitute Firefox for Chrome.
Can anybody help me provide the right 'permissions' so I can properly use Selenium? Please let me know if you need additional information, as this is my first question on here.
You should use the full path including the filename:
chromedriver_loc = '/usr/local/bin/chromedriver'

Categories