
遇坑过程:
1.

?
?selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
2.之后想着chrome不行,那我就换一个浏览器,换成edge。结果还是那么凑巧,默认下载的就是最新版本的edge。
报错变成SessionNotCreatedException session not created: No matching capabilitie
但是反复输出驱动版本与浏览器版本都是对应上的
microsoft-edge --version msedgedriver --version
这个地方实在是没搞懂
3.后面有幸看到说selenium版本低了,与chromedriver不兼容,才想着去尝试换成更低的版本!!!
Selenium对浏览器支持的版本【2022/02/16更新】 - 碎冰 - 博客园 (cnblogs.com)

?4.中途还遇到(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
使用
from selenium.webdriver import ChromeOptions
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless') #无头模式,ubuntu中不支持图形化(意思就是不打开页面,看不到chrome已经在运行了)
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options,executable_path='/usr/bin/chromedriver')
|