D:\学习\Python工程\venv\Scripts\python.exe “D:\软件\PyCharm Community Edition
2019.1.3\plugins\python-ce\helpers\pydev\pydevd.py” --multiproc
--qt-support=auto --client 127.0.0.1 --port 52230 --file
D:/学习/Python工程/UI_AUTO/esd_login.py
pydev debugger: process 91620 is connecting
Connected to pydev debugger (build 201.7846.77)
切换到了右侧frame
CDwindow-B3FC117941CC01FC680B60DE024FF9A7
Traceback (most recent call last):
File “D:\软件\PyCharm Community Edition
2019.1.3\plugins\python-ce\helpers\pydev\pydevd.py”, line 1438, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File “D:\软件\PyCharm Community Edition
2019.1.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py”, line
18, in execfile
exec(compile(contents+"\n", file, ‘exec’), glob, loc)
File “D:/学习/Python工程/UI_AUTO/esd_login.py”, line 79, in
el=driver.find_element_by_xpath(’//*[@id=“ContentPlaceHolder_lblWebAddress”]’)
File
“D:\学习\Python工程\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”,
line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File
“D:\学习\Python工程\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”,
line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File
“D:\学习\Python工程\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”,
line 321, in execute
self.error_handler.check_response(response)
File
“D:\学习\Python工程\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py”,
line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: no such window
(Session info: chrome=83.0.4103.116)
web自动化,遇到定位,就打开黑框的谷歌,然后就报错,找不到原因。
太迷惑了,在定位元素操作前加sleep,就不会再打开谷歌页面,也可以定位到元素。