0% found this document useful (0 votes)
7 views3 pages

Package Pages OBJ MODEL

The document contains Java code for a Selenium-based automation framework with a BasePage class that provides common web interaction methods. The HomePage class extends BasePage, allowing navigation to the N11 website and transitioning to a login page. It includes methods for clicking buttons and logging actions using a logging utility.

Uploaded by

Sarithag Devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Package Pages OBJ MODEL

The document contains Java code for a Selenium-based automation framework with a BasePage class that provides common web interaction methods. The HomePage class extends BasePage, allowing navigation to the N11 website and transitioning to a login page. It includes methods for clicking buttons and logging actions using a logging utility.

Uploaded by

Sarithag Devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

package pages;

import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class BasePage {


public WebDriver driver;
public WebDriverWait wait;

//Constructor
public BasePage(WebDriver driver) {
this.driver = driver;
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}

//Click Method
public void click(By by) {
waitVisibility(by).click();
}

//Write Text
public void writeText(By by, String text) {
waitVisibility(by).sendKeys(text);
}

//Read Text
public String readText(By by) {
return waitVisibility(by).getText();
}

//Wait
public WebElement waitVisibility(By by) {
return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
}
}

package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import utils.logs.Log;

public class HomePage extends BasePage {


/**
* Constructor
*/
public HomePage(WebDriver driver) {
super(driver);
}

/**
* Variables
*/
String baseURL = "http://www.n11.com/";

/**
* Web Elements
*/
By signInButtonClass = By.className("btnSignIn");

/**
* Page Methods
*/
//Go to Homepage
public HomePage goToN11() {
Log.info("Opening N11 Website.");
driver.get(baseURL);
return this;
}

//Go to LoginPage
public LoginPage goToLoginPage() {
Log.info("Going to Login Page..");
click(signInButtonClass);
return new LoginPage(driver);
}
}

package pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import utils.logs.Log;

public class HomePage extends BasePage {


/**
* Constructor
*/
public HomePage(WebDriver driver) {
super(driver);
}

/**
* Variables
*/
String baseURL = "http://www.n11.com/";

/**
* Web Elements
*/
By signInButtonClass = By.className("btnSignIn");

/**
* Page Methods
*/
//Go to Homepage
public HomePage goToN11() {
Log.info("Opening N11 Website.");
driver.get(baseURL);
return this;
}

//Go to LoginPage
public LoginPage goToLoginPage() {
Log.info("Going to Login Page..");
click(signInButtonClass);
return new LoginPage(driver);
}
}

You might also like