我目前正在使用selenuim进行一些网页报废,我的脚本在Windows 10上的chrome v60.0.3112.90上运行正常但我在无头模式下运行时出错:
Traceback (most recent call last):
File "C:\Users\T460\Desktop\reboot.py", line 13, in <module>
UsernameField = browser.find_element_by_id('input_URN')
File "C:\Users\T460\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 330, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Users\T460\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 832, in find_element
'value': value})['value']
File "C:\Users\T460\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Users\T460\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"input_URN"}
(Session info: headless chrome=60.0.3112.90)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.15063 x86_64)