What is JAR file, De-compiling selenium JAR

Test Automation

JAR stands for Java Archive Files, to understand a jar file, de-compile it and then extracted files can help in understanding the underlying layers and architecture.

How to de-compile a JAR file

There are various opensource tools/software available using which a jar file can be de-compiled, I will be using one of the utility which is known as JD-GUI though there various other open source decompilers available

Download JD-GUI it from-http://jd.benow.ca/

please refer below screenshots

1 – Navigate to JAR which you want to de-compile.

2- Highlighted part is selenium webdriver which is defined as an interface.

What is selenium-

Answer-Selenium webdriver is an interface, it comes as a JAR file, to understand selenium webdriver one needs to de-compile it, post that structure of selenium webdriver can be understood. Using above JD-GUI de-compilation can be done.

Selenium architecture has four key components –

1-Selenium Client Library
2-JSON Wire Protocol over HTTP
3-Browser Drivers
4-Real Browsers

Selenium script pass command to selenium driver which interact with selenium binding/libraries using JSON protocol which then return it to browser and same helped real browser to execute the command.

So first Question is what is the purpose of making an interface-

Answer- In Java multiple inheritance is not allowed therefore interface plays a key role in achieving the same.
while creating object of ChromeDriver or FirefoxDriver we only write as-
WebDriver driver = new ChromeDriver / or New FirefoxDriver- That means we are using interface WebDriver and creating object or giving memory space for chromedriver/firefox driver. Using driver various methods/of different classes can be accessed, for accessing them WebDriver works as an interface.

Abstract classes and interface-which is widely used inside selenium jar as well as mostly recommended while designing a framework

Answer-In abstract classes method body can be defined we can use combination if abstract classes and interface by implementing interface to abstract class and extending the same abstract class by extending it, same can fulfill our purpose of re usability.

//Creating interface that has 2 methods
interface Class A{
void method1();//by default its , public and abstract
void method2();

}

//Creating abstract class that provides the implementation of one method of A interface
abstract class B implements Class A{
public void method3(){System.out.println(“I am in method 4”);}
}

//Creating subclass of abstract class, now we need to provide the implementation of rest of the methods
class M extends B{
public void method1(){System.out.println(“I am in method 1”);}
public void method2(){System.out.println(“I am in method 2”);}

}

//Creating a test class that calls the methods of A interface
class TestClass{
public static void main(String args[]){
A a=new M();
a.method1();
a.method2();
a.method3();

}}

Output-

I am in method 1
I am in method 2
I am in method 3

Its Prashant Chaudhary, I have 10+ years of experience in software test automation, performance & process automation with various commercial and open source tools. This blog shares my experience on the topic of Automation. The content published on my blog is solely mine, it does not express the views of any of my employers (current or previous).
No Comments

Leave a Reply

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

Selenium Basic
1
Step by step selenium – step 3, what is findelement method

Abstract- So far, we have learned how to launch a web browser, entering values in a text box and clicking button. In this post, we will learn about findelement method. Test automation is all about get and set, which means get from web and set into web. Talking more specifically- …

Test Automation
1
What is ITestListner interface and its Use in Selenium

There are several interfaces available in TestNG that allow you to modify TestNG’s behavior or to give test scripts additional strength. These interfaces are broadly called “TestNG Listeners”. Here are a few listeners which are commonly used: 1- IAnnotationTransformer 2- IAnnotationTransformer2 3- IHookable 4- IInvokedMethodListener 5- IMethodInterceptor 6- IReporter 7- …

Test Automation
How to Capture Screenshot in Selenium Webdriver-3 different ways

Abstract– Capturing screenshot is an essential feature of a test automation framework, They help in defect analyses once after test execution is over. In this blog post we will see how to capture screenshot, there are different ways to capture screenshots. Which includes- 1- Capture full Page 2- Capturng full …

Shares