0
votes

I am using Selenium tool for automation and My automation scripts are failing because of this gmail issue.

Not sure, after my automated script sends my Email on Sign In page(https://google.com) usually it should go to

Enter Password page but instead why gmail is navigating to page

https://accounts.google.com/signin/v2/usernamerecovery?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin

where it asks me to "Find Your Email" by entering the recovery email.

FIND YOUR EMAIL PAGE

Even after i enter all the correct details it still says "cannot find email". Every time i run my script i face the same issue.

I have tried with different Email ID's, irrespective of Email ID whenever i run it from my Automation Script i am redirected to "Find Your Email" page

And if i refresh and enter my Email address manually it identifies my Email Id and navigates to Enter Password Page and works fine

Can Anybody help me resolve this as my website is completely dependent on the link i open it from Email.

I am on Windows using Google Chrome as my web browser.

Please refer to the attached screenshot of the Find Your Email page

CODE:

GMAIL PAGE

[FindsBy(How = How.Id, Using = "identifierId")] public IWebElement gmailUserName { get; set; }

[FindsBy(How = How.Name, Using = "password")] public IWebElement gmailPassWord { get; set; }

[FindsBy(How = How.ClassName, Using = "CwaK9")] public IWebElement gmailNext { get; set; }

public void LaunchGmail()

    {
        webDriver.Manage().Cookies.DeleteAllCookies();

        webDriver.Navigate().GoToUrl("https://gmail.com");

    }

    public void GmailLogin(int iteration)

    {

        if (iteration < 1)

        {

            gmailUserName.SendKeys(ConfigurationManager.AppSettings["GmailUserName"] + "@gmail.com");

            gmailNext.Click();

        }

        Thread.Sleep(2000);

        gmailPassWord.SendKeys(ConfigurationManager.AppSettings["GmailPassWord"]);

        gmailNext.Click();

    }

TESTSETUP PAGE

[Binding]

public class TestSetup

{

    public static IWebDriver WebDriver;

    Actions myAction;

    public static int TestCaseNumber = 0;

    public GmailPage _gmailPage = new GmailPage(WebDriver);

[BeforeScenario]

    public void BeforeScenario()

    {
        currentTest = Test.CreateNode("TestName : " + ScenarioContext.Current.ScenarioInfo.Title);

        String ScenarioName = ScenarioContext.Current.ScenarioInfo.Title;

        WebDriver.Manage().Window.Maximize();

        if (ScenarioName.Equals("Scenario Name"))
        {
            _gmailPage.launchGmail();

            _gmailPage.GmailLogin(TestCaseNumber);

            _gmailPage.DeleteRegistrationEmail();

            _gmailPage.gmailLogout();

        }

    }

Used Iteration as i launch gmail delete an email and launch my application Register as a user and relaunch Gmail after user Registers in my application user have to complete registration by clicking on the link sent to email to Set Password

Thanks,

Automation Choicez

1
Can you share your code?Aman B
Can you edit your question and paste the code there? it's not easy to read hereAman B
Also, what is the selector for gmailNext ?Aman B
If you are just going to gmail.com it doesn't have username textbox?Aman B
If you are just going to gmail.com it doesn't have username textbox? Username is nothing but the EMAILAutomation Choicez

1 Answers

0
votes

Class CwaK9 is assigned to 2 different controls (forgot password & next button). Try getting the parent div with Id passwordNext (which actually has the click method defined on it) and call click on that. This will ensure the next button is clicked.