title: Automating email creation on ProtonMail using (Python, Selenium)
body: <p>I want to create 10 emails on ProtonMail.</p>
  
  <p>I already automated half of the part, using <code>PyAutoGui</code> and <code>Selenium</code> but I want to make it like a checker because sometimes usernames are taken.
  Now what I wanna do is this:</p>
  
  <ul>
  <li>Generate Random Usernames</li>
  <li>Check the usernames <code>either by Selenium or another package(suggestions if you know any)</code></li>
  <li>If the username is valid, a notepad will be created to save the valid usernames.</li>
  </ul>
  
  <p>This is the concept of what I am trying to build now. I am truly sorry if I sound garbage but I legit started using Python a few days ago and it hasn't yet been a week so... I'm learning :P</p>
  
  <p>I have automated the part where Selenium fills the form of ProtonMail for Sign In / Sign Up, but sometimes I get the error that the Username is already taken and I want the script to check if that error message pops up, and if it does, a "reserved code" line will be executed to fix the issue. Then, the code can continue. But, I want the script not to interfere with the "reserved code" if the element doesn't pop up.</p>
  
  <p>If anyone is here just to get the code ready, here you go:</p>
  
  <pre><code>import selenium
  import pyautogui
  import time
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  
  #Variables
  protonmail = "https://mail.protonmail.com/create/new?language=en"
  
  username = input("Please enter your desired username for the email:")
  password = input("Enter your password:")
  
  driver = webdriver.Firefox()
  time.sleep(4)
  driver.get(protonmail)
  time.sleep(7)
  
  pyautogui.click(535, 501)
  time.sleep(1)
  pyautogui.typewrite(username)
  time.sleep(2)
  driver.find_element_by_xpath(
      "/html[1]/body[1]/div[2]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[2]/div[1]/div[1]/input[1]").send_keys(
      password)
  time.sleep(2)
  driver.find_element_by_xpath(
      "/html[1]/body[1]/div[2]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[2]/div[2]/div[1]/input[1]").send_keys(
      password)
  time.sleep(2)
  pyautogui.click(1284, 916)
  time.sleep(2)
  pyautogui.click(655, 762)
  time.sleep(3)
  </code></pre>