Login test for Gmai...
Notifications
Clear all

Login test for Gmail with Cucumber and Selenium Webdriver

RSS

(@ganesh)
Noble Member
Joined: 1 year ago
Posts: 1362
19/05/2021 12:34 pm

Anyone please help me with gmail login test automation using Cucumber and Webdriver?


Quote
(@anamika)
Noble Member
Joined: 1 year ago
Posts: 1381
19/05/2021 12:36 pm

following feature-file shows the scenario for gmail login functionality test:

Feature: Login Feature File@seleniumScenario: Login scenario test for GmailGivennavigate to Gmail pageWhenuser logged in using username as “username” and password as “password”Thenhome page should be displayed

现在从这个铁ature file, you can write Selenium test file using Webdriver:

public class stepDefinition { WebDriver dr; @Given("^navigate to gmail page$") public void navigate(){ dr=new FirefoxDriver(); dr.get("http://www.gmail.com"); } @When ("^user logged in using username as \"(.*)\" and password as \"(.*)\"$") public void login(String username,String password){ dr.findElement(By.xpath("//*[@id='Email']")).sendKeys(username); dr.findElement(By.xpath("//*[@id='Passwd']")).sendKeys(password); dr.findElement(By.xpath("//*[@id='signIn']")).click(); dr.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); } @Then("^home page should be displayed$") public void verifySuccessful(){ String expectedText="Gmail"; String actualText= dr.findElement(By.xpath("//*[@id='gbq1']/div/a/span")).getText(); Assert.assertTrue("Login not successful",expectedText.equals(actualText)); } }

ReplyQuote
Share:
Baidu