简体   繁体   English

尝试使用 Selenium(Python)登录 Proton 邮件时出现“ElementNotInteractableException”和“NoSuchElementException”

[英]"ElementNotInteractableException" and "NoSuchElementException" while trying to login in to Proton mail using Selenium(Python)

I am tryin to automate the process of creating a proton mail account.我正在尝试自动化创建质子邮件帐户的过程。 My python code runs fine until I reach the point where it has to enter the username in the sign up process.我的 python 代码运行良好,直到我到达必须在注册过程中输入用户名的地步。 Here is a photo of the html code of the site - photo of Proton sign up page and it's html code , the site allows me to type password with selenium but its not allowing me to enter the username.这是该站点的 html 代码的照片 - Proton 注册页面的照片,它是 html 代码,该站点允许我使用 Z8E00596AD8DE2213FF8F8D8478D5362C 输入密码,但不允许我输入用户名I have tried selecting the input tag and its parent div.我尝试选择输入标签及其父 div。

The below code is for selecting the input tag.下面的代码用于选择输入标签。

   pmail_user_data = generator.generate_protonmail_user_data()
   driver.set_page_load_timeout(20)
   username_input = driver.find_element(By.XPATH, "//*[@id='username']")
   username_input.click()
   time.sleep(0.5)
   username_input.send_keys(pmail_user_data[2])

With this code I end up with:-有了这段代码,我最终得到:-

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

And the code below is when is selected the parent div.下面的代码是何时选择父 div。

   pmail_user_data = generator.generate_protonmail_user_data()
   driver.set_page_load_timeout(20)
   username_input = driver.find_element(By.XPATH, "/html/body/div[1]/label/div[2]/div/div[1]")
   username_input.click()
   time.sleep(0.5)
   username_input.send_keys(pmail_user_data[2])

With this I end up with:-有了这个,我最终得到: -

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[1]/label/div[2]/div/div[1]"}

I have tried various methods like ActionChains, WebDriverWait, driver.implicitly_wait().我尝试过各种方法,例如 ActionChains、WebDriverWait、driver.implicitly_wait()。 But nothing seems to work for me.但似乎没有什么对我有用。 Any answer is much appreciated, Thank you in advance.任何答案都非常感谢,在此先感谢您。

To send a character sequence to the Email field within Protonmail you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies :要将字符序列发送到Protonmail中的Email字段,您需要为element_to_be_clickable()引入WebDriverWait并且您可以使用以下任一定位器策略

  • Using CSS_SELECTOR :使用CSS_SELECTOR

     driver.get("https://account.protonmail.com/login") WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#username"))).send_keys("KAMI@D.KAI")
  • Using XPATH :使用XPATH

     driver.get("https://account.protonmail.com/login") WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='username']"))).send_keys("KAMI@D.KAI")
  • Note : You have to add the following imports:注意:您必须添加以下导入:

     from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
  • Browser Snapshot:浏览器快照:

图片

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ElementNotInteractableException 在 python 中使用 selenium - ElementNotInteractableException using selenium in python 使用 python 的 selenium 中的 ElementNotInteractableException - ElementNotInteractableException in selenium using python ElementNotInteractableException 使用 Selenium Python - ElementNotInteractableException using Selenium Python ElementNotInteractableException:消息:尝试使用Selenium和Python单击元素时,元素无法滚动到视图中 - ElementNotInteractableException: Message: Element could not be scrolled into view while trying to click an element using Selenium and Python ElementNotInteractableException:尝试使用 Selenium 和 Python 在 www.finanzen.net 上搜索股票时出现元素不可交互错误 - ElementNotInteractableException: element not interactable error while trying to search for stock on www.finanzen.net using Selenium and Python NoSuchElementException:消息:尝试使用 Selenium 和 Python 定位元素时无法定位元素 - NoSuchElementException: Message: Unable to locate element while trying to locate an element using Selenium and Python selenium.common.exceptions.ElementNotInteractableException:消息:使用Selenium和Python插入值时元素不可交互 - selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable while inserting value using Selenium and Python selenium.common.exceptions.ElementNotInteractableException:消息:使用 Selenium 和 Python 与元素交互时元素不可交互 - selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable while interacting with element using Selenium and Python 硒 Python:'ElementNotInteractableException' - Selenium Python: 'ElementNotInteractableException' 使用 selenium 和 python3.8 加入 whatsapp 组时出现 NoSuchElementException - NoSuchElementException while joining whatsapp group using selenium and python3.8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM