python无法打开谷歌浏览器?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python无法打开谷歌浏览器?相关的知识,希望对你有一定的参考价值。
代码class Run_case:
def run_case(self):
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://www.baidu.com')
driver.find_element_by_id('kw').send_keys('袁隆平')
driver.find_element_by_id('su').click()
sleep(2)
driver.quit()
if __name__ == '__main__':
a = Run_case()
a.run_case()
报错
D:\my_project\venv\Scripts\python.exe D:/my_project/dcs60/lesson02.py
Traceback (most recent call last):
File "D:/my_project/dcs60/lesson02.py", line 17, in <module>
a.run_case()
File "D:/my_project/dcs60/lesson02.py", line 7, in run_case
driver = webdriver.Chrome()
File "D:\my_project\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "D:\my_project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "D:\my_project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\my_project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\my_project\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': "auxData":"frameId":"5093DB5F5802F38169ACE366DBA5C7FB","isDefault":true,"type":"default","id":1,"name":"","origin":"://","uniqueId":"1899763173666603839.6259080565478825072"
(Session info: chrome=90.0.4430.212)
(Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)
Process finished with exit code 1
你可以通过driver = webdriver.Chrome(executable_path=d'你的driver.exe.路径')
设置
以上是关于python无法打开谷歌浏览器?的主要内容,如果未能解决你的问题,请参考以下文章
谷歌浏览器打开以后老显示无法正确打开您的配置文件,怎么解决?