Maison  >  Questions et réponses  >  le corps du texte

python - 为什么不能使用click()、clear()、send_keys()?

先放网址https://passport.58.com

我能通过xpath定位到网页元素(用户名)

↑无报错

却不能使用click()、clear()、send_keys()

↑报错:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/untitled/t.py", line 13, in <module>

browser.find_element_by_xpath("//input[@id='usernameUser']").click()

File "C:UsersAdministratorAppDataRoamingPythonPython35site-packagesseleniumwebdriverremotewebelement.py", line 77, in click

self._execute(Command.CLICK_ELEMENT)

File "C:UsersAdministratorAppDataRoamingPythonPython35site-packagesseleniumwebdriverremotewebelement.py", line 494, in _execute

return self._parent.execute(command, params)

File "C:UsersAdministratorAppDataRoamingPythonPython35site-packagesseleniumwebdriverremotewebdriver.py", line 236, in execute

self.error_handler.check_response(response)

File "C:UsersAdministratorAppDataRoamingPythonPython35site-packagesseleniumwebdriverremoteerrorhandler.py", line 192, in check_response

raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.ElementNotVisibleException:太多了,略

Screenshot: available via screen

我怀疑是这个网站做的保护措施,希望大家能帮我看看0.0

ringa_leeringa_lee2716 Il y a quelques jours805

répondre à tous(2)je répondrai

  • 阿神

    阿神2017-04-18 10:17:33

    #我实际测试了下,因为usernameUser 这个id 是hidden的
    from selenium.webdriver.common.keys import Keys
    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get('https://passport.58.com/')
    driver.find_element_by_xpath("//p[@class='pwdlogin']").click()#先点击密码登录才会有usernameUser这个id元素
    driver.find_element_by_xpath("//input[@id='usernameUser']").click()#ok

    répondre
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:17:33

    Ce n'est pas qu'il ne peut pas être utilisé, mais lorsque vous entrez pour la première fois sur cette page, vous devez scanner le code QR pour vous connecter. Vous devez d'abord sauter, puis la boîte de mot de passe est en fait cachée et vous devez exécuter un morceau de JS pour l'afficher.

    répondre
    0
  • Annulerrépondre