Wednesday, 21 February 2018

Overview of Webservice

What is webservices ?

It's a simple xml based information exchange system, which uses internet for direct interaction between applications.
Components of webservice :
SOAP : Simple object access protocol
UDDI : Universal description and discovery integration.
WSDL :web services descriptive language.
Note : WSDL is a language , used by UDDI.

What is SOAP ?
It is technology which allow communication between different languages. It allow us to pass the data over the internet in easy way.

A simple definition :
SOAP stands for Simple Object Access Protocol.
SOAP can interact with other programming language applications.
It is a just protocol which is XML Based for accessing web services over the internet.
It is recommended by W3C for communication between two application over the network.

Advantage of SOAP :
SOAP has its own security known as WS Security.
Language and platform independent.
Disadvantage of SOAP :
It support only XML format, it has many standards which we have to follow while working with SOAP UI so that the reason it is slow.
It works with WSDL file onle so we can not use other format like JSON, header , Cookies and so on.

What is REST ?
REST stands for Representational State Transfer

It is platform dependent
It support multiple format like Json, HTML, XML, Plain text file too.
It is fast as compared to SOAP.
It is not a protocol like SOAP it is just a architectural design.

How WebServices works ?

A web service enables communication among various applications by using open standards such as HTML, XML, WSDL, and SOAP.
A web service takes the help of −
XML to tag the data
SOAP to transfer a message
WSDL to describe the availability of service.

OR In another way
Used XML for tagging >> Transfer it to SOAP >> WSDL to get the availabilities of services.

A simple definition: A web service is a function that can be accessed by other programs over the web (Http). To clarify a bit, when you create a website in PHP that outputs HTML its target is the browser and by extension the human being reading the page in the browser. A web service is not targeted at humans but rather at other programs.

Example: I can go to, and type in my home address, and see a map of where I live in my browser.
But what if you were writing a computer program where you wanted to take an address and show a pretty map, just like Google maps?
Well, you could write a whole new mapping program from scratch, OR you could call a web service that Google maps provides, send it the address, and it will return a graphical map of the location, which you can display in your program.

API vs WebService

API and web service both used for communication.
The only difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which the third-party vendors can write programs that interface easily with other programs.


1. All Web services are APIs but all APIs are not Web services. as all tigers are cats but not all cats are tiger

2. Web services might not perform all the operations that an API would perform.

3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication whereas API may use any style for communication.

4. A Web service always needs a network for its operation whereas an API doesn’t need a network for its operation.


SOAP is Simple Object Access Protocol
Request and Response > XML Format
Uses Web Services and more secure.

Representational State Transfer,
Each URI is representational of some object.
Uses Http get/post/put/delete and uses XML/json/html format
Totally stateless and light weight than soap
Not a protocol rather a architechtural style.

What is URI ?

URI : Uniform Resource Identifier
Identifyng documents using a short of numbers, letters and symbol.

URL and URN A URN(Uniform Resource Name) ia an internet resource with a name.


WSDL : The web service description language(WSDL) is an XML vocabulary used to describe SOAP-based web services.
WSDL files that we will be using for SOAP based web services only.
It's major elements are :
Definition : root element of all WSDL documents, It defines the name of the web service, declares multiple namespaces used throughout the remainder of the document, and contains all the service elements described here.
Datatype : The data types to be used in the messages are in the form of XML schemas.
Message : It is an abstract definition of the data, in the form of a message presented either as an entire document or as arguments to be mapped to a method invocation.
Binding : It is the concrete protocol and data formats for the operations and messages defined for a particular port type.
Operation : It is the abstract definition of the operation for a message, such as naming a method, message queue, or business process, that will accept and process the message.
Port : It is a combination of a binding and a network address, providing the target address of the service communication.
Service : It is a collection of related end-points encompassing the service definitions in the file; the services map the binding to the port and include any extensibility definitions.

WADL : The web application descrition language(WADL) is an XML vocabulary used to describe RESTful web services and XML vocabulary for expressing the behaviour of HTTP resources.
main porpose to define the contact.

Tuesday, 20 February 2018

HTTP Request and HTTP Response

Hello Friends,

Before starting the API Testing a tester must know what is HTTP Request and HTTP response, so this article mainly cover :
HTTP Request
HTTP Response

The HTTP Protocol :

HTTP : Hypertext Transfer Protocol

The HTTP is an application layer protocol(OSI Model) that allows web-based applications to communicate and exchange data.

