Sie sind auf Seite 1von 4

ActiTime.

java

package TestNG;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class ActiTime extends BaseTestAT
{

ChromeDriver driver = new ChromeDriver ();


POMNewTest pm = new POMNewTest(driver);

@Test
public void Loginpage()
{

pm.setusername("admin");
pm.setpassword("manager");
pm.clicklogin();
}
@Test
public void secondpage()

pm.settings();
pm.License();
}

@Test
public void Thirdpage()
{

pm.issuedate();

============================================
POM
package TestNG;

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

public class POMNewTest


{
@FindBy (id="username")
private WebElement un;

@FindBy (name="pwd")
private WebElement pw;

@FindBy (xpath="//div[.='Login ']")


private WebElement lgbtn;

@FindBy (xpath="//div[@class='popup_menu_icon settings_icon']")


private WebElement settings;

@FindBy(xpath="//a[text()='Licenses']")
private WebElement Lic;

@FindBy(xpath ="//nobr[.='Issue Date:']/../../td[2]")


private WebElement issuedate;

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

public void setusername(String admin)


{
un.sendKeys(admin);
}

public void setpassword(String manager)


{
pw.sendKeys(manager);
}

public void clicklogin()


{
lgbtn.click();
}
public void settings()

{
settings.click();
}

public void License()


{
Lic.click();
}

public void issuedate()


{
issuedate.getText();
}

===========================================
package TestNG;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;

public class BaseTestAT {


@BeforeTest
public void login()
{
System.setProperty("webdriver.chrome.driver","./driver/chromedriver.exe");
}

======================
package ActiTime;

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

public class POMAT {

@FindBy (id="username")
private WebElement un;

@FindBy (name="pwd")
private WebElement pw;

@FindBy (xpath="//div[.='Login ']")


private WebElement lgbtn;

@FindBy (xpath="//div[@class='popup_menu_icon settings_icon']")


private WebElement settings;

@FindBy(xpath="//a[text()='Licenses']")
private WebElement Lic;

@FindBy(xpath ="//nobr[.='Issue Date:']/../../td[2]")


private WebElement issuedate;

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

String fetchIssueDate() throws InterruptedException


{
Actions act =new Actions(driver);
act.moveToElement(settings).click().perform();
Thread.sleep(1000);
act.moveToElement(Lic).click().perform();
Thread.sleep(1000);
String Date=issuedate.getText();
return Date;

}
}