# Cucumber Spicejet

**pom.xml**

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.spicejet</groupId>
    <artifactId>SpiceJetAutomation</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.8.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>7.0.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
```

[**LoginPage.java**](http://LoginPage.java)

```java
package pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.time.Duration;

public class LoginPage {
    WebDriver driver;
    WebDriverWait wait;

    @FindBy(xpath = "//div[contains(text(),'Login')]")
    WebElement loginButton;

    @FindBy(xpath = "//input[@data-testid='user-mobileno-input-box']")
    WebElement mobileField;

    @FindBy(xpath = "//input[@type='password']")
    WebElement passwordField;

    @FindBy(css = ".css-1dbjc4n.r-1awozwy")
    WebElement loginSubmitButton;

    public LoginPage(WebDriver driver) {
        this.driver = driver;
        this.wait = new WebDriverWait(driver, Duration.ofSeconds(15));
        PageFactory.initElements(driver, this);
    }

    public void clickLoginButton() {
        loginButton.click();
    }

    public void enterMobileNumber(String mobile) {
        wait.until(ExpectedConditions.visibilityOf(mobileField));
        mobileField.sendKeys(mobile);
    }

    public void enterPassword(String password) {
        passwordField.sendKeys(password);
    }

    public void clickSubmit() {
        loginSubmitButton.click();
    }
}
```

[**SearchFlightsPage.java**](http://SearchFlightsPage.java)

```java
package pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class SearchFlightsPage {
    WebDriver driver;

    @FindBy(xpath = "//div[@data-testid='to-testID-origin']//input[@type='text']")
    WebElement originInput;

    @FindBy(xpath = "//div[contains(text(),'Dharamshala')]")
    WebElement originOption;

    @FindBy(css = ".css-76zvg2")
    WebElement destinationInput;

    @FindBy(xpath = "//div[normalize-space()='Goa International Airport']")
    WebElement destinationOption;

    @FindBy(css = "div[class='css-1dbjc4n r-18u37iz'] div:nth-child(1)")
    WebElement dateSelect;

    @FindBy(css = ".css-1dbjc4n.r-1awozwy")
    WebElement searchButton;

    public SearchFlightsPage(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);
    }

    public void enterOrigin() {
        originInput.click();
        originOption.click();
    }

    public void enterDestination() {
        destinationInput.click();
        destinationOption.click();
    }

    public void selectDate() {
        dateSelect.click();
    }

    public void clickSearch() {
        searchButton.click();
    }
}
```

[**BookingPage.java**](http://BookingPage.java)

```java
package pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class BookingPage {
    WebDriver driver;

    @FindBy(xpath = "(//input[@type='text'])[6]")
    WebElement firstNameField;

    @FindBy(xpath = "(//input[@type='text'])[7]")
    WebElement lastNameField;

    @FindBy(css = ".css-1dbjc4n.r-1kihuf0")
    WebElement bookButton;

    public BookingPage(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);
    }

    public void enterPassengerDetails(String firstName, String lastName) {
        firstNameField.sendKeys(firstName);
        lastNameField.sendKeys(lastName);
    }

    public void confirmBooking() {
        bookButton.click();
    }
}
```