OSI Layers are as below:
Presentation Session
Data Link

OSI model in detailed view :

What is HTTP?

The HTTP is the messenger of the web
It is a TCP/IP based protocol
It is used to deliver content for example images, videos, audios, documents etc.
The computer that communicate via the HTTP must speak the http protocol

Three Important things about HTTP

1). HTTP is connectionless means after making the request, the client disconnect from the server, then when the response is ready the server re-establish the connection again and deliver the response.
2). The HTTP can deliver any sort of data, as long as the two computers are able to read it.
3). The HTTP is a stateless means the client and server know about each other just during the current request, it is closes and the two computers want to connect again, they need to provide information to each other anew, and the connection is handled as the very first one.

Key points :

1).The HTTP is a TCP/IP based application layer protocol that allows web based applications to communicate and exchange data.
2).The computers that communicate via the HTTP must speak the http protocol.
3). The http is stateless, connectionless and can deliver any data.
4).We use the http protocol bacause it is a convenient way to quickly and reliably move data on the web.
5). The request response cycle works on the web via http messages.
6). A http message contains three sections the start line, the header and the body.
7).The http request message differs from the http response messages.

Cycle of HTTP Request & Response

HTTP Request :

An HTTP client sends an HTTP request to a server and basically this request is a packet of information.
This packet ave binary data sent by the client to the server.

HTTP Request contains following three things :

1). Request Line
2). zero or more header (General|Request|Entity) fields followed by CRLF
and an empty line(i.e. a line with nothing preceding the CRLF)
indicating the end of header fieds
3). Message body of request (Optionally)

Two HTTP Request Methods:


Two commonly used methods for a request-response between a client and server are: GET and POST.
GET - Requests data from a specified resource
POST - Submits data to be processed to a specified resource

Request line have Request Method, Request URI, HTTP Protocol

Request Header : In the request section, whatever follows Request Line till before Request Body everything is a Header.
Headers are used to pass additional information about the request to the server.

Request Body is the part of the HTTP Request where additional content can be sent to the server.
For example, a file type of JSON or XML.

Let's better understand by below Image :

HTTP Response :

After successfully receiving and interpreting a request message, server responds with a HTTP response message.
This response is the packet of information sent by server to the client.
As like HTTP Request, HTTP Response also have three things :

1).A status Line
2).Zero or more header (Genreal|Response|Entity) fields followed by CRLF
An empty line (i.e. a line with nothing preceding the CRLF)
indicating the end of the header fields
3). Message Body (optionally)

Status line has , HTTP Protocol version, Status code like 200, and Status message as OK,
Response header, Response Header also contains zero or more Header lines. However, it is very uncommon to have zero Headers in the response. Lines just after the Status Line and before the Response Body are all Response Headers lines.
Response Body , Response Body contains the resource data that was requested by the client.
Note: Response Body contains text in JSON format, as one of the Response headers suggested.
can better understood by below image :

HTTP Staus code :

1xx Informational response :
100 Continue
101 Switching Protocol
102 Processing
103 Early Hints

2xx Success :
200 OK
201 Created
202 Accepted
203 Non-Autoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status
208 Already Reorted
226 IM Used

3xx Redirection :
300 Multiple choices
301 Moved Permanently
302 Found
303 see other
304 Not Modified
305 Use Proxy
306 Switch Proxy
307 Temporary Redirect
308 Permanent Redirect

4xx Client errors :
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Payload Too Large
414 URI Too Long
415 Unsupported Media Type
416 Range Not Satisfiable
417 Expectation Failed
418 I'm a teapot
421 Misdirected Request
422 Unprocessable Entity
423 Locked
424 Failed Dependency
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
451 Unavailable For Legal Reasons

5xx Server errors :
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage
508 Loop Detected
510 Not Extended
511 Network Authentication Required

API Testing Overview


Hello Friends,

In this article , i will describe that what is API? what is API Testing? and an overview of API.

What is API? (Application Programming Interface)

API is a software intermediary that use to allow two applications to talk to each other,
basically an API specifies how software components should interact.
It consists of a set of routines, protocols and tools for building the Software Application.
OR in simple words
API essentialy a library of functions, data structure and classes used by the developer to perform a specific task such a drawing a window and posting a comment etc.

Example of API :

Each time when you use an app like Twiiter, Facebook, send an instant message, or check the weather on your phone, you are using an API.

