Creating an automation code that is maintainable is among the keys to your favorable test automation Job. Test automation code must be treated as similar standards and production code And designs should while developing this code, to be used.

We may use the Webpage Object model pattern while developing Selenium Web Driver evaluations. This In improving the evaluations, making them exceptionally maintainable, cutting back the code pattern helps Duplication, concealing the internal execution from evaluations, and creating a layer of abstraction.

Utilizing the Webpage Object Model

By using object oriented development principles, we are able to create a group that functions as an Interface into a website in the program, modeling conduct and its properties. This helps

in making a layer of separation involving the test code and code unique to the webpage, by

Concealing the technical execution including locators used to spot components on the webpage, layout, etc.

The Page Object design pattern provides evaluations for an interface in which a test can operate on such a page in a fashion much like an individual getting the page, but by concealing its internals.

For instance, if we construct a Page Object evaluation to get a login page, then it’ll supply a solution take an individual to the and to log in, that will accept the username and password home page of the program. The evaluation need not worry about input signal controls are employed for the login page, their locator details, etc.

Evaluations should use items of a page in a higher degree, where any characteristics or change in layout used for the subjects in the inherent page must not break the evaluation.

This chapter covers evaluations using relevant layout and Page Object model to be built by recipes. For exposing components from a page using the PageFactory group

We should plan and develop a Page Item for executing the Web Page Object model in evaluations Type for every page being analyzed. As an example, to examine a BMI, the BMI Calculator program Calculator page type is going to be defined, that will expose the internals of the BMI Calculator page to the evaluation, as shown in following diagram.

Using the PageFactory group does this of Selenium WebDriver API. Sample Codes will soon be posted shortly……

Selenium WebDriver – Architecture

selenium-webdriver-architecture

I Attempt To Simplify as much as you possibly can to know the method by which the structure of Selenium formed.

Selenium WebDriver Split into 3 major sections

  1. Language amount Bindings
  2. Selenium WebDriver API
  3. Drivers

Language Degree Bindings

We now have a common API with a common group of commands and we’ve various bindings for the languages that are different. So we are able to see there is Java, Python, Ruby, etc..There Is also some other bindings and new bindings can be added quite easily.

Selenium WebDriver API

Now these bindings and Selenium WebDriver API convey and this API send the commands taken from language degree bindings sent it to Individual driver and interpret it. In temporary API includes place of common library which enable sending command to individual drivers.

Drivers

Internet Browser Special Drivers such as IE, FF, Chrome etc..It functions in headless mode which makes, text execution quicker. In addition, it includes particular Drivers that are mobile. The essential notion is each one among the drivers knows the best way to drive the browser it corresponds to. For E.g. Chrome Driver understands how to manage the low level details of chrome driver and drive it to do things like clicking the objective component, browsing the goal page etc…

How it is working:

Your evaluation is being written by you in Java using common that commands are being sent by Java binding across this common API and selenium API. Now on another end is listening a driver, those commands are interpreted by it and running them on return result back-up and the specific browser utilizing the API.

WebDriver – Recording Screen shot

This can help when evaluation run and extraordinary malfunctions during execution through The Use Of the webpage will be Captured by the TakeScreenshot Interface WebDriver.

Sample Code:

@Test

public void testScreenshot()

{

try {

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(scrFile, new File(“c:\\Screeshots\\Loginpage.png”));

} catch (Exception e) {

e.printStackTrace();

}

}

The way that It Works….

The TakesScreenshot interface supplies the getScreenshotAs() procedure to get

a screenshot of the page shown in the driver example. In the below code , we

Set OutputType.FILE as an argument to the getScreenshotAs() procedure,

So that it’ll return the screenshot that is shot in a file:

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

We can save the file object returned by the getScreenshotAs() procedure using the

copyFile() procedure of the FileUtils group

Leave a Reply

Your email address will not be published. Required fields are marked *