package com.test.webpages;
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.*;
import org.assertj.core.api.Assertions;
public class RegistrationPage {
private WebDriver driver;
//private static String url="https://www.cisiveglobal.com/Registration.html";
@FindBy(xpath = "//*[@id='name']")
WebElement elementName;
@FindBy(xpath = "//*[@id='dateofbirth']")
WebElement elementDOB;
@FindBy(xpath = "//*[@id='male']")
WebElement elementMale;
@FindBy(xpath="//*[@id='female']")
WebElement elementFemale;
@FindBy(xpath="//*[@id='qualification']")
WebElement elementQualification;
@FindBy(xpath="//*[@id='mobile']")
WebElement elementMobile;
@FindBy(xpath="//*[@id='emailid']")
WebElement elementEmail;
@FindBy(xpath="//*[@id='address']")
WebElement elementAddress;
public RegistrationPage(WebDriver driver) {
this.driver=driver;
PageFactory.initElements(driver, this);
}
public void enterName(String name) {
Assertions.assertThat(name)
.hasSizeGreaterThan(1)
.hasSizeLessThan(25)
.doesNotContainOnlyWhitespaces();
elementName.sendKeys(name);
}
public void enterDOB(String dateofbirth)
{
Assertions.assertThat(dateofbirth)
.doesNotContainAnyWhitespaces()
.isLessThan(java.time.LocalDateTime.now().toString())
.isGreaterThan("01/01/1900");
elementDOB.sendKeys(dateofbirth);
}
public void enterMale(String male) {
Assertions.assertThat(male)
.doesNotContainAnyWhitespaces()
.isEqualTo("male");
elementMale.click();
}
public void enterFemale(String female) {
Assertions.assertThat(female)
.doesNotContainAnyWhitespaces()
.isEqualTo("female");
elementFemale.click();
}
public void enterQualification(String qualification) {
Assertions.assertThat(qualification)
.doesNotContainAnyWhitespaces();
Select select=new Select(elementQualification);
select.selectByValue(qualification);
}
public void enterMobile(String mobile) {
Assertions.assertThat(mobile)
.doesNotContainAnyWhitespaces()
.hasSizeGreaterThan(0)
.hasSizeLessThan(11)
.containsOnlyDigits();
elementMobile.sendKeys(mobile);
}
public void enterEmail(String email) {
Assertions.assertThat(email)
.doesNotContainAnyWhitespaces()
.hasSizeGreaterThan(3)
.hasSizeLessThan(25);
elementEmail.sendKeys(email);
}
public void enterAddress(String address) {
Assertions.assertThat(address)
.hasSizeGreaterThan(0)
.hasSizeLessThan(255);
elementEmail.sendKeys(address);
}
}
--====================
package com.test.webpages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class RegistrationPageOperations {
private WebDriver driver;
//private static String url="https://www.cisiveglobal.com/Registration.html";
@FindBy(xpath="//*[@id='btnSubmit']")
WebElement eleBtnSubmit;
@FindBy(xpath="//*[@id='btnReset']")
WebElement eleBtnReset;
public RegistrationPageOperations(WebDriver driver) {
this.driver=driver;
PageFactory.initElements(driver, this);
}
public void clickOnSubmit() {
eleBtnSubmit.click();
}
public void clickOnReset() {
eleBtnReset.click();
}
}
No comments:
Post a Comment