When we use an applicaton on our mobile phone, the application connects to the internet and sends data to a server, then the server retrives that data, interprets it, perform the necessary actions and sends it back to our phone.
The application then interprets that data and presents you with the information you wanted in a readable way.
This is that an API is - all of this happens via API.

Popular API Examples :

Google Maps API : Google Maps APIs lets developes embed Google Maps on weboage using a JavaScript or Flash Interface.

YouTube API : Google's APIs lets developers integrate YouTube videos and functionality into websites or applications.

Twitter APIs: Twitter offers two APIs. The REST API allows developers to access core Twitter data and the Search API provides methods for developers to interact with Twitter Search and trends data.

Amazon Product Advertising API: Amazon's Product Advertising API gives developers access to Amazon's product selection and discovery functionality to advertise Amazon products to monetize a website.

What is API Testing ?

As like other kinds of testing, API testing also is intended to reveal bugs : inconsistencies or deviations from the expected behaviour.
Continuous testing is also very important to make sure it continues to work when the public has access to it.
API testing is one of the most challenging parts of the chain of software and QA testing because it works to assure that our digital lives run in an increasingly seamless and efficient manner.
API testing as a part of integration testing to determine if they meet expectations for functionalit, reliability, performance and security.

let's discuss on Three layer Software Architecture :

Presentation layer: This layer contains the user oriented functionality responsible for managing user interaction with the system, and generally consists of components that provide a common bridge into the core business logic encapsulated in the business layer.

Business layer: This layer implements the core functionality of the system, and encapsulates the relevant business logic. It generally consists of components, some of which may expose service interfaces that other callers can use.

Data layer: This layer provides access to data hosted within the boundaries of the system, and data exposed by other networked systems; perhaps accessed through services.

Api testing is mainly exist on the business logic layer of the software architecture.
Remember : Api testing won't focus on the look and feel of an application.

Important Point : API Testing is not either black box or white box basically its both black and white.

API testing is now considered critical for automation testing because APIs now serve as the primary interface to application logic and because GUI tests are difficult to maintain with the shortrelease cycles and frequent changes commonly used with agile Software Development and Devops.

Types of API testing
API testing typically involves the following practice :
Unit Testing
Functional Testing : Incluse test case definition, execution, validation and regression testing.
Load testing
Runtime error detection : Monitoring an application the execution of automated or manual tests to expose problems such as race conditions, exceptions and resource leaks.
Security testing : Include penetration testing and fuzz testing as well as validation authentication, encryption and access control.
Web UI testing
Interoreability testing -(SOAP only) checking conformance to web services Interoperability profiles.
Compliance testing (SOAP only)

API Architecture

API Call Collector
1). HTTP Header
2). HTTP Request
3). Status code/response code

HTTP header
a) Automatization
b) Response Time

HTTP request
c. GET
g. PUT

Response code like 404 (Not Found), 200(OK) etc.

Types of Web Service

1). SOAP (Simple Object Access Protocol)
2). REST (Representational state transfer)

Popular API Testing Tools :
SWAGGER (Manual API Testing)
API Studio
Amazon webServices

Advantage of API Testing

Test of core functionality
Test Quality
Faster Release
Test coverage with application
Access to application without user interface
Protection from malicious code and breakage
Time Efficiency Vs. Functional and Validation testing
Cost Effective/Reduce Testing cost
Technology independent.. etc

Types of bugs expected :
Wrong status code
API validation
Components (module) not interacting as expected
HTTPS request are not working.

Difference between Unit Testing and API Testing
UNIT Testing API Testing
Owned by development Owned by test
Limited in Scope Broader in scope
Mocked dependencies Mocked and real dependencies
Does it work by itself Does it play well with others
Usually ran before check-in Ran after the build created

API Test Design Principles

Robust automated test cases generally have 5 stages of API test design
1).Setup : Initialize data, create objects, start services etc.
2).Execution : Steps to exercise API or scenario, also logging
3).Verification : Oracles to evaluate execution outcome
Note : Oracles are messages function usally used to compare actual result with expected results
4).Reporting : pass, fail or blocked
5).Clean up : Pre-test state.

Key Points:

API testing benefits both the development and testing organization.
API testing is both a black and white box activity
Find some types of bugs more efficiently but not find all bugs
Doesn't evaluate "look and feel"
Can change focus of GUI automation
Not for everyone.

Approach of API Testing
1).First understand the funcationality of your API program and find the scope of this program.
2). Then simply apply your testing techniques like error guessing, input parameters , boundary value etc.
3). Now time have come to execute your test case & compare the result with expected results.

