![](/img/trans.png)
[英]How to click on the Create Account button within https://mail.protonmail.com/ signup page using Selenium and Python
[英]How to send text to the recovery mail field of https://mail.protonmail.com/create/new?language=en using Selenium and Python
所以我試圖讓我的第一個 ProtonMail 帳戶生成器工作。 我的問題是 selenium 找不到恢復郵件的字段或“創建帳戶”按鈕。 我已經切換到 iframe。 我很新,並認為這個問題可能是由包含底部部分(從恢復電子郵件開始)的“新”html 文檔引起的。 希望可以有人幫幫我。 截屏
from selenium import webdriver
import time
url = 'https://mail.protonmail.com/create/new?language=en'
driver = webdriver.Chrome('D:/Downloads/chromedriver')
driver.get(url)
time.sleep(2)
driver.switch_to.frame(driver.find_element_by_xpath("//iframe[@title='Registration form']"))
driver.find_element_by_id('username').send_keys('hallo')
time.sleep(1)
driver.switch_to.default_content()
driver.find_element_by_id('password').send_keys('password')
driver.find_element_by_id('passwordc').send_keys('password')
time.sleep(1)
driver.switch_to.frame(driver.find_element_by_xpath("//iframe[@title='Registration form']"))
driver.find_element_by_id('notificationEmail').send_keys('test')
driver.find_element_by_name('submitBtn').click()
Recovery email字段位於<iframe>
中,因此您必須:
誘導WebDriverWait使所需的幀可用並切換到它。
誘導WebDriverWait使所需元素成為可點擊的。
您可以使用以下任一定位器策略:
使用XPATH
:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//label[@for='notificationEmail']//following::div[@class='signupIframe-iframe']/iframe[@title='Registration form']"))) WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='notificationEmail']"))).send_keys("manu102")
注意:您必須添加以下導入:
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
瀏覽器快照:
您可以在以下位置找到一些相關的討論:
幾個有用的討論:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.