• Skip to main content
  • Skip to primary sidebar

ITechOasis

Ease Your IT+Tech Experience!

  • Home
  • All Courses
  • My Account
  • Blog
You are here: Home / Automation / Yahoo Login Test using Cucumber and Selenium

ITechOasis / March 11, 2018

Yahoo Login Test using Cucumber and Selenium

1. Feature File : myCuc.feature

Feature: Yahoo Login Page
Scenario: Yahoo Login Test

Given user opens Yahoo Login Page
Then user enters username
Then user clicks on Next Button
Then user enters password
And user clicks on signIn Button
And close the browser

2. Cucumber_Step_Definition Class :

package Practice_Cucumber;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;

public class Cucumber_Step_Def {
 
 WebDriver driver = null;
 
 @Given("^user opens Yahoo Login Page$")
 public void user_opens_Yahoo_Login_Page() {

 System.setProperty("webdriver.chrome.driver", "lib\\chromedriver.exe");
 driver = new ChromeDriver();
 driver.navigate().to("https://login.yahoo.com/");
 driver.manage().window().maximize(); 
 driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
 }
 
 @Then("^user enters username$")
 public void user_enters_username() {
 
 driver.findElement(By.xpath("//*[@id='login-username']")).sendKeys("[email protected]");
 
 }
 
 @Then("^user clicks on Next Button$")
 public void user_clicks_on_Next_Button() {
 
 driver.findElement(By.xpath("//*[@id='login-signin']")).click();
 
 }
 
 @Then("^user enters password$")
 public void user_enters_password() {
 
 driver.findElement(By.xpath("//*[@id='login-passwd']")).sendKeys("dummyPassword");
 
 }
 
 @And("^user clicks on signIn Button$")
 public void user_clicks_on_signIn_Button() {
 
 driver.findElement(By.xpath("//*[@id='login-signin']")).click();
 
 }
 
 @And("^close the browser$")
 public void close_the_browser() {
 
 driver.quit();
 
 }

}

3. Runner Class :

package Practice_Cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;


@RunWith(Cucumber.class)

@CucumberOptions(features="src/Practice_Cucumber/myCuc.feature", format = {"pretty","html:target/cucumber_report"})

public class RunTest {}

Filed Under: Automation Tagged With: Cucumber, Selenium

Software Testing – Manual+ Interview

Software Testing – Manual+ Interview

0
20h
I
By ITechOasis In Software Testing
Start Learning
Software Testing – FULL COURSE (Manual + Automation + Interview)
5.00
(2)

Software Testing – FULL COURSE (Manual + Automation + Interview)

1
50h
I
By ITechOasis In Software Testing
Start Learning
Robot Framework with Selenium & Python – UI+API Testing
5.00
(1)

Robot Framework with Selenium & Python – UI+API Testing

3
20h
I
By ITechOasis In Automation
Start Learning
Selenium with Java – Web Automation Framework from Scratch

Selenium with Java – Web Automation Framework from Scratch

2
30h
I
By ITechOasis In Automation
Start Learning
Python for Beginners – Learn Programming from scratch
5.00
(1)

Python for Beginners – Learn Programming from scratch

3
10h
I
By ITechOasis In Programming
₹5000 ₹3000
30% Booked
Add to cart
JAVA for Beginners – Learn Programming from scratch
5.00
(1)

JAVA for Beginners – Learn Programming from scratch

1
15h
I
By ITechOasis In Programming
₹8000 ₹5000
13% Booked
Add to cart

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

New title
Software Testing – Manual+ Interview

Software Testing – Manual+ Interview

0
20h
I
By ITechOasis In Software Testing
Start Learning
Software Testing – FULL COURSE (Manual + Automation + Interview)
5.00
(2)

Software Testing – FULL COURSE (Manual + Automation + Interview)

1
50h
I
By ITechOasis In Software Testing
Start Learning
Robot Framework with Selenium & Python – UI+API Testing
5.00
(1)

Robot Framework with Selenium & Python – UI+API Testing

3
20h
I
By ITechOasis In Automation
Start Learning
Selenium with Java – Web Automation Framework from Scratch

Selenium with Java – Web Automation Framework from Scratch

2
30h
I
By ITechOasis In Automation
Start Learning
Python for Beginners – Learn Programming from scratch
5.00
(1)

Python for Beginners – Learn Programming from scratch

3
10h
I
By ITechOasis In Programming
₹5000 ₹3000
30% Booked
Add to cart
JAVA for Beginners – Learn Programming from scratch
5.00
(1)

JAVA for Beginners – Learn Programming from scratch

1
15h
I
By ITechOasis In Programming
₹8000 ₹5000
13% Booked
Add to cart

·

  • About Us
  • Disclaimer
  • Privacy Policy
  • Terms and Services
  • Contact

Login

Register | Lost your password?

Register

Log In | Lost your password?

Reset Password

Lost your password? Please enter your username or email address. You will receive a link to create a new password via email.

Log In | Register

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.