我想登录网站,并且正在使用python进行登录,问题之一是我只能在IE而不是chrome或任何其他浏览器上打开它。我正在使用以下代码,在下面添加了不包括凭据和Web链接的部分
dirname = os.path.dirname(__file__)
chromedriver = os.path.join(dirname, 'D:\Python\Driver\IEDriverServer.exe')
if __name__ == "__main__":
driver = webdriver.Ie(executable_path=chromedriver, capabilities={'ignoreZoomSetting':True})
driver.get(webpageAddress)
time.sleep(10)
element = driver.find_element_by_id("usuario")
浏览器打开并正确导航到页面,但是在此driver.find_element_by_id(“ usuario”)步骤下,我看到以下错误
File "<ipython-input-75-470f4dc56898>", line 1, in <module>
File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "D:\anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Desktop/Telefonica_Crawler/TelefonicaCrawler/Main.py", line 34, in <module>
element = driver.find_element_by_id("usuario")
File "D:\anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "D:\anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\anaconda\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchWindowException: Currently focused window has been closed.
有人可以帮我解决错误,HTML代码中确实存在ID
这不是重复的问题