나는 넷플 릭스 웹 사이트에 자동 로그인 스크립트를 만들려고 해요 : https://www.netflix.com/it/셀레늄 : 요소도 현재는 가시 때문에 상호 작용되지 않을 수 있습니다
코드입니다 :
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
while True:
driver.get("https://www.netflix.com/it/")
login = driver.find_element_by_css_selector(".authLinks.signupBasicHeader")
login.click()
element = driver.find_element_by_name("email")
element.send_keys("[email protected]")
submit = driver.find_element_by_css_selector(".btn.login-button.btn-submit.btn-small")
submit.click()
element2 = driver.find_element_by_name("password")
element2.send_keys("test1")
submit.click()
를하지만 가끔은 작동 때로는 그렇지 않습니다 그것은이 예외가 발생합니다 :
Traceback (most recent call last):
File "netflix.py", line 35, in <module>
submit.click()
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 72, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
return self._parent.execute(command, params)
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/home/user/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
Stacktrace:
at fxdriver.preconditions.visible (file:///tmp/tmp7otgskq8/extensions/[email protected]/components/command-processor.js:10092)
at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmp7otgskq8/extensions/[email protected]/components/command-processor.js:12644)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmp7otgskq8/extensions/[email protected]/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmp7otgskq8/extensions/[email protected]/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///tmp/tmp7otgskq8/extensions/[email protected]/components/command-processor.js:12608)
예외는 웹 페이지의 일부가 그 부분은 페이지 실제로 사용의 경우에도 (눈에 보이지 않는 것을 말한다을 y) ... 그것은 일종의 버그입니다. 어떻게 이것을 무시할 수 있습니까?
요소를 표시하기 위해 드라이버에 시간을주기 위해 url을 연 후'wait'을 추가하십시오. – Flint
time.sleep을 추가했지만 작동하지 않습니다 ... – CatchJoul