Error message: 'chromedriver' executable needs to be available in the path
You can test if it actually is in the PATH, if you open a cmd and type in chromedriver
(assuming your chromedriver executable is still named like this) and hit Enter. If Starting ChromeDriver 2.15.322448
is appearing, the PATH is set appropriately and there is something else going wrong.
Alternatively you can use a direct path to the chromedriver like this:
driver = webdriver.Chrome('/path/to/chromedriver')
So in your specific case:
driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe")
selenium - chromedriver executable needs to be in PATH
You can download ChromeDriver here:
https://sites.google.com/chromium.org/driver/
Then you have multiple options:
add it to your system
path
put it in the same directory as your python script
specify the location directly via
executable_path
driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')
traceback: Message: 'chromedriver' executable needs to be in PATH
os.environ['PATH'] += self.driver_path
This is not the right way to set the environment variable. Actually webdriver
allows you to specific the path of chromedriver binary, so you don't need to make use of environment variable.
CHROMEDRIVER_PATH = r"C:\Users\Narsil\dev\seleniumDrivers\chromedriver.exe")
class Booking(webdriver.Chrome):
def __init__(self, driver_path=CHROMEDRIVER_PATH):
self.driver_path = driver_path
super(Booking, self).__init__(executable_path=driver_path)
Besides, IMO composition is more suitable than inheritance to build page object in most cases. Here is the sample.
class BasePageObject:
def __init__(self, driver_path):
self.driver = webdriver.Chrome(executable_path=driver_path)
class Booking(BasePageObject):
def land_page(self):
self.driver.get(const.BASE_URL)
Error chromedriver executable needs to be in PATH
In the self.driver = webdriver.Chrome()
, pass the path to the executable as an argument in the parentheses.
For example:
self.driver = webdriver.Chrome('C:/user/Downloads/chromedriver.exe')
Related Topics
How to Change an Image Size in Pygame
Python Beautifulsoup Iframe Document HTML Extract
How Is the Feature Score(/Importance) in the Xgboost Package Calculated
How to Write a Perl, Python, or Ruby Program to Change the Memory of Another Process on Windows
Looking for Recommendation on How to Convert PDF into Structured Format
How to Redirect Stdout to Both File and Console with Scripting
Common Xlabel/Ylabel for Matplotlib Subplots
How to Use a Socks 4/5 Proxy with Urllib2
How Find Specific Data Attribute from HTML Tag in Beautifulsoup4
R, Python: Install Packages on Rpy2
Running Ruby, Node, Python and Docker on the New Apple Silicon Architecture
Does Ruby Have Something Like Python's List Comprehensions
How to Access the Request Object or Any Other Variable in a Form's Clean() Method
How to Put Parameterized SQL Query into Variable and Then Execute in Python