diff --git a/src/main/java/NisumWebTest/Cucumber/Nisum.feature b/src/main/java/NisumWebTest/Cucumber/Nisum.feature new file mode 100644 index 0000000000000000000000000000000000000000..f4f95b2fc787fcd50476c442e411bbfdf0acc474 --- /dev/null +++ b/src/main/java/NisumWebTest/Cucumber/Nisum.feature @@ -0,0 +1,12 @@ +@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! | diff --git a/src/main/java/NisumWebTest/Cucumber/TestRunner.java b/src/main/java/NisumWebTest/Cucumber/TestRunner.java new file mode 100644 index 0000000000000000000000000000000000000000..df9e1f1f99898f0a5e621d98413b2c157f16060e --- /dev/null +++ b/src/main/java/NisumWebTest/Cucumber/TestRunner.java @@ -0,0 +1,11 @@ +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 { +} diff --git a/src/main/java/NisumWebTest/PageObject/NisumPage.java b/src/main/java/NisumWebTest/PageObject/NisumPage.java new file mode 100644 index 0000000000000000000000000000000000000000..b956867001b4ed365f809853fe68b6f3fc994ee4 --- /dev/null +++ b/src/main/java/NisumWebTest/PageObject/NisumPage.java @@ -0,0 +1,59 @@ +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(); + } + + + +} diff --git a/src/main/java/NisumWebTest/StepDefination/StepDefination.java b/src/main/java/NisumWebTest/StepDefination/StepDefination.java new file mode 100644 index 0000000000000000000000000000000000000000..57262f9fff407dba13f69f33d12768288a95ff68 --- /dev/null +++ b/src/main/java/NisumWebTest/StepDefination/StepDefination.java @@ -0,0 +1,30 @@ +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 + } + +} diff --git a/src/main/java/NisumWebTest/Utils/BaseTest.java b/src/main/java/NisumWebTest/Utils/BaseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..53c7bc75994a69de6b373fdaa7121af8f9099f45 --- /dev/null +++ b/src/main/java/NisumWebTest/Utils/BaseTest.java @@ -0,0 +1,33 @@ +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(); + } + } + +} diff --git a/src/main/java/POM_Structure_code/Cucumber/Login.feature b/src/main/java/POM_Structure_code/Cucumber/Login.feature index 5f7ae9ed7986090a7d3c54ce172b49b03ac3ff8f..012a18bb784e8e492d1d8432aeac249bcb11c9b7 100644 --- a/src/main/java/POM_Structure_code/Cucumber/Login.feature +++ b/src/main/java/POM_Structure_code/Cucumber/Login.feature @@ -12,3 +12,5 @@ Feature: Validating the login Functionality | name | pass | | zain | rahulshettyacademy | | yawar | rahulshettyacademy | + +