1

So im trying to get my first ProtonMail Account Generator working. My Problem is that selenium wont find either the field for the recovery mail or the Create Account button. I switched to the iframe already. Im pretty new and thought that this problem might be caused by the "new" html document which contains the bottom part (starting with the recovery email). Hope someone can help me. Screenshot

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()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
manu102
  • 13
  • 2
  • You actually have two iframes you need to switch to instead of just one they both have //iframe[@title='Registration form'] but they differ by one index or class = top or bottom. – Arundeep Chohan Aug 14 '20 at 23:17
  • driver.switchTo().frame(0); and driver.switchTo().frame(1); I think should be enough to switch to the frames. – Arundeep Chohan Aug 14 '20 at 23:31
  • You need to get in the habit of [accepting answers](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) which help you to solve your issues. You'll earn points and others will be encouraged to help you. – Jay Blanchard Aug 17 '20 at 14:57
  • Yea but what actually helped me was the comment by arundeep chohan but I can't accept it or handle it like an answer? – manu102 Aug 17 '20 at 23:57

1 Answers1

1

The Recovery email field is within an <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use either of the following Locator Strategies:

  • Using 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")
    
  • 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:

recovery


Reference

You can find a couple of related discussions in:


Outro

A couple of useful discussions:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352