P3selenium Framework Configuration Steps

Here we will see the Configuration Steps of P3selenium.


Java should be installed in the system
TestNG and Maven should be installed in eclipse

NOTE: We are using “Eclipse Juno” in this example

Configuration Steps:
You can get P3selenium framework from Github, use the following URL to download the zip

Step 1: Extract the zip file and put it in your workspace
Step 2: Open Eclipse IDE.
Step 3: Go to File > Import
Step 4: Import window will open, select Existing Projects into Workspace under General category


Step 5: Now to run different tests you have to make an entry in testng.xml file. Below is the testng.xml file used in p3selenium framework

Step 6: To run the test, right click on the project go to “Run As” > Maven test.
NOTE: When you run the project first time it may take time because it will download some required jar files.

Step 7: Now, we have to see the reports.
Reports will get generated at the end of the test execution and to see the reports you have to open the index.html file which is under target>surefire-reports>html>index.html

grid console, registered node

Selenium webdriver and Grid Integration

In this post we will see Selenium webdriver and Grid Integration, you will get the answers of the following questions:
What is Selenium Grid?
How it is useful?
Requirements of Selenium Grid
How to Setup Selenium Grid?

Selenium grid is a way using which we can run our automated script on other system (prerequisite: they should be in LAN).

You need the selenium standalone server on both the machines i.e. on hub machine and on node machine.
Machine on which the selenium framework or script is actually present is the hub machine and the other machine on which we are intended to execute the script are the node machine.

you can download the selenium standalone server from http://docs.seleniumhq.org/download/

After downloading follow the following steps:

Step – 1: open command prompt on the hub machine or on the machine which you want to make hub.
Step – 2: Goto the folder where you put the selenium standalone server, then execute the following command:
java -jar selenium-server-standalone-2.41.0.jar -role hub

once this command executed your hub is ready to for the node to connect.
Step – 3: You can check hub is running by clicking the view config of the URL: http://localhost:4444/grid/console

Grid console

Now go to another system which you want to make node, you just need the selenium standalone server and browser specific driver on this machine but not the complete framework as like you have on hub machine.
Put both the jars in same folder.

Open command prompt and go to the respective folder and execute the following command (By using below command we are registering chrome driver)

java -jar selenium-server-standalone-2.41.0.jar \ -role node -port 5555 -hub http://IP_OF_HUB:
4444/grid/register \ -browser browserName=chrome, version=33, platform=WINDOWS -Dwebdriver.chrome.driver=\chromedriver.exe

start grid node

once you executed the node command, open the http://localhost:4444/grid/console
you will see node details, see below image

grid console, registered node

Now you have to tell selenium framework on hub machine to run the test script on the registered node.
Below is the code snippet:

