Commit c369b476 authored by Qazi Zain's avatar Qazi Zain

Nisum Web Automate Task of Cucumber BDD is uploaded

parent 0f45dd3f
@Navigate
Feature: Navigate Functionality
@PositiveScenario
Scenario Outline: Validate the links navigate to the correct page
Given User is Present on nisum Website
When User click on Global Career and then click on pakistan
Then User Should see "<expectedText>" on Page
Examples:
| expectedText |
| We're Hiring Now! |
package NisumWebTest.Cucumber;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(features ="src/main/java/NisumWebTest/Cucumber",glue="NisumWebTest.StepDefination",monochrome = true,plugin = {"html:target/Nisumcucumber.html"})
public class TestRunner extends AbstractTestNGCucumberTests {
}
package NisumWebTest.PageObject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import javax.swing.*;
import java.time.Duration;
public class NisumPage
{
WebDriver obj;
WebDriverWait wait;
public NisumPage(WebDriver obj)
{
this.obj=obj;
PageFactory.initElements(obj,this);
wait = new WebDriverWait(obj, Duration.ofSeconds(8));
}
@FindBy(xpath = "//div[@class='hhs-header-menu custom-menu-primary js-enabled']//*[text()='Global Careers']")
WebElement CareerDropDown;
@FindBy(xpath = "(//div[@class='hhs-header-menu custom-menu-primary js-enabled']//*[@href='https://www.nisum.com/careers/careers-pakistan'])[1]")
WebElement PakistanCareer;
@FindBy(xpath = "//div[@class='hhs-rich-text wow fadeIn']//h1")
WebElement HiringHeading;
//---------------------------------------> Action Flow.
public void RunFlow()
{
Actions mouse = new Actions(obj);
mouse.moveToElement(CareerDropDown).build().perform();
PakistanCareer.click();
}
public String PassText()
{
wait.until(ExpectedConditions.visibilityOf(HiringHeading));
return HiringHeading.getText();
}
}
package NisumWebTest.StepDefination;
import NisumWebTest.PageObject.NisumPage;
import NisumWebTest.Utils.BaseTest;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Then;
import org.testng.Assert;
public class StepDefination extends BaseTest {
NisumPage object;
@Given("User is Present on nisum Website")
public void user_is_present_on_nisum_website() {
setUp(); // Setup WebDriver and navigate to the site
object = new NisumPage(driver); // Initialize the page object after WebDriver is set up
}
@When("User click on Global Career and then click on pakistan")
public void user_click_on_global_career_and_then_click_on_pakistan() {
object.RunFlow(); // Perform actions on the page object
}
@Then("User Should see {string} on Page")
public void user_should_see_we_re_hiring_now_on_page(String expectedText) {
Assert.assertEquals(object.PassText(), expectedText); // Validate the text on the page
}
}
package NisumWebTest.Utils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import java.time.Duration;
public class BaseTest {
public WebDriver driver;
@BeforeMethod
public void setUp()
{
driver= new FirefoxDriver();
driver.get("https://www.nisum.com/");
}
@AfterMethod
public void tearDown()
{
if(driver!=null)
{
driver.quit();
}
}
}
......@@ -12,3 +12,5 @@ Feature: Validating the login Functionality
| name | pass |
| zain | rahulshettyacademy |
| yawar | rahulshettyacademy |
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment