Selenium

Java POM: 07-Apache POI ( Excel )

 

Imports

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

 

 

Tags

Java POM: 06-Selenium

 

Imports

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;

 

Components Commonly Used

WebDriver

  • Create a public class so its accessible through the application
  • Create a single static object so it also can be referenced throughout the application
  • This class will do the work of building up & calling the correct Browser & Profile
  • Then return the driver for use with the PageObjects(which will NOT be static)
public class BrowserUtils {
    public static WebDriver driver = null;
    public static WebDriver OpenBrowser(){

            // Create web driver
            driver = new FirefoxDriver();
            return driver;
    } //end method

}

 

Tags

Java POM: 05-TestNG

Configuration File testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suites" parallel="none">
       <listeners>
              <listener class-name="com.uc.test.selenium.util.Listener"></listener>
       </listeners>
      <test name="Simple Test">
        <classes>
          <class name="com.uc.test.selenium.tests.Test_Login"/>
        </classes>
      </test>
      <!-- test name="ALL">
          <packages>
              <package name="com.uc.test.selenium.tests" />
          </packages>
      </test -->
      
                          
</suite> <!-- Suite -->

 

Tags

Java POM: 04-Classes

Package Layout

  • src
    • log4j2.xml - log4j2 Configuration
    • pom.xml - Maven Configuration
    • testng.xml - TestNG Configuration
    • com.us.test.selenium
      • Main
    • com.us.test.selenium.pageactions
      • Home_Actions
    • com.us.test.selenium.pageobjects
      • Home_Page
      • PageBaseClass
    • com.us.test.selenium.tests
      • Login_Home
    • com.us.test.selenium.tests.testdata
      • TestData.xls
    • com.us.test.selenium.util
      • BrowserUtils
      • Constant
      • ElementUtils
      • ExcelUtils
      • LIstener
      • Listeners
      • TestLog

 

Classes

com.uc.test.selenium

Main

 

 

 

 

Tags

Java POM: 03-Packages

Packages Schema

Best Practices

  • all lower case names
  • use com.<brandName>.<appType>.<project>
    • the created packages will treat the '.' as a subfolder, yielding:
      • com
        • <brandName>
          • <appType>
            • <project>
  • managing packages this way ensures conflicts won't arise when including other projects for larger ecosystems

 

Tags
Subscribe to Selenium