我试图在MacOS上通过PyCharm CE运行Selenium,并尝试使用Google Chrome运行它
但是,每当我运行以下命令时:
from selenium import webdriver
browser = webdriver.Chrome("/Users/louiscage/PycharmProjects/SeleniumPractice/chromedriver")
browser.get('https://inventwithpython.com')
结果是:
/Users/louiscage/PycharmProjects/SeleniumPractice/SeleniumPractice.py:3: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
browser = webdriver.Chrome("/Users/louiscage/PycharmProjects/SeleniumPractice/chromedriver")
我已经下载了Mac64的Chromedriver和Geckodriver,并将其放置在PyCharm项目的适当目录中。但我似乎仍然找不到解决这个问题的办法。任何帮助都将不胜感激
这个弃用问题出现在Selenium、Pip和Python更新中。为此,您只需执行以下操作:
使用以下代码
正如警告所说:
please pass in a Service object
,因此您应该这样做:在chrome
Service
类上传递可执行路径,并将其放在可变服务上。然后将其传递给webdriver chrome此处的链接引用:Selenium Chrome webdriver service
相关问题 更多 >
编程相关推荐