After I install selenium, chrome, and chromedriver to aws cloud9, I tried to execute chromedriver. But PATH error occurred.
I checked chromedriver path is correct. And I don't know why this error happened.
aws:~/environment/seleniumTest $ ll /home/ec2-user/environment/seleniumTest/chromedriver
-rwxr-xr-x 1 ec2-user ec2-user 8496784 Sep 13 2018 /home/ec2-user/environment/seleniumTest/chromedriver
Are there any solutions to solve this problem?
My steps is as below,
1.install selenium pip install selenium -t ./
2.install chrome curl https://intoli.com/install-google-chrome.sh | bash
3.download chromedriver curl -SL https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip > chromedriver.zip unzip chromedriver.zip
4.Execute Python code as below
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def lambda_handler(event, context):
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome('/home/ec2-use/environment/seleniumTest/chromedriver', chrome_options=options)
return(0)
I got "'chromedriver' executable needs to be in PATH" error.
Response
{
"errorMessage": "Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home\n",
"errorType": "WebDriverException",
"stackTrace": [
[
"/var/task/seleniumTest/lambda_function.py",
9,
"lambda_handler",
"driver = webdriver.Chrome('/home/ec2-use/environment/seleniumTest/chromedriver', chrome_options=options)"
],
[
"/var/task/selenium/webdriver/chrome/webdriver.py",
73,
"__init__",
"self.service.start()"
],
[
"/var/task/selenium/webdriver/common/service.py",
83,
"start",
"os.path.basename(self.path), self.start_error_message)"
]
]
}
Function Logs
Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
: WebDriverException
Traceback (most recent call last):
File "/var/task/seleniumTest/lambda_function.py", line 9, in lambda_handler
driver = webdriver.Chrome('/home/ec2-use/environment/seleniumTest/chromedriver', chrome_options=options)
File "/var/task/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/var/task/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
I'm not sure you're specifying the executable_path for Chromedriver properly, I think the below should work:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def lambda_handler(event, context):
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(executable_path='/home/ec2-user/environment/seleniumTest/chromedriver', chrome_options=options)
return(0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.