selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
RuslanBM opened this issue · 3 comments
Hi, thanks for service.
I'am using pytest-selenium to setting up browser start in conftest.py:
from requestium import Session, Keys
import pytest
@pytest.fixture
def selenium(selenium):
selenium.implicitly_wait(10)
selenium.maximize_window()
return selenium
@pytest.fixture
def requestium():
s = Session(webdriver_path='./chromedriver',
browser='chrome',
default_timeout=15,
webdriver_options={'arguments': ['headless']})
return s
https://pytest-selenium.readthedocs.io/en/latest/user_guide.html#specifying-capabilities
And PageObject model to open pages, without setting up driver/paths:
https://selenium-python.readthedocs.io/page-objects.html
Here is my test.py:
title = requestium.get('https://httpbin.org').xpath('//title/text()')
requestium.transfer_session_cookies_to_driver()
requestium.driver.get('http://www.samplesite.com/sample/process')
And starting like:
pytest
with pytest.ini
[pytest]
addopts = --driver Remote
--verbose
--tb short
--selenium-port 4444
--capability browserName chrome
and selenium remote in docker:
services:
hub:
image: selenium/hub:3.141.59-20200409
ports:
- "4444:4444"
chrome_one:
image: selenium/node-chrome-debug:latest
volumes:
- /dev/shm:/dev/shm
- logs:/e2e/tests/logs
- uploads:/e2e/tests/uploads:ro
depends_on:
- hub
environment:
- HUB_HOST=hub
ports:
- 5901:5900
Finally, I got an error, could you please help to resolve it?
№1
E selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
If i change driver here requestium.driver.get('http://www.samplesite.com/sample/process')
to requestium.selenium.get('http://www.samplesite.com/sample/process')
, i catch another error:
№2
requestium.selenium.get('http://www.samplesite.com/sample/process')
E AttributeError: 'Session' object has no attribute 'selenium'
I also tried replace remote hub address in webdriver_path and got error №2:
s = Session(webdriver_path='http://0.0.0.0:4444/wd/hub',
browser='chrome',
default_timeout=15,
webdriver_options={'arguments': ['headless']})
No ideas?
The value of webdriver_path
is passed directly to the Chrome driver. Is the chromedriver
file really at ./chromedriver
relative to the path where you're executing your tests? Is the chromedriver
file executable? Those are the first things I'd check.
Perhaps also provide an absolute path to chromedriver
instead of a relative path?
Closing as stale. Please reopen with more details if the problem persists.