原文寫於 Cmd Markdown
原文連接:https://www.zybuluo.com/CYTand/note/1208879python
在嘗試《Jenkins 建立構建任務》這個項目時遇到一些問題,本文用於記錄解決方法(能夠說是很小白的方法了)。web
問題主要在這一步:C:\Users\wis01>python d:/py_tests.py
chrome
輸出爲:編輯器
[5956:4996:0710/155156.898:ERROR:install_util.cc(589)] Unable to create registry key HKLM\SOFTWARE\Policies\Google\Chro
e for reading result=2
DevTools listening on ws://127.0.0.1:12075/devtools/browser/9ea3a1c2-613a-4752-a3f8-05f619563ff7
E[10772:6808:0710/155209.983:ERROR:install_util.cc(589)] Unable to create registry key HKLM\SOFTWARE\Policies\Google\Ch
ome for reading result=2
DevTools listening on ws://127.0.0.1:12532/devtools/browser/2315ce85-01b3-441c-8a56-d553470e711b
E
======================================================================
ERROR: test_case (__main__.TestClass)
----------------------------------------------------------------------
Traceback (most recent call last):
File "d:/py_tests.py", line 16, in test_case
self.driver.get(self.base_url)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 332, in get
self.execute(Command.GET, {'url': url})
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: missing or invalid 'entry.level'
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x8
_64)
======================================================================
ERROR: test_case2 (__main__.TestClass)
----------------------------------------------------------------------
Traceback (most recent call last):
File "d:/py_tests.py", line 22, in test_case2
self.driver.get(self.base_url)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 332, in get
self.execute(Command.GET, {'url': url})
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: missing or invalid 'entry.level'
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x8
_64)
----------------------------------------------------------------------
Ran 2 tests in 25.587s
FAILED (errors=2)
這裏有兩種錯誤:ui
[5956:4996:0710/155156.898:ERROR:install_util.cc(589)] Unable to create registry key HKLM\SOFTWARE\Policies\Google\Chrome for reading result=2
找不到註冊信息。url
解決方法:spa
1)打開註冊表編輯器.net
a) 快捷鍵win+R b) 輸入:regedit c) 打開regedit.exe
2)找到並按順序展開如下項目:code
-HKEY_LOCAL_MACHINE -SOFTWARE -Policies
3)在Policies下建立Chrome項:orm
a) 選中Policies b) 點擊右鍵 c) 新建 - 項(k) d) 將該項命名爲:Google
4)在Google下建立Chrome項:
a) 選中Google b) 點擊右鍵 c) 新建 - 項(k) d) 將該項命名爲:Chrome
5)在Chrome下新建MachineLevelUserCloudPolicyEnrollmentToken字串:
a) 選中Chrome b) 點擊右鍵 c) 新建 - 字符串值(s) d) 將該字符串命名爲:MachineLevelUserCloudPolicyEnrollmentToken
6)若本來已有Google、Chrome項,則直接在下面添加第五步中的字符串值便可。
WebDriverException: Message: unknown error: cannot determine loading status
from unknown error: missing or invalid 'entry.level'
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x8
_64)
webdriver與Chrome二者版本不匹配(通常來講,二者均保持最新便可)。
解決方法:
1)更新Chrome
2)更新webdriver
參考如下連接提供的webdriver下載地址:
http://www.testclass.net/selenium_python/selenium3-browser-driver/
3)必定要替換原來的webdriver,若忘記了原來的位置,能夠到環境變量配置中看一下
以上。