Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package POM_NEW;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- public class POM_Object_Repository {
- WebDriver driver;
- //constructor
- public POM_Object_Repository(WebDriver driver) {
- this.driver = driver;
- }
- public void OpenBrowser(){
- driver.manage().window().maximize();
- }
- public void LaunchApplication(){
- driver.get("https://opensource-demo.orangehrmlive.com/");
- }
- public WebElement UserName(){
- WebElement user=driver.findElement(By.xpath("//input[@id='txtUsername']"));
- return user;
- }
- public WebElement Password(){
- WebElement pass=driver.findElement(By.xpath("//input[@id='txtPassword']"));
- return pass;
- }
- public WebElement Click(){
- WebElement click=driver.findElement(By.xpath("//input[@id='btnLogin']"));
- return click;
- }
- public void CloseBrowser(){
- driver.close();
- }
- public WebElement Performance(){
- WebElement performance=driver.findElement(By.xpath("//*[@id='menu__Performance']/b"));
- return performance;
- }
- public WebElement Configure(){
- WebElement configure=driver.findElement(By.xpath("//*[@id='menu_performance_Configure']"));
- return configure;
- }
- public WebElement KPIs(){
- WebElement kpis=driver.findElement(By.xpath("//*[@id='menu_performance_searchKpi']"));
- return kpis;
- }
- public WebElement Add(){
- WebElement add=driver.findElement(By.xpath("//*[@id='btnAdd']"));
- return add;
- }
- }
- ------------------------------------------------------------------------------------------------------------------
- package POM_NEW;
- import org.testng.annotations.Test;
- import org.testng.annotations.DataProvider;
- import org.testng.annotations.BeforeClass;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.testng.annotations.AfterClass;
- public class POM_TestNG_KeyAddDelete {
- WebDriver driver;
- POM_Object_Repository por;
- @Test(dataProvider = "UserName")
- public void UserName(String UserName) throws InterruptedException {
- WebElement user=por.UserName();
- user.sendKeys(UserName);
- }
- @Test(dataProvider = "Password")
- public void password(String Password) {
- WebElement pass=por.Password();
- pass.sendKeys(Password);
- WebElement click=por.Click();
- click.click();
- //verification
- String ExpVal="OrangeHRM";
- String ActVal=driver.getTitle();
- System.out.println("Verification :"+ActVal.equals(ExpVal));
- }
- @Test(priority=2,dataProvider = "KPIs")
- public void Navigate() throws InterruptedException{
- WebElement performance=por.Performance();
- performance.click();
- Thread.sleep(5000);
- WebElement configure=por.Configure();
- configure.click();
- Thread.sleep(5000);
- WebElement kpis=por.KPIs();
- kpis.click();
- Thread.sleep(5000);
- WebElement add=por.Add();
- add.click();
- }
- @DataProvider
- public Object[][] UserName() {
- return new Object[][] {
- new Object[] { "Admin" },
- //new Object[] { 2, "b" },
- };
- }
- @DataProvider
- public Object[][] Password() {
- return new Object[][] {
- new Object[] { "admin123" },
- //new Object[] { 2, "b" },
- };
- }
- @BeforeClass
- public void beforeClass() throws InterruptedException {
- driver=new FirefoxDriver();
- por=new POM_Object_Repository(driver);
- por.OpenBrowser();
- por.LaunchApplication();
- por.UserName();
- por.Password();
- por.Click();
- por.Performance();
- }
- @AfterClass
- public void afterClass() {
- por.CloseBrowser();
- }
- }
Add Comment
Please, Sign In to add comment