Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用Selenium登录网站?_Python_Selenium - Fatal编程技术网

Python 如何使用Selenium登录网站?

Python 如何使用Selenium登录网站?,python,selenium,Python,Selenium,通过使用定位器上方的字符串可以找到按钮,但是当我运行脚本时,我遇到了这个错误 self.driver.find_element_by_id("signinSubmit").click() selenium.common.exceptions.elementnotinteractiableexception:Message:Element无法滚动到视图中 我该如何解决这个问题?可能是以下限制您单击按钮的原因 可能是元素必须在iframe中 可能是您正在使用的xpath不是唯一的 在单击元素之前

通过使用定位器上方的字符串可以找到按钮,但是当我运行脚本时,我遇到了这个错误

self.driver.find_element_by_id("signinSubmit").click()
selenium.common.exceptions.elementnotinteractiableexception:Message:Element无法滚动到视图中

我该如何解决这个问题?

可能是以下限制您单击按钮的原因

  • 可能是元素必须在iframe中
  • 可能是您正在使用的xpath不是唯一的
  • 在单击元素之前放置一些等待

  • 可能是以下限制您点击按钮的原因

  • 可能是元素必须在iframe中
  • 可能是您正在使用的xpath不是唯一的
  • 在单击元素之前放置一些等待

  • 这是一个登录twitter的示例,不同之处在于我通过按ENTER按钮而不是单击SUBMIT来登录

    selenium.common.exceptions.ElementNotInteractableException: Message: Element <div id="signinSubmit" class="orangeButton buttonBase js-loginSubmitModal"> could not be scrolled into view
    

    这是一个登录twitter的示例,不同之处在于我通过按ENTER按钮而不是单击SUBMIT来登录

    selenium.common.exceptions.ElementNotInteractableException: Message: Element <div id="signinSubmit" class="orangeButton buttonBase js-loginSubmitModal"> could not be scrolled into view
    
    尝试使用:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    
    driver = webdriver.Chrome()
    
    driver.get('https://twitter.com/login')
    
    email = driver.find_element(By.NAME, 'email')
    email.clear()
    email.send_keys(EMAIL)
    password = driver.find_element(By.NAME, 'pass')
    password.clear()
    password.send_keys(PASSWORD)
    
    password.send_keys(Keys.RETURN) # Login with ENTER button
    
    如果它不工作,可能是因为它禁用了此类
    create\u account\u按钮
    你能手动使用吗?试着使用:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    
    driver = webdriver.Chrome()
    
    driver.get('https://twitter.com/login')
    
    email = driver.find_element(By.NAME, 'email')
    email.clear()
    email.send_keys(EMAIL)
    password = driver.find_element(By.NAME, 'pass')
    password.clear()
    password.send_keys(PASSWORD)
    
    password.send_keys(Keys.RETURN) # Login with ENTER button
    
    如果它不工作,可能是因为它禁用了此类
    create\u account\u按钮

    你能手动使用它吗?

    self.driver。通过id(“密码”)查找元素。发送密钥(密码,密钥。返回)本身似乎不起作用。driver.find\u element\u by_id(“密码”)。发送密钥(密码,密钥。返回)似乎也不起作用。我可以手动操作,但这有点违背了目的,因为我将来肯定会遇到其他问题。这也不起作用。我可以手动操作,但这有点违背了我的目的,因为我将来肯定会遇到其他问题。这个页面的url是什么?我需要更多信息才能提供帮助这个页面的url是什么?我需要更多信息才能提供帮助