Create email account using Selenium in python

in #python-dev6 years ago (edited)

Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. Here is an example of how to use selenium to create an email account using Selenium in python using Google Chrome browser in Windows platform.

Install Selenium

pip install selenium

Download Google Chrome webdriver

Go to this website (https://chromedriver.chromium.org/downloads) and download Google Chrome webdriver

Create email account using selenium

Create and run the following python script.

from selenium import webdriver

# use https://protonmail.com as an example to create email account
url ='https://protonmail.com'

# specify the location of the google Chrome webdriver
driver = webdriver.Chrome('D:/Steem/chromedriver')

EMAIL_NAME = 'michael_ward_20183432'
EMAIL_PASSWORD = 'Test123456Pass'

driver.get(url)
driver.find_element_by_link_text('SIGN UP').click()
driver.implicitly_wait(3)
driver.find_element_by_class_name('panel-heading').click()
driver.implicitly_wait(3)
driver.find_element_by_id('freePlan').click()
driver.implicitly_wait(3)

# switch to the iframe top to write text in textbox
iframe_registration_top = driver.find_element_by_xpath("//iframe[@class='top']")
driver.implicitly_wait(3)
driver.switch_to.frame(iframe_registration_top)
driver.find_element_by_id('username').send_keys(EMAIL_NAME)
driver.implicitly_wait(3)

# switch back to the defaut iframe
driver.switch_to.default_content()
driver.find_element_by_id('password').send_keys(EMAIL_PASSWORD)
driver.implicitly_wait(3)
driver.find_element_by_id('passwordc').send_keys(EMAIL_PASSWORD)
driver.implicitly_wait(3)


# switch to the iframe bottom to click registration buttom
iframe_registration_bottom = driver.find_element_by_xpath("//iframe[@class='bottom']")
driver.implicitly_wait(3)
driver.switch_to.frame(iframe_registration_bottom)
driver.implicitly_wait(3)
driver.find_element_by_name('submitBtn').click()
driver.implicitly_wait(3)

# switch back to the defaut iframe
driver.switch_to.default_content()
driver.find_element_by_id('confirmModalBtn').click()

Sort:  

Nice code! Thanks, I tried, it stop at verification stage. Is there anyway to automate the email verification process?