Saturday 10 February 2018

config and testng xml

package com.spa.sfautomation.browser;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

import com.spa.sfautomation.page.AddDocumentURLPage;
import com.spa.sfautomation.page.AdminDefaultPage;
import com.spa.sfautomation.page.HomePage;
import com.spa.sfautomation.page.KPIMetricPage;
import com.spa.sfautomation.page.LoginPage;
import com.spa.sfautomation.page.popup.DeleteRowPopUp;
import com.spa.sfautomation.page.popup.ManageCustomModulesPopUp;
import com.spa.sfautomation.page.popup.ManageMetricCategoriesPopUp;
import com.spa.sfautomation.page.popup.ManageMetricDimensionsPopUp;
import com.spa.sfautomation.page.popup.ManageMetricTemplatesPopUp;
import com.spa.sfautomation.page.popup.ManageMetricUnitsPopUp;
import com.spa.sfautomation.page.popup.ManageMetricsPopUp;
import com.spa.sfautomation.util.ConfigReader;

public abstract class InitDriver {

enum DriverType {
IE, Chrome
}
public WebDriver driver;
public ConfigReader appProp;
public String baseURL;
public String adminUserId;
public String adminPassword;

@BeforeClass
@Parameters({"driverType"})
public void beforeMainClass(String driverType){
// TODO: some config xml file
if (DriverType.Chrome.toString().equals(driverType)) {
System.setProperty("webdriver.chrome.driver",".\\src\\main\\resources\\chromedriver.exe");
driver = new ChromeDriver();
}else if(DriverType.IE.toString().equals(driverType)){
System.setProperty("webdriver.ie.driver",".\\src\\main\\resources\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
else {
System.out.println("Driver type is not defined in testng.xml file, Please specify browser (IE or Chrome)");
}
//driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
loadApplicationProperties();
this.beforeClass();
}

@AfterClass
public void afterMainClass() {
this.afterClass();
driver.quit();
}

@BeforeMethod
public void beforeMainMethod() {
this.beforeMethod();
}

@AfterMethod
public void afterMainMethod() {
this.afterMethod();
}

@BeforeTest
public void beforeMainTest() {
this.beforeTest();
}

@AfterTest
public void afterMainTest() {
this.afterTest();
}

public abstract void beforeMethod();

public abstract void afterMethod();

public abstract void beforeClass();

public abstract void afterClass();

public abstract void beforeTest();

public abstract void afterTest();

//Page references
public LoginPage loginPage;
public HomePage homePage;
public AdminDefaultPage adminDefaultPage;
public KPIMetricPage kpiMetricPage;
public ManageMetricCategoriesPopUp manageMetricCategoriesPopUp;
public DeleteRowPopUp deleteRowPopUp;
public ManageMetricUnitsPopUp manageMetricUnitsPopUp;
public ManageMetricDimensionsPopUp manageMetricDimensionsPopUp;
public AddDocumentURLPage addDocumentURLPage;
public ManageMetricTemplatesPopUp manageMetricTemplatesPopUp;
public ManageCustomModulesPopUp manageCustomModulesPopUp;
public ManageMetricsPopUp manageMetricsPopUp;

//data variables
public List <String> categoryDataList = new ArrayList<String>(0);
public List <String> unitDataList = new ArrayList<String>(0);
public List <String> dimensionDataList = new ArrayList<String>(0);
public List <String> templateDataList = new ArrayList<String>(0);
public List <String> customModuleDataList = new ArrayList<String>(0);
public List <String> metricDataList = new ArrayList<String>(0);

//get application configuration setting.
public void loadApplicationProperties(){
ConfigReader appProp = new Config Reader();
baseURL = appProp.readKeyValue("BASE_URL");
adminUserId = appProp.readKeyValue("ADMIN_USERID");
adminPassword = appProp.readKeyValue("ADMIN_PASSWORD");
}

//load landing page
public void openURL(){
driver.get(baseURL+"/login.aspx");
}

}
==========================
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="KPI Marics Suite" parallel="false">
<!-- dtiverType = IE, Chrome -->
<parameter name="driverType" value="Chrome"></parameter>

  <test name="Verify adding a new category">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddCategory"/>
</classes>
</test>
<test name="Verify by clicking on close, category is not added">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotAddCategory"/>
</classes>
</test>
<test name="Verify Editing an existing category">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.EditCategory"/>
</classes>
</test>
<test name="Verify by clicking on cancel, category is not Edited">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotEditCategory"/>
</classes>
</test>
<test name="Verify validation message for category field on adding category">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnAddCategory"/>
</classes>
</test>
<test name="Verify validation message for category field on editing category">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnEditCategory"/>
</classes>
</test>
<test name="Verify deleting a category">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.DeleteCategory"/>
</classes>
</test>
<test name="Verify adding a new unit">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddUnit"/>
</classes>
</test>
<test name="Verify by clicking on close, unit is not added">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotAddUnit"/>
</classes>
</test>
<test name="Verify Editing an existing unit">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.EditUnit"/>
</classes>
</test>
<test name="Verify by clicking on cancel, unit is not Edited">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotEditUnit"/>
</classes>
</test>
<test name="Verify validation message for unit name and symbol fields on adding unit">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnAddUnit"/>
</classes>
</test>
<test name="Verify validation message for unit name and symbol fields on editing unit">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnEditUnit"/>
</classes>
</test>
<test name="Verify deleting an unit">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.DeleteUnit"/>
</classes>
</test>
<test name="Verify adding a new basic dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddBasicDimension"/>
</classes>
</test>
<test name="Verify adding a new absolute tolerance dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddToleranceAbsoluteDimension"/>
</classes>
</test>
<test name="Verify adding a new percentage tolerance dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddTolerancePercentageDimension"/>
</classes>
</test>
<test name="Verify adding a new variation dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.AddVariationDimension"/>
</classes>
</test>
<test name="Verify with same base dimensions, new variation dimension is not added">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotAddVariationDimension"/>
</classes>
</test>
<test name="Verify by clicking on close, dimension is not added">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotAddDimension"/>
</classes>
</test>
<test name="Verify Editing a basic dimension to tolerance dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.EditBasicDimensionToTolerance"/>
</classes>
</test>
<test name="Verify Editing a tolerance dimension to variation dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.EditToleranceDimensionToVariation"/>
</classes>
</test>
<test name="Verify Editing a variation dimension to basic dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.EditVariationDimensionToBasic"/>
</classes>
</test>
<test name="Verify with same base dimensions, variation dimension is not edited">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotEditVariationDimension"/>
</classes>
</test>
<test name="Verify by clicking on cancel, dimension is not Edited">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.NotEditDimension"/>
</classes>
</test>
<test name="Verify validation message for name, display name and symbol fields on adding dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnAddDimension"/>
</classes>
</test>
<test name="Verify validation message for name, display name and symbol fields on editing dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.ValidationMessageOnEditDimension"/>
</classes>
</test>
<test name="Verify deleting a dimension">
<classes>
<class name="com.spa.sfautomation.test.kpi.basic.DeleteDimension"/>
</classes>
</test>
</suite>

No comments:

Post a Comment