Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver testing login verification/authentication

I am using Katalon to build the base Selenium script of which will allow me to have an automated login for gmail. I do however need to add password and username verification in between my test method code. I just need help understanding and if possible, a base template, for how I should structure my verification code. As my title says, I just need help understanding how to code login verification. Thanks ahead of time. Here is my [Test Method]. I am removing my username and password for security reasons, however my username is in the structure of [email protected] and my password follows this structure asd2098KAM.

[TestMethod]
    public void TheUntitledTestCaseTest()
    {
        driver.Navigate().GoToUrl("https://www.google.com/");
        driver.FindElement(By.LinkText("Gmail")).Click();
        driver.FindElement(By.LinkText("Sign In")).Click();
        driver.FindElement(By.Id("identifierId")).Clear();
        driver.FindElement(By.Id("identifierId")).SendKeys("aaaa.ksat97");
        driver.FindElement(By.Id("identifierId")).SendKeys(Keys.Enter);
        driver.FindElement(By.Name("password")).Clear();
        driver.FindElement(By.Name("password")).SendKeys("aln9178JKM");
        driver.FindElement(By.Name("password")).SendKeys(Keys.Enter);
    }
like image 298
S. Star Avatar asked Mar 31 '26 01:03

S. Star


1 Answers

  1. You can assert if your username displays. A displayed username would indicate a successful login.

  2. You can also see if a token/cookie is added to your session on login.

  3. Or see what response gmail sends back on failure/successful login post. Depending on the response you can assert if it's a successful login or not.

like image 148
starfighter104 Avatar answered Apr 02 '26 09:04

starfighter104



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!