Tuesday, 13 February 2018

How To Handle Tabs in selenium

Hello Friends,

In this article , i will describe that how to handle the Tabs in selenium.
So we will cover below scearios :

For Video part 1:

Click here

For Video part 2:

Click here

Scenario :1-
Open the browser & enter Url Open a new tab
Hit a url in new tab
perform some operation in new tab
come back to main tab

Scenario :2-
Open the browser & enter Url
click some link which will open the new tab
switch to newly opened tab
perform some operation
come back to main tab
Scenario :3-
Open the browser & enter Url click on link which will open the new tab
switch to newly opened tab
close newly opened tab only
perform some operation in your main tab

So, here we will write some simple code to do these operations :-

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class RealTabdemo
WebDriver driver;
public void g() throws InterruptedException
System.setProperty("", "D:\\Selenium\\Complete selenium\\ChromeDriver\\chromedriver.exe");
driver = new ChromeDriver();
Thread.sleep(3000); }
public void h() throws InterruptedException, AWTException
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
Robot rbt = new Robot();
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"\t");
String originalHandle = driver.getWindowHandle();
ArrayList tabs2 = new ArrayList (driver.getWindowHandles());
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
catch(Exception e)
for(String handle : driver.getWindowHandles())
if (!handle.equals(originalHandle))

Another Example :
Scenarios :
Open the browser & navigate to URL
Open the new Tab by using Robot class
open new URL in new tab
Pass driver control in new tab
Perform some operation in new tab
close the new Tab
pass the driver control back to main parent tab

Here is the sample code, where we will open the browser & hit the URL
Then open a new tab, and open a new Url in new tab
now will perform operation in new tab
close the new tab & come back to parent tab

Another Example :

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Tabtest
WebDriver driver;
public void h() throws InterruptedException
System.setProperty("", "D:\\Selenium\\Complete selenium\\ChromeDriver\\chromedriver.exe");
driver = new ChromeDriver();
public void g() throws AWTException, InterruptedException
Robot robot = new Robot();
String windowhandle = driver.getWindowHandle();
ArrayList tabs = new ArrayList(driver.getWindowHandles());
System.out.println("Total tabs are : " +tabs.size());
driver.switchTo().window((String) tabs.get(1));
@Test(priority = 1)
public void I() throws InterruptedException
String originalHandle = driver.getWindowHandle();
ArrayList tabs2 = new ArrayList(driver.getWindowHandles());
System.out.println("Total tabs are : " +tabs2.size());
driver.switchTo().window((String) tabs2.get(1));
for(String handle : driver.getWindowHandles())
if (!handle.equals(originalHandle))

Tuesday, 6 February 2018

Send Reports Automatically to Email using Maven from Eclipse

Hell Friends,

In this article we will discuss

How to Send Reports Automatically to Email using Maven from Eclipse by Post-Man plugin

For Video :

Click here

This is very simple, you just need to add some plugin & remaining things will be same.
So steps will be as below :
Step 1 : Create a Maven Project.
Step 2 : Add Dependency as below in your POM.xml file.
Step 3 : Update the project.
Step 4 : Convert your Execution file to TestNG xml file & place it in main source folder(if using below plugins).
Step 5 : Set email address & report path.
Step 6 : Now Run your POM.xml file.

To Download the complete plugin in notepad click the below link :

click here

