Selenium Webdriver正在打开浏览器,但未打开给定的URL

时间:2020-04-29 11:26:34

标签: python selenium selenium-webdriver webautomation

This is the screenshot of the error I'm getting.

我最近承担了使用selnium webdriver和python学习功能测试和Web自动化的任务。当我执行代码时,将打开Web浏览器,但不会打开URL。我已经尝试了Internet上的所有建议,例如:使用Firefox更新chrome,尝试其他IDE。这些都没有帮助我的代码实现我想要的。

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

chrome = webdriver.Chrome(executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')

chrome.get('https://www.youtube.com/watch?v=oM-yAjUGO-E')

2 个答案:

答案 0 :(得分:0)

对于遇到此问题的任何人,请确保已安装chromedriver(或浏览器可用的任何驱动程序)。对于chrome,您首先需要检查您的信息并从chrome:// version /中查找版本。 然后从https://sites.google.com/a/chromium.org/chromedriver/downloads 下载相应的驱动程序,然后将文件路径复制到execute_path部分。

答案 1 :(得分:0)

确保已安装chromedriver。 安装路径通常为“ / usr / local / bin”,尽管无论该路径如何,它都将用作“ executable_path”

还请记住保留Chrome浏览器和chromedriver版本in sync,即,如果您具有Chrome 81版本,则应安装chromedriver 81版本。

相关问题