NOTE: p3selenium framework already grid enabled you just have to set use_grid=true in config.properties (https://github.com/AbhishekAggarwal/p3selenium/blob/master/src/test/resources/config.properties) and p3selenium framework works in grid mode.

private static String SELENIUM_HUB_URL;
private static String TARGET_SERVER_URL;

private static String getConfigurationProperty(String envKey,
String sysKey, String defValue) {
String retValue = defValue;
String envValue = System.getenv(envKey);
String sysValue = System.getProperty(sysKey);
// system property prevails over environment variable
if (sysValue != null) {
retValue = sysValue;
} else if (envValue != null) {
retValue = envValue;
return retValue;

SELENIUM_HUB_URL = getConfigurationProperty("SELENIUM_HUB_URL",
"test.selenium.hub.url", "http://localhost:4444/wd/hub");
logger.info("using Selenium hub at: " + SELENIUM_HUB_URL);
TARGET_SERVER_URL = getConfigurationProperty("TARGET_SERVER_URL",
"test.target.server.url", "http://domain_name.com");
logger.info("using target server at: " + TARGET_SERVER_URL);

capability = DesiredCapabilities.chrome();
System.setProperty("webdriver.chrome.driver", project_path
+ "\\src\\test\\resources\\driver\\chromedriver_v32.exe");
//setDriver(new ChromeDriver(capability));
setDriver(new RemoteWebDriver(new URL(
SELENIUM_HUB_URL), capability));
getDriver().get(TARGET_SERVER_URL + "/");

Now open Run/Debug Settings

Run/Debug Settings

click edit then go to arguments tab and paste the following:


Set parameters for Grid

Its done.
now you can run the project and it will execute the test script on node machine

How to Start Scripting using P3selenium Framework

Before see how to Start Scripting using P3selenium Framework let’s first see the structure of the p3selenium framework, it will give the better understanding in scripting.

Project Structure:

p3selenium folder structure

P3selenium built with robust folder structure. We have attached a info file with each folder which tells you the use of that folder.

Now let’s start with the scripting.
P3selenium framework has WebDriverFactory class that contains all methods that selenium framework contains. These methods are redefine so that they can be used easily and also this class has given additional methods other than methods provided by selenium webdriver, those methods will be explained later in the post or post series.
To use WebDriverFactory we need to first create the object of WebDriverFactory class.

then to use methods of the WebDriverFactory follow the below syntax:

element_name and element_type are string type.

element_type can be anything like name, css, link, class, id, name, value, label, xpath, tag and partialLinkText.

WebDriverFactory class have below methods:

WebDriverFactory Outline

WebDriverFactory class act as addon while scripting, suppose you want to move over an element then you can use mouseOver method by using following code:

these methods can be called in the same way by creating wdf object. Like for click method you have to write the following code:


One great advantage of using this framework is the *robust exception handling mechanism*. For example, during searching of element on the page if an exception occurs then the framework itself handles it and tells you the exact line where the error occurs rather then saying no such element.

Other methods like:

  • findElement
  • get
  • getCurrentUrl
  • getPageSource
  • getTitle
  • getWindowHandle
  • getWindowHandles
  • manage
  • navigate
  • quit

can be used by writing getDriver().method_name(); or driver.method_name(); in your scripts.

You can use findElement() in two ways:
1. either way you write the code by directly calling the method on driver object driver.findElement(By by)
2. or by creating object of WebDriverFactory, for example –

Special features:
Ready to Use Functions
There are some methods that you might need while scripting

Consider a situation where you want to find an element(s) in a table:
Sometimes you may encounter with the table on a web page.

heading1 heading2
value1 value2
value1 value2
end1 end2

structure, where you may face difficulty to write the generic code to locate an element. We have made it possible, call below function to locate the element in the table

We are developing a demo site where you can test all the functionality of this framework, Stay Tuned :)

Use and Benefit of P3selenium

In this article we will talk about the Use and Benefits of p3selenium.

Use of P3selenium framework and benefits:

First thing first, before proceeding we would like to see the benefits of using this framework. Some of the benefits of the P3selenium framework are listed below:

  1. Scalable: This framework allows you to add new features can easily
  2. Maintainable: This framework follows a robust package structure that allows you to maintain and manage your automated scripts in an easy way. It helps you to keep your scripts in a manageable way. You can manage and run as many scripts as needed.
  3. Boilerplate code: P3selenium can be used as a boilerplate code, you do not have to write the code to create a framework for automation testing, just pick the P3selenium and start scripting your application scenarios from day one.You can keep your scripts under com.p3selenium.scripts.pname.testcase
  4. Centralized exception handling: Besides stack trace information, the framework assists you by letting you know the which line of code throws an error. We have built a robust framework by using a centralized exception handling mechanism. Any one using P3selenium framework can take advantage of this.Suppose an exception occurs while script execution then it this framework handles the exception and gives you a useful message that let you quickly identify the exception occurred.
  5. Database Testing: Adding this feature to the framework, this feature will be added in second release i.e. p3selenium_v1.0
  6. Grid Enabled: P3selenium framework is grid enabled, it contains all the settings that is required to run the framework as a grid.

    Next >> How to start with P3selenium Framework


Introduction to P3selenium, an Automation Framework

Updated link : http://p3lang.com/portfolio/p3selenium-automation-framework/

We are very excited to give introduction to our new work.


This is an Introduction to P3selenium, an Automation Framework P3selenium is a selenium automation framework written in Java. You can easily get it from github, use below URL: https://github.com/AbhishekAggarwal/p3selenium

Version: p3selenium_v0.1_beta

Technologies used:

  1. Java 1.7
  2. Selenium WebDriver or Selenium 2.0
  3. Testng 6.1.1 (for Reporting)
  4. Maven (to manage project/Framework)

This is the beta version, in case you find any bug or you want any enhancement then you can drop a mail at abhishek.smile09@gmail.com or report on the Github Issues “https://github.com/AbhishekAggarwal/p3selenium/issues“. Your suggestion are very welcome.

Next >> Read Use and Benefit of P3selenium