Alternatively, one can copy the below plugin & paste in his Maven Pom.xml file.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<!-- -->
<!-- -->
<id>send a mail</id>
<!-- From Email address -->
<!-- Email subject -->
<subject>Test Automation Report</subject>
<!-- Fail the build if the mail doesnt reach -->
<!-- host -->
<!-- port of the host -->
<!-- Email Authentication(USername and Password) -->
<mailuser>Enter email id here</mailuser>
<mailpassword>Enter password here</mailpassword>
<!-- To Email address -->
<!-- Report directory Path -->
<!-- Report file name -->
<!-- Use Regular Expressions like **/*.html if you want all the html files to send-->

Here is the sample code

package com.lang.Execution;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
public class ReportTest
WebDriver driver;
ExtentReports report;
ExtentTest logger;
public void navigate() throws InterruptedException, IOException
System.setProperty("", "D:\\Selenium\\Complete selenium\\ChromeDriver\\chromedriver.exe");
driver=new ChromeDriver();
report=new ExtentReports("./Reports/TestReport.html");
@Test(priority = 0)
public void title()
logger.log(LogStatus.INFO, "test started ");
System.out.println("Your Title is :" + driver.getTitle());
String title = driver.getTitle();
if(title.equalsIgnoreCase(" Online Software Testing: Software Testing"))
logger.log(LogStatus.PASS, "Test Verified");
logger.log(LogStatus.FAIL, "Test Failed");
//Flush the data to report
@Test(priority = 1)
public void clicklink(){
//Create object for Report with filepath
//report=new ExtentReports("./Reports/TestReport.html");
//Start the test
//Log the status in report
logger.log(LogStatus.INFO, "Test started ");
//Pass the test in report
logger.log(LogStatus.PASS, "Link Verified");
//End the test
//Flush the data to report

Tags :

how to send report through email in selenium webdriver,Sending Selenium Reports through mail,
Advance Selenium Reporting- Selenium Webdriver tutorial How to Send a Report via Email in selenium,
How to generate and send HTML reports using Selenium WebDriverSend Reports Automatically to Email using Maven from Eclipse
Robotically Send Test Reports via Mail Using Maven Postman PluginHow to send Test result to email using maven by postman plugin
how do i send a email test report from maven,How to send an automated email with test reports using Maven and TestNG,

Core Java Interview Questions for Selenium tester

Hell Friends,

In this article we will discuss about Java interview Questions for Selenium Tester :

0.What is Java?
Java is a programming language and computing platform first released by Sun MicroSystems in 1995.

1. What is a JVM?
JVM is Java Virtual Machine which is a run time environment for the compiled java class files.

2. Does Java support multiple inheritance?
Java doesn't support multiple inheritance.

3. What is the most important feature of Java?
Java is a platform independent language.

4. What is difference between Path and Classpath?
Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

5. What are instance variables?
Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.

6. What is a pointer and does Java support pointers?
Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn't support the usage of pointers.

7. What is the return type of the main() method?
Main() method doesn't return anything hence declared void.

8. What are local variables?
Local variables are those which are declared within a block of code like methods. Local variables should be initialized before accessing them.

9. Is Java a pure object oriented language?
Java uses primitive data types and hence is not a pure object oriented language.

10. Is JVM platform independent?
JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor.

11. Can a main() method be overloaded?
Yes. You can have any number of main() methods with different method signature and implementation in the class.

12. What is the base class of all classes?

13. What do you mean by platform independence?
Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).

14. Are arrays primitive data types?
In Java, Arrays are objects.

15. What is the difference between a JDK and a JVM?
JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM.

16. Does the order of public and static declaration matter in main() method?
No. It doesn't matter but void should always come before main().

17. What is the impact of declaring a method as final?
A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

18. Can a class be declared as protected?
A class can't be declared as protected. only methods can be declared as protected.

19. How to define a constant variable in Java?
The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also. static final int PI = 2.14; is an example for constant.

20. Which package is imported by default?
java.lang package is imported by default even without a package declaration.

21. What is the argument of main() method?
main() method accepts an array of String object as argument.

22. Can a source file contain more than one class declaration?
Yes a single source file can contain any number of Class declarations but only one of the class can be declared as public.

23. What is the access scope of a protected method?
A protected method can be accessed by the classes within the same package or by the sub classes of the class in any package.

24. Can a class declared as private be accessed outside it's package?
Not possible.

25. Why is the main() method declared static?
main() method is called by the JVM even before the instantiation of the class hence it is declared as static.

26. What is the purpose of declaring a variable as final?
A final variable's value can't be changed. final variables should be initialized before using them.

27. What is a package?
Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

28. Can a main() method be declared final?
Yes. Any inheriting class will not be able to have it's own default main() method.

29. I don't want my class to be inherited by any other class. What should i do?
You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

30. Should a main() method be compulsorily declared in all java classes?
No not required. main() method should be defined only if the source class is a java application.

31. When will you define a method as static?
When a method needs to be accessed even before the creation of the object of the class then we should declare the method as static.

32. What is the importance of static variable?
static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

33. How is final different from finally and finalize()?
final is a modifier which can be applied to a class or a method or a variable. final class can't be inherited,final method can't be overridden and final variable can't be changed.
finally is an exception handling code section which gets executed whether an exception is raised or not by the try block code segment. finalize() is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.

34. I want to print "Hello" even before main() is executed. How will you achieve that?
Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main() method. And it will be executed only once.

35. Can we declare a static variable inside a method?
Static variables are class level variables and they can't be declared inside a method. If declared, the class will not compile.

36. Can a abstract class be defined without any abstract methods?
Yes it's possible. This is basically to avoid instance creation of the class.

37. Can you give few examples of final classes defined in Java API?
java.lang.String, java.lang.Math are final classes.

38. Can a abstract class be declared final?
Not possible. An abstract class without being inherited is of no use and hence will result in compile time error.

39. Can you create an object of an abstract class?
Not possible. Abstract classes can't be instantiated.

40. What are the restriction imposed on a static method or a static block of code?
A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.

41. Can a Class extend more than one Class?
Not possible. A Class can extend only one class but can implement any number of Interfaces.

42. Class C implements Interface I containing method m1 and m2 declarations. Class C has provided implementation for method m2. Can i create an object of Class C?
No not possible. Class C should provide implementation for all the methods in the Interface I. Since Class C didn't provide implementation for m1 method, it has to be declared as abstract. Abstract classes can't be instantiated.

43. Can a class be defined inside an Interface?
Yes it's possible.

44. Can an Interface extend another Interface?
Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

45. What is use of a abstract variable?
Variables can't be declared as abstract. only classes and methods can be declared as abstract.

46. Can an Interface be defined inside a class?
Yes it's possible.

47. What is an Abstract Class and what is it's purpose?
A Class which doesn't provide complete implementation is defined as an abstract class. Abstract classes enforce abstraction.

48. Can an Interface be final?
Not possible. Doing so so will result in compilation error.

49. Can an Interface implement another Interface?
Interfaces doesn't provide implementation hence a interface cannot implement another interface.

50. Why does Java not support operator overloading?
Operator overloading makes the code very difficult to read and maintain. To maintain code simplicity, Java doesn't support operator overloading.

51. Is there any difference between an argument and a parameter?
While defining methods, you pass variables which you refer as parameters. And when you call these methods and pass values for the variables then they are phrased as arguments.

52. How your program would behave if you declare the main method as private?
It would get compiled correctly but will throw the error "Main method not public." at runtime.

53. Q: What difference you see between pass by reference and pass by value in Java?
Pass by reference indicates, passing the address itself rather than passing the value. Pass by value means is giving a copy of the value.
Example : Actions action = new Actions(driver);

54. Can you compile a Java class successfully without having the main method?
Yes, we can compile, but it won't run. The
method works as the startup function for a Java class, and the JVM calls it for the program execution.

55.What do you make of System, out and in the function System.out.println()?
System -> A predefined final class,
out -> PrintStream object and,
The -> built-in overloaded method of the out object.

56.Q: How would you prove that an array is not null but is empty?
Call the . It will print 0. That suggests that the array is empty. If it would've been null then, it would've thrown a on calling the .

57. Q: What do you understand of Garbage Collection and how to call it explicitly?
If the object is no longer belong to any variable, Java automatically reclaims the memory. This process is known as garbage collection. You can use the method to call it explicitly.
For more :

Click here

Frequently Asked Selenium Interview Questions and aswers

Hell Friends,

In this article we will discuss about basic Selenium interview Questions for Selenium Tester :

0.What is Automation Testing?
When Testing script/cases/tests run by some robot/tool , then it will become automation testing.

1. What is selenium?
A tool, which will automate your web browser.

Friday, 2 February 2018

How to Handle Frames in Selenium

Hell Friends,

In this article i will describe how to handle the frame , we will get the answers of below questions :

For Video :-

Click Here

1). How to switch to Frame
2). How to handle alert/confirmation on frame.
3). How to switch between the frames.
4). How to come back from frame to main window.

I have created a Web page , which have two frames & in first frame there is some alerts/confirmation etc as shown below :-



Scenarios are as :

Navigate to WebPage
Enter the data in text box
Switch to frame 1
Click on alert
Accept the alert
Switch to frame 3
click on webelment
Switch to frame 2.
click on element

Here is sample code
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Framedemo
WebDriver driver;
public void g() throws InterruptedException, IOException
System.setProperty("", "D:\\Selenium\\Complete selenium\\ChromeDriver\\chromedriver.exe");
driver=new ChromeDriver();
@Test(priority = 0)
public void switchframe() throws InterruptedException
driver.findElement(By.xpath("html/body/input")).sendKeys("welcome to way2testing");
List framecount = driver.findElements(By.tagName("iframe"));
System.out.println("Total frames on page are : " + framecount.size());

driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.switchTo().frame(driver.findElement(By.xpath(".//*[@title = 'ifsccode']")));
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);