-1

I'm trying to automate Gmail account login with selenium webdriver, and I need the to check if account signed in successfully and give me the result.

How exactly I can do it?

y = input("input email ID: ")
x = input("input your password: ")            
browser.get('https://accounts.google.com/')
browser.maximize_window()
time.sleep(3)    
User_Id = browser.find_element_by_id("identifierId")
User_Id.send_keys(y)
Next_Button = browser.find_element_by_id('identifierNext').click()
time.sleep(3)
password = browser.find_element_by_name('password')
password.send_keys(x)
time.sleep(2)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
wezzo
  • 49
  • 5
  • Please share your code so we can help you with where you're getting stuck. – Shine J Apr 03 '22 at 01:45
  • 1
    You need to apply to assert after clicking on the login button and you can verify it in multiple ways like you can check the `email` is right through which you logged in or just assert the landing page title etc. – Muhammad Farooq Apr 03 '22 at 06:04
  • @MuhammadFarooq thanks for your comment, but i don't know what to search for with assert, or how to check the email is right. – wezzo Apr 03 '22 at 17:57

1 Answers1

1

An ideal approach to validate if you have signed in successfully within your account will be to verify the visibility of a visible element.

Once you login through Gmail account login you can verify the visibility of the either of the following elements inducing WebDriverWait for the visibility_of_element_located() and you can use either of the following locator strategies:

  • Verifying the Inbox link:

    WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//a[contains(@aria-label, 'Inbox') and contains(., 'Inbox')]")))
    
  • Verifying the Primary tab link:

    WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[text()='Primary']")))
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352