How to set an app password and verify the email of the logged in users into an application? – Devstringx

Back to Blog

How to set an app password and verify the email of the logged in users into an application? – Devstringx

Do you know how to generate the app password and verify the email for required actions like user log-in, file downloads, etc?
If not, then this blog will help you to learn that.

How to automate a test case where 2 – factor authentication is enabled?

Less Secure App access setting is no longer available so now if you want to integrate Selenium with your Gmail account, then you need to create an app password first.

App Password: It can be used for accounts in which 2-steps verification is turned on.

Steps to turn on App Password:

  • Open your Google account
  • Click on Manage your Google Account and select security
  • Under “Signing in to Google,” select App Passwords
  • Sign in, to your account
  • Select the app and device and click on Generate button as shown in the below image

Dashboard to change App password

  • The App Password appears in the yellow bar on your device as shown below:

App password for Windows Computer

Recommended to Read:- Read PDF File Using Python in Robot Framework

Code to Verify the user is getting an email notification for the user logged in to the system

In this example, I have logged in to a web application and verified the user is getting an email logged in user.

*** Settings ***
Library           Collections
Library           OperatingSystem
Library           String
Library           SeleniumLibrary

*** Variables ***
${driver} webdriver.gecko.driver
${path} C:\\Users\\ddev0\\Downloads\\driver\\chromedriver
${url}= “enter your site URL here”
${browser} chrome

#Gmail Login
USER_EMAIL = "mailto:[email protected]"
USER_PASS  = "wituloholeefukow"      #App password
APP_USER_EMAIL = "mailto:[email protected]"
APP_USER_PASS  = "Tester1@”

*** Keywords ***
Verify Email Notification For Logged In User
    [Documentation]  This keyword use to verify email of account verified 
    ...   Argument1: user of the registered user
    ...   Argument2: email of the registered user
    [Arguments]  ${username}  ${email}
    Open Mailbox    user=${USER_EMAIL}   password=${USER_PASS}
    ${LATEST} =    Wait For Email    subject=Login  (${email})    timeout=300
    ${HTML} =    Get Email body    ${LATEST}
    Should Contain  ${HTML}  Hello  ${username}
    Should Contain  ${HTML}  Thank you for verifying your email address.  Your account will be approved shortly and you will receive an email with information 
    Should Contain  ${HTML}  In the meantime, please make sure to sign up
    Close Mailbox

Login With User   #created keyword to login into my app
    [Arguments]    ${user}   ${pswd}
    Login Page Should Be Seen
    input text    ${EMAIL_INPUT_FIELD}      ${user}
    input text    ${PASSWORD_INPUT_FIELD}    ${pswd}
    Click Button    ${SUBMIT_BTN}

*** Test Cases ***

Verify user is getting notification when a registered user logged in into system
    [Tags]   test=1
     Set Environment Variable ${driver} ${path}
     Open Browser ${url} ${browser}                                   
     Login With User    ${APP_USER_EMAIL}    ${APP_USER_PASS} 
     Verify Email Notification For Logged In User  ${USERNAME}   ${USER_EMAIL}  
     Close After Test    ${USERNAME}
     Close Browser

Command to Run the Above Program

Program to run

Recommended to Read:- Read Data From Excel Using Python in Robot Framework


EmailNotifications Report

Test Details

I hope this blog helped you to learn, how to set the app password and verify the email for the accounts where two-factor authentication is enabled.

  • Can we automate emails in Outlook using selenium?

Selenium is a powerful tool that enables the automation of web browsers, making workflow more efficient. However, for pulling emails from a server’s API the answer is no – something else needs to be used!

  • Can we use Robot Framework for mobile testing?

Robot Framework makes testing a breeze by removing the need to rewrite tests for different platforms. This allows you to focus on one test and use it across multiple systems, like Android/iOS apps or Firefox/Chrome/Safari browsers!

  • How do you pass the robot test?

To easily pass the test, all you have to do is click and hold on to the checkbox for a couple of seconds before releasing it. No extra effort is necessary – it’s an instant success!

  • How does the robot test work?

To pass the test, users must put their deciphering skills to work in order to identify and type out letters that have been transformed into a seemingly unrecognizable form. Those who succeed will receive passage – those who fail to invite for another try!

If you are interested in even more software testing-related articles and information from us here at Devstringx, then we have a lot to choose from

Share this post

Back to Blog