# coding = utf-8
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
print (driver.title) # 把頁面title 打印出來
driver.quit()
運行上續代碼報錯:
Traceback (most recent call last):
File "D:/aasoftcfl/python/cflproject/projectcfl22chrome.py", line 5, in <module>
driver = webdriver.Chrome()
File "D:\aasoftcfl\python\lib\site-packages\selenium-3.11.0-py3.6.egg\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "D:\aasoftcfl\python\lib\site-packages\selenium-3.11.0-py3.6.egg\selenium\webdriver\remote\webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\aasoftcfl\python\lib\site-packages\selenium-3.11.0-py3.6.egg\selenium\webdriver\remote\webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\aasoftcfl\python\lib\site-packages\selenium-3.11.0-py3.6.egg\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "D:\aasoftcfl\python\lib\site-packages\selenium-3.11.0-py3.6.egg\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: Chrome version must be >= 63.0.3239.0
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64)
查看瀏覽器版本58.****,所以升級瀏覽器解決了問題;
解決方法:升級Chrome瀏覽器
