Pom
Page Object Model, is selenium
framework where we can create object of each page and call in test methods.
Same time in test case method we only
call method from page.
Below is project for POM
In test package you need to use below
code
As classname “Google”
package test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import
org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import pages.GoogleFun;
import pages.Guru99HomePage;
import pages.Guru99Login;
public class Google {
GoogleFun
objGoogle;//page obejct
@Test
public
void test_Home_Page_Appear_Correct(){
System.setProperty("webdriver.chrome.driver",
"D://Ylo//chromedriver.exe");
WebDriver
driver = new ChromeDriver();
// driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
driver.get("https://www.webpagetest.org/");
System.out.println("test1");
System.out.println("test2");
//Create
Login Page object
objGoogle
= new GoogleFun(driver);// calling page method
objGoogle.searchButtonExist();
}
}
In package “pages” you have to use “GoogleFun”
as class
package test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import
org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import pages.GoogleFun;
import pages.Guru99HomePage;
import pages.Guru99Login;
public class Google {
GoogleFun
objGoogle;//page obejct
@Test
public
void test_Home_Page_Appear_Correct(){
System.setProperty("webdriver.chrome.driver",
"D://Ylo//chromedriver.exe");
WebDriver
driver = new ChromeDriver();
// driver.manage().timeouts().implicitlyWait(10,
TimeUnit.SECONDS);
driver.get("https://www.webpagetest.org/");
System.out.println("test1");
System.out.println("test2");
//Create
Login Page object
objGoogle
= new GoogleFun(driver);// calling page method
objGoogle.searchButtonExist();
}
}
Remember you need to handle object
well in POM and in test file you have to call only page methods.
For object we can create Objet Repo or we can even call it from page, example mentioned in page class
No comments:
Post a Comment