首页 > 解决方案 > Google App Engine 上的 Selenium webdriver chrome

问题描述

我可以找到很多类似的主题,但没有一个有帮助......我已经在 GAE 上成功安装了 chromedriver,但我不断得到以下内容。

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
start (/env/lib/python3.7/site-packages/selenium/webdriver/common/service.py:83)

我的python代码。

try:
    if 'linux' in sys.platform:
        print("Headless Chrome Initialized on Linux")
        return webdriver.Chrome()
except WebDriverException as e:
    print(getattr(e, 'message', repr(e)))
    print(getattr(e, 'message', str(e)))

我可以从服务器的命令行启动 chromedriver ...

Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

还尝试使用可执行路径 /usr/bin/chromedriver 但结果相同...

webdriver.Chrome(executable_path='/usr/bin/chromedriver')

标签: pythonseleniumgoogle-app-enginegoogle-cloud-platformselenium-chromedriver

解决方案


推荐阅读