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 🙂

Leave a Reply

Contact Us
close slider
Contact Us

How can we help you with?