Total Pageviews

Friday, 24 August 2018

Core java _ one liners


  1. When one object acquires all the properties and behaviors of a parent object, it is known as inheritance
  2. If one task is performed by different ways, it is known as polymorphism.
  3. Highlighting the set of services while hiding the implementation is known as abstraction.
  4. Binding code and data as single unit is known as encapsulation



Boolean vs boolean in Java

Boolean is a wrpper class in java.lang package while boolean is a primitive data type
Boolean provides more methods which can be failrly useful while in case if you want to save memory then use boolean.


//--

A class is a blueprint from which objects are created while an object is an instance of class

//--

There are 8 primitives in Java i.e. byte,short,int,long,float,double,char,boolean. These are not objects. To represent these 8 primitives datatypes in the form of objects
there are 8 classes used. These classes are called as wrapper classes.Those wrapper classes are Byte,Short,Integer,Long,Float,Double,Character,Boolean .
These wrapper classes are present in java.lang package.

Typecasting is of two types implicit type casting and explicit type casting.
In implicit type casting is smaller to bigger like converting byte to short.
Explicit type casting comes when we are converting from bigger to smaller. short to byte. In this there is loss of information.

//--
Autoboxing:
int a = 10;
Integer b = a;  //here compiler internally understands this line as Integer b = Integer.valueOf(a);

Unboxing:
Integer a = new Integer(10);
int b = a;  // here compiler will internally see it as int b = a.intValue();

Comparable meant for default sorting order , comparator meant for customised sorting order

What is invoked first, instance initializer block or constructor?
-- Firstly constructor is invoked , after execution it may seem that instance initialzer was first invoked but actually compiler copies what is there in
instance initialeser block in constructor and then run.


Since method invocation is determined by the JVM not compiler, it is known as runtime polymorphism.

All catch blocks must be ordered from most specific to most general i.e. catch for ArithmeticException must come before catch for Exception .

Test t = new Test();
Test: Class Name
t: Refrence Variable
=: Assignment Operator

//*[not(contains(.,'Certificate'))]

Alerts are blocking in nature, they will not allow any action on webpage if they are present.
Alerts are generally three types:
1>Simple alert: just displays the msg
2>Conformation alert with ok and cancel button
3>prompt alert: prompts the user and ask for yes and not

> The packages whose names are starting with java like 'import java.util.Collections;' will be java packages and the packages whose name are starting with org.openqa.selenium
like import org.openqa.selenium.Alert; will be selenium package.

> Packages is logically organising your java classes.Jar(Java Archive) is physically orgnising your java classes. One Jar can have many java packages.
A library is a collection of jars and a jar is a collection of classes.

Because constructors are not methods and a subclass’ constructor cannot have same name as a superclass’ one, so there’s nothing relates between constructors and overriding.
        Bold this line constructors are not methods 

Abstract class object creation is not possible

Abstract class may contain abstract methods or may not contain abstract methods but it is not possible to create object of Abstract Class

instanciation is nothing but object creation

Is it possible to declare main methods in abstract class or not:  ---Yes you can have main method , it is just that you wont be able to intanciate the abstract class .

Inside abstract class u can declare constructors

Rules and Regulations for
1>Constructor Name class name must be same
2>Constructor must be able to take parameters
3>Constructors are not allowed to return values
4>If u are not declaring constructors then compiler generates 0 arguments constructor.
ex.
class Test{

void m1(){
  system.out.println("m1 method");
}
/*                                              ---------- commented constructor is generated by compiler internally
Test(){
   // empty implementation, no body
}
*/
main(){
Test t = new Test();
t.m1();
}
}
5> If u are not declaring any constructor then only default constructor will be generated by compiler. If suppose u are creating one multiple argument constructor in your
   class and in main method u are creating object of default constructor then compiler will throw error. e.g.
   Class Test{
Test(int arg){
   // empty implementation
}
    main(){
new Test();      // here compiler will throw error stating constructor new Test() is undefined.
new Test(4);
}
   }
 
Advantages of constructor
 > The benefits of constructors are they get executed during their object creation itself. So suppose u want to perform some tasks and want those tasks to get executed
   immediately at the time of object creation then u are going to write those tasks using constructors.


> Serialization in Java is a mechanism of writing the state of an object into a byte stream.
It is mainly used to travel object's state on the network.
Also one of the way to create object in java is using deserialization.


> An exception is an event which disturbs normal flow of program.

>u can put try without catch but u will have to put finally

> Finally block is expected to be clean up block , return is not expected from it.

>Checked exceptions are not propagated while unchecked exceptions are propagated.

> If a class have an entity reference, it is known as Aggregation.

> Wrapper class in java provides the mechanism to convert primitive into object and object into primitive.


> There is only call by value in java, not call by reference. If we call a method passing a value, it is known as call by value.


>>Variables declared inside a static block will be local to that block just like methods and constructors variables.


 
 
 
   

Saturday, 18 August 2018

Core Java

COLLECTIONS

Importance of collections: - 
1>The main objective of collections framework is to represent group of objects as a single entity.
2>In java Collection framework provide very good architecture to store and manipulate the group of objects.
3>Collections are providing flexibility to store, retrieve, and manipulate data.

##All collection framework classes and interfaces are present in java.util package.
##The root interface of Collection framework is Collection.
##For storing and fetching data we use ArrayList but manipulation of data is slow and not efficient but if our primary objective is manipulation then Linkedlist should be used.

Collection vs Collections: - 
Collection is interface it is used to represent group of objects as a single entity.
Collections is utility class it contains methods to perform operations.

Arrays vs Collections: -
Both Arrays and Collections are used to represent group of objects as a single entity, but the differences are as shown below.

Limitations of Arrays 
1) Arrays are used to represent group of objects as a single entity.
2) Arrays are used to store homogeneous data (similar data).
3) Arrays are capable to store primitive & Object type data
4) Arrays are fixed in size, it means once we created array it is not possible to increase & decrease      the  size based on our requirement.
5) With respect to memory arrays are not recommended to use.
6) If you know size in advance arrays are recommended to use because it provide good performance.
7) Arrays does not contain underlying Data structure hence it is not supporting predefined methods.
8) While working with arrays operations (add, remove, update…) are difficult because it is not                 supporting methods.

Advantages of Collections
1) Collections are used to represent group of objects as a single entity.
2) Collections are used to store both heterogeneous data (different type) & homogeneous data.
3) Collections are capable to store only object data.
4) Collections are growable in nature, it means based on our requirement it is possible to increase &    decrease the size.
5) With respect to memory collections are recommended to use.
6) In performance point of view collections will give low performance compare to arrays.
7) Collection classes contains underlying data structure hence it supports predefined methods.
8) Here operations are become easy because collections support predefined methods.

The default capacity of the ArrayList is 10 once it reaches its maximum capacity then size is automatically increased by New capacity = (old capacity*3)/2+1 



Ques. How to get synchronized version of ArrayList?
Ans:- By default ArrayList methods are non synchronized but it is possible to get synchronized version of ArrayList by using fallowing method.
To get synchronized version of List
ArrayList al = new ArrayList(); //non- synchronized version of ArrayList
List l = Collections.synchronizedList(al); // synchronized version of ArrayList
HashSet h = new HashSet(); //non- synchronized version of HashSet
Set h1 = Collections.synchronizedSet(h); // synchronized version of HashSet
HashMap h = new HashMap(); //non- synchronized version of HashMap
Map m = Collections.synchronizedMap(h); // synchronized version of HashMap
TreeSet t = new TreeSet(); //non- synchronized version of TreeSet
SortedSet s = Collections.synchronizedSortedSet(t); // synchronized version of TreeSet
TreeMap t = new TreeMap(); //non- synchronized version of TreeMap
SortedMap s = Collections.synchronizedSortedMap(t); // synchronized version of TreeMap


Retrieving objects of collections classes:- 
We can retrieve the objects from collection classes in 3-ways
1) By using for-each loop.
2) By using get () method.
3) By using cursors(Iterator,ListIterator,Cursors).










Difference between iterator and list iterator:
> Iterator traverses in forward direction only while list iterator traverses in both forward and        backward direction.
> Iterator can be used with list , set or queue while list iterator can only be used with list

Difference between Iterator and Enumeration:
> Iterator can traverse both legacy and non legacy elements while Enumeration can traverse only      legacy elements.
> Iterator is slower than enumeration.

//---------------------------------------------------------------------------------------------------//
Comparable Vs Comparator




//----------------------------------------------------------------------------------------------------//
Anonymous Inner Class





//----------------------------------------------------------------------------------------------------//
toString() method


//-----------------------------------------------------------------------------------------------------//

Singleton Class:
A class is said to be singleton if it limits the number of objects of that class only to one.
Singleton classes are employed extensively in Networking ,jdbc etc.
//------------------------------------------------------------------------------------------------------//
Static keyword

//-------------------------------------------------------------------------------------------------------//
Association:
Association is the relationship between two different classes which are established with their objects.
Aggregation
Inheritence has IS-A relation ship while Aggregation HAS-A relationship.
Class A has instance of Class B is known as aggregation.
If a class has a entity refrence then it is known as Aggregation. It is also used for code reusability.

Composition:
In composition two entities are highly dependent on each other.
It represents part of relationship..
To be contd..

//-------------------------------------------------------------------------------------------------------//
Java Reflection API

Java Reflection is a process of examining or modifying the run time behavior of a class at run time.

Security issues since it can access private data too.
Performance issue since it involves process like scanning of class path.




//--------------------------------------------------------------------------------------------------------//
Generics in Java
Generics is the facility of generic programming in java.Its benifits are type safety ,type casting not required and since its checked at compile time so problem will not happen at run time. It was introduced in java 1.5.
Example:
****Before generics we were using arraylist like this:
List list = new ArrayList();
list.add("hello");
String s = (String)list.get(0); //typecasting
 ****After generics we dont need to type cast the object
List<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0);


Generic class:
A class that can refer to any type is known as generic class

Generic Method:
A generic method can accept any type of argument.

Wild Card in java generics:
The ? mark is known as wild card in generic programming.It means any type.
refer: https://www.javatpoint.com/generics-in-java
//--------------------------------------------------------------------------------------------------------//
Lamda Expression:-
Lambda expression provides clear and consise way to represent one method interface using an expression. It was introduced in Java 8

FYI: Lambda expressions only works with functional interface(functional interface means , interface with just one abstract method in it.)
There are different types of interfaces like functional interface,nested interface,marker interface(i.e. empty interface)

//--------------------------------------------------------------------------------------------------------//
Java Enum
Enum in java represents data type that contains fixed set of constants.

//--------------------------------------------------------------------------------------------------------//
JDK, JRE & JVM
> To Develop and run java application we need to have JDK.
> Just to run java application we need to have JRE.
> In JRE , JVM is responsible for running our program line by line. JVM is a interpretor.

JDK = JRE + Development Tools
JRE = JVM + Library Classes

First compiler converts source file( which contains our classes) into byte code then JVM executes this byte code line by line.

Polymorphism:-
The process of performing tasks in different ways is known as polymorphism.
There are two types of polymorphism:
1) Compile time polymorphism / static binding / early binding
Example :- method overloading
2) Runtime polymorphism /dynamic binding /late binding.
Example :- method overriding
There are three types of overloading in Java
--Method overloading
     #class contains more than one method with same name but different number of arguments or argument type
--Constructor overloading
     #constructor with different number of argument or argument data type
--Operator overloading
     #Java doesnot support operator overloading but one overloaded operator is present implicitly i.e. '+'
10+"gaurav" = 10gaurav
10+"gaurav"+10+20 = 10gaurav1020
10+"gaurav"+(10+20)=10gaurav30
 

 
Rules for overriding in Java:-
1> While overriding overridden method signature and overriding method signature must be same.
2> While overriding overridden method return type and overriding method return type must be same.
3> It is possible to change return type of method by using covariant return type.
4> It is not possible to override final methods in java.
   
   Just for Info.
   # Final class variables are not a final but final class methods are final.
   
5> Static method overriding is not possible.
6> It is not possible to override private methods.Private methods are not visible in child classes.
7> Reducing permission while overriding is not possible in java.Permission can either be at same level or in increasing order.
   
   example:
   
   Class Parent{
void m1(){       // here it is having default permission
}
   }
   
   Class child extends Parent{
  public void m1(){     // here we have increased permission. If instead of public we gave private then it would have thrown compile time error
  
  }
   }
   
   Just for Info.
   Access modifire perfmission:
   
   Public       : variable , method , class     : Any package can access
   Protected  : variable , method                : With in package and outside package by child class only
   Private      : variable , method                : With in class only
   Default     : variable , method , class     : With in package 
   
Abstraction: 
--The process of highlighting the set of services and hiding the implementation is known as Abstraction.
--We achive abstration by using abstract classes (0-100%) and interfaces(100%);
--We can declare class as abstract even if it doesnot have abstract methods.
--We can not create object of abstract class.
e.g. 
abstract Class A{         // abstract class
abstract void m1();   // abstract method
void m2(){            // non abstract method
}
}
Ques: How to prevent object creation of class?
Ans:  Declare the class as abstract class to prevent object creation.

Ques: How to prevent inheritence?
Ans: Declare the class as final.

Ques: How to prevent overriding?
Ans: Declare the method as final.

--Inside abstract class we can declare constructors
--Interface methods are by default public.



Encapsulation:-
The process of binding code and data togeather as single unit is known as encapsulation.

Just for info.
-- Bean class contains data,getters and setters method
-- A class is said to be tightly encapsulated if and only if, all the data members(variables) of that class is declared as private.

Ques: System.out.println();
Ans:  System  :   Class present in java.lang package
      out     :   Static variable present in System class of type print stream
  println :   method present in print stream class
  
  
Interfaces:-
Interfaces are extension of abstract classes and contains abstract methods.

-- By default interface methods are public and abstract.
-- If we want to declare only few methods of interface then we will have to declare that class as abstract in which we are implementing interface.
-- In java one class can only extend one class at a time but interface can extend multiple interfaces at a time

Nested Interfaces:

   interface It1(){
interface It2(){
void m1();
}
   }
   
   Class Test implements It1.It2{
public void m1(){
syso("");
}
   }
   
-- It is possible to declare interface inside class also.
-- Interface is by default abstract
-- Interface methods are by default public and abstract
-- Interface variables are by default public static final.

Scope of variables in Java:
Variables are of three types in Java
1>Instance variable
2>Local Varibale
3>Argument Variables

Instance Variables: Instance variables are those which belong to class itself and not in any method or constructor of class.
  Scope: Scope of these variables are determined by the access specifier that is applied to these variables.
  Lifetime: Life time of these variables are same as the life time of of object to which it belongs to.
  
Argument Variables: These are variables which are defined in the header of method or constructor itself.
  Scope: Scope is limited to method or constructor in which they are defined.
  Lifetime: Life time is limited to time in which method or constructor keeps executing.
  
Local Variables: Local variables are those which are defined inside body of method or constructor.
  Scope and lifetime is limited to method itself.
  
  [FYI: Access specifier can only be applied to instance variable not to local or argument variable, if you will try to apply access specifier to local or argument variable
        compiler will throw error stating only final is permitted]
  
  
  
Just for info.
Objects once created do not exist forever.They are destroyed by garbage collector when there are no more refrence to that object.

//--------------------------------------------------------------------------------------------------//

Coupling in Java:

There are two types of coupling in java.
1> Tight Coupling
2> Loose Coupling

Tight Coupling
Tight Couple means classes and objects are dependent on each other.


Loose Coupling
Loose Coupling means classes and objects have minimal dependency on each other.


String Vs String Buffer Vs String Builder
  • Objects of String are immutable, and objects of StringBuffer and StringBuilder are mutable.
  • StringBuffer and StringBuilder are similar, but StringBuilder is faster and preferred over StringBuffer for single threaded program. If thread safety is needed, then StringBuffer is used.
  • The objects created as strings are stored in constant string pool while the objects created using buffer/builder are stored in heap.

Stack vs Heap
To be cond..


Method Hiding in Java:
Static method are bounded with class while instance method are bounded with object.
In Java it is possible to override only instance methods not static methods.

When we try to override static method concept of method hiding comes in picture.

Method hiding means :- Subclass has defined a method with same signature as superclass, and method of superclass is hidden by subclass. It means, the version of method that is executed will not be determined by the object that is used to invoke it.In fact it will be determined by the type of reference variable used to invoke the method

Example:



Ques: Why cant static method be overridden?
Ans: Because static methods are resolved statically i.e. at compile time based on the class they are called on, not dynamically as in the case with instance methods which are resolved polymorphically based on run type of object.

FYI: Static methods should always be accessed in static way i.e. name of class followed by name of method.




Ques: Different Ways of creating object in java.
Ans:



Ques: Difference between global and static global variable
Ans: 


Ques: Create your own ArrayList
Ans:







Thursday, 9 August 2018

BackEnd Automation

/********************Fire command from windows machine to windows VM************************************/
// in order to fire commands from windows machine to windows vm we can use Psexec
// more details are available at https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
//or u can search google for psexec tutorial
/*******************************************************************************************************/

/********************Fire command from Linux machine to Windows VM************************************/
// u can use winexe to fire commands from linux machine to Windows VM
/*****************************************************************************************************/

/*********************Copy files from Windows machine to another windows machine**********************/
// one way to do this is to create a bat file with commands like below
net use "\\192.168.3.42\c$" Sanovi123 /user:Administrator"       

// in above command net use is a Command Prompt command that's used to connect to, remove, and configure connections to shared resources,
//like mapped drives and network printers. The net use command is one of many net commands like net send, net time, net user, net view, etc.
//192.168.3.42 is IP of VM Sanovi123 is password and Administrator is user name

xcopy C:\Users\IBM_ADMIN\sahi_pro\userdata\scripts\RO_Automation\utility\Sfr \\192.168.3.42\c$\Sfr /s /i /Y

// in above command xcopy is the command to copy files from one location to another location
// first location is the source and second location is destination and then the /s /i /Y are switches

echo EXIT CODE : %errorlevel% > SfrCopyExitCode.txt

// above line is going to create a text file at source with the commands exit code

net use "\\192.168.3.42\c$"  /delete

// once our work is done we delete the connection created


/********************Copy files from Windows machine to Linux machine********************************/
//to do this we can use pscp tool to transfer file from windows to linux or from linux to windows
//create a bat file with commands like below

cd C:\Users\IBM_ADMIN\sahi_pro\userdata\scripts\RO_Automation\tools\Pscp
// first cd the path where Pscp tool is kept
pscp.exe  -scp -pw Sanovi123$ -r sanovi@192.168.2.142:/opt/panaces_JY_Auto/workflows/MSSQL/MSSQLLogPFR/ C:\Users\IBM_ADMIN\sahi_pro\userdata\MSSQL\MSSQLLogPFR/
//sanovi is the user name of linux VM and Sanovi123$ is the password , -r is the switch for recursion
//     /opt/panaces_JY_Auto/workflows/MSSQL/MSSQLLogPFR/  is the source path from where to copy the files
//   C:\Users\IBM_ADMIN\sahi_pro\userdata\MSSQL\MSSQLLogPFR/   is the destination path

// so it is going to copy files from linux to your local windows machine,
// suppose u want to copy files from windows to linux then just reverse the source and destination path
echo EXIT CODE : %errorlevel% > PscpCopyExitCode.txt

//*****************Copy files from Linux to Linux************//
//Use scp command in linux
//sudo scp -r /opt/softwares/tomcat7 sanovi@192.168.20.30:/tmp/G2


// for updating contents of file use sed tool


//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//to fire command from:
Windows to Windows use : Psexec
Windows to Linux use      : JSCH jar or ganymed
Linux to Windows use      : winexe

to copy files from:
Windows to Windows use : netuse and xcopy (windows cmd line tools)
Windows to Linux use      : Pscp tool
Linux to Windows use      : Pscp tool
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//












Regex Examples.......


1.
Regex: [0-9]+.
100.Explain the Selenium Architecture.

2.
Test["1"]
[A-Za-z\[\]"0-9]

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Wednesday, 8 August 2018

Selenium Interview Questions


Explain the Selenium Architecture
There are four levels the way selenium works,
First layer is LANGUAGE BINDINGS and it can be any language like JAVA, C#, Python, Ruby etc.
Second layer is WEBDRIVER API, the corresponding java code issues command to webdriver api,
Third layer webdriver api talks to webrowser driver (web browser driver can be any driver chrome driver, Firefox driver) in common json wire protocol, the wire protocol is basically a RESTful web service over HTTP, implemented in request/response pairs of “commands” and “responses”. So, we can send HTTP requests, such as, GET, POST, PUT etc. to the driver server.
In Fourth layer these driver servers perform the commands over actual browser.


Difference between Selenium-IDE & Selenium RC, WebDriver
Selenium comes in the package of three i.e. Selenium IDE, Webdriver/RC & Grid. Selenium IDE is just a record and playback utility. In selenium RC we must launch a separate application called selenium remote control server which acts as a middleman between u and browser. When selenium server is started it injects java script program called selenium core in browser (like SAHI tool does, if u have worked with SAHI). Once injected selenium core receives instruction from selenium RC server and executes them as JavaScript commands on browser. Webdriver on the other hand takes native support of browser to perform automation. Webdriver is faster than selenium RC as it talks directly to browser. Selenium RC has in built support for reporting while in webdriver you must manage it by yourself.
Just draw backs of webdriver is it does not support new browsers and automatically does not generate results




Difference between WebDriver driver = new Firefox Driver() and FirefoxDriver driver = new FirefoxDriver()  or
Why we upcast a browser driver class object to WebDriver type?
WebDriver Interface is super interface (Not super most) of every browser driver classes like ChromeDriver , FirefoxDriver etc. And as per java concept, a super class/interface reference can hold a its sub class object but vice versa is not possible. 
We can write like FirefoxDriver driver = new FirefoxDriver () but suppose new browser comes in picture then in that case we will have to declare new reference variable to new browser class.

Difference between get (), navigate().to()
get ():
1. Waits till complete page loads.
2. cannot move forward & backward in the browser.
Navigate.to () :
1. Will not wait until the page loads, you can feel this experience only if page takes time to load, like more number of images or ajax calls etc.
2. can move forward & backward in the browser.

What is API , where it is being used
An API is an interface your application library is exposed to another application/library to take advantage of your functionality. Software programs talk to each other using api.
[ A jar file is a zipped collection of java classes and other files like text, images etc. with .jar extension]

Difference between quit () & close()
webDriver.Close(): Close the browser window that the driver has focus of
webDriver.Quit(): Calls Dispose (),Closes all browser windows and safely ends the session
webDriver.Dispose(): This is webdriver's internal method. Closes all browser windows and safely ends the session

 How to maximize & minimize the browser
driver.manage().window().maximize();   // to maximize browser
There is no native support in selenium to minimize the browser, but we can set position in such a way that it is minimized like this:
driver.manage().window().setPosition(new Point(-2000, 0)); You can check browser position and select the size from any online services like https://browsersize.com/ etc.

FYI#1: To set any size of the browser :
1> Make the browser of that size
2> Presss cntrl+Shift+J to open its java script console
3> fire java script commands like window.outerHeight or window.outerWidth to see the height and            width on browser console.
4> Now u can give same position like 
      driver.manage().window().setPosition(new Point(pt1,pt2));

FYI#2:




What is Webdriver “interface” or Class
Consider the statement like WebDriver driver = new FirefoxDriver();
WebDriver is an public interface, we just define a reference variable i.e. driver whose type is interface. Now any object we assign to it must be an instance of class i.e. Firefox Class which implements that interface.
We can write like FirefoxDriver driver = new FirefoxDriver ();  , but in that case suppose we need to use another browser then we will have to create another object variable for that browser, so it’s better to write like WebDriver driver = new FirefoxDriver().
So, the question comes why do we need interface in case of Selenium webdriver? If we look at selenium architecture then we can see that selenium talks to browser in their native language, so suppose webdriver is made a class file and all the methods are defined to test an application using that browser (keep this point in mind that every browser can have different way of handling popup, frames etc.),so by the time I finish up and plan for releasing in the market a newer version of browser might come and will spoil all the efforts and this is for one browser I might have to write method definitions for all the browsers.
So, a better way can be I write an interface and send it to all browser companies to take care of my abstract methods and provide implementation inside Webdriver that would be a most convenient option.
 That’s where you have separate class files for FirefoxDriver, ChromeDriver etc. And these will implement the abstract methods of WebDriver interface in their way.

 What is Super interface for WebDriver
An interface is a guarantee that a class will implement it. When an interface is implemented then it becomes super interface of what extended or implemented it.
If class C implements interface B, and interface B extends interface A, then A is a Super interface to B and B is a Super interface for C.
Now if we look at webdriver’s architecture (http://makeseleniumeasy.com/2017/04/02/hierarchy-of-selenium-classes-and-interfaces/) SearchContext is the superinterface and it has two abstrat methods findelement and findelements.

What is WebElement & explain all the methods available in WebElement
WebElement is a html element, html documents are written in start and end tag and the content in between. Some of the methods of WebElement are click, clear, equals, findelement, findelements,getAttribute, getCSSValue,getLocation, getScreenShotAs etc.

How many locators are available in Webdriver & which locator is preferred
There are 8 locators in selenium i.e. id, name, className, tagName, linkText, partiallinktext, cssSelector and xpath . Out of these, Id is the fastest but we cannot get id for each and every element.
Between CSS and Xpath if we compare CSS is faster and readable but backward traversing and forward traversing can’t be done with it also older browser does not support all features of CSS.

How to check whether object is available in GUI 
 WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.
isDisplayed(), isSelected() & isEnabled()

How to check the text from the UI
driver.getPageSource().contains("Text which you looking for");
driver.findElement(By.xpath("")).getText();

How to capture color, height, width, font–size of the Element
driver.findElement(By.xpath()).getCssValue("color")

How to get the Location of the Webelement
WebElement Image = driver.findElement(By.xpath("//img[@border='0']"));
Point pt = Image.getLocation();
int xcordi = pt.getX();
int ycordi = pt.getY();

FYI: Here WebElement is an interface and Point is a JavaClass. We are passing 

How to check whether object is selected or not ?
driver.findElement(By.id("26110162")).isSelected();   OR   driver.findElement(By.id("26110162")).getAttribute("checked") == true

How to check whether object is enabled in GUI
driver.findElement(By.id("gbqfb")).isEnabled();
How to delete All Cookies
driver.manage().deleteCookieNamed("_ut"); or driver.manage().deleteAllCookies();


Do we use any constructor in webdriver


How to compare Image
Some third party tools like Sikuli, Ashot, image comparison jar etc..

How to get the WebElement height & width
WebElement ele = driver.findElement(By.xpath("//img[@id='hplogo']"));
Dimension d = ele.getSize();
System.out.println(d.height);
System.out.println(d.getWidth());   

What is Synchronization
Synchronization is a mechanism which involves more than one component to work parallel with each other.
Generally in test automation we have two components
    1>AUT
    2>Test Automation Tool
Both these components have their own speed. AUT will have its own processing speed and automation tool will have its own execution speed. We should write our scripts in such a way that both the components should move with same and desired speed, so that we will not encounter "Element Not Found" errors which will consume time again in debugging.
Synchronization can be classified into two categories:
1. Unconditional --- Wait(), Thread.Sleep()
 2. Conditional Synchronization --- Explicit Wait, Implicit wait, fluent wait
               
How to handle Synchronization wait available in Webdriver
Can be handled with explicit or implicit wait

Which wait statement will be used to wait till page load
fluent wait, implicit wait

How to handle dynamic object
With relative xpath

Difference between thread wait , implicitly wait , explicitly wait
Thread.Sleep() is hardcoded wait, we should avoid it as much as possible in automation

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time(the implicit wait polling time is around 250 milli seconds) when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
So, in a way, you can call it a global wait.
To use implicit wait, you need to type the following line in your code.

WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://somedomain/url_that_delays_loading");
WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement"));

WARNING: Mixing implicit and explicit waits. Doing so can cause unpredictable wait times. For example setting an implicit wait of 10 seconds and an explicit wait of 15 seconds, could cause a timeout to occur after 20 seconds.Remember it has to be used just once in your code.

The limitation of implicit wait is the fact that it only checks for the presence of web elements. To tackle with the shortcomings of Implicit Wait you can make use of Explicit Wait. Remember you can use both implicit and explicit wait at the same time or them individually. No issues there!
With Explicit wait command in Selenium Webdriver, you can layer your waiting period with certain conditions. Until those conditions are met, the waiting will keep happening, and the control will not go to the next statement.
There is this ‘ExpectedConditions’ class which retains some predefined conditions that you can use to guarantee a proper waiting duration until your element is loaded. That way you can handle the individual element loading issues.
We should use explicit wait where websites make use of Ajax to load dynamic info.

WebDriverWait wait = new WebDriverWait(WebDriver driver, long timeOutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(“xpathInfo”));
//......................................................................................................................................................//

We can achieve same fluent wait effect using this Explicit wait, just pass sleep time as well in argument.It will act as polling time of fluent wait.
Read: https://stackoverflow.com/questions/48336948/how-to-use-built-in-expectedconditions-with-fluentwait

//......................................................................................................................................................//
Fluent Wait is similar to Explicit Wait only difference being, it lets you create your own conditions, unlike Explicit Wait that used to come with its own predefined conditions.
It implements Wait Interface.Here we have a concept called polling, which is nothing but a repetitive visitation of your condition to ensure whether it is met or not.
FYI:1 The main difference between explicit wait and fluent wait is that you can Ignore specific types of exception while waiting such as NoSuchElementExceptions while searching for an element on the page.
FYI:2 A Function is a generic interface which asks you to implement apply or equals method


Page Load timeout: We can set the amount of time to wait for a page load to complete before throwing an error.
e.g. driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
Once added in the script, the WebDriver instance waits for 20 seconds for every page to get loaded before throwing an exception. If the page is not loaded in 20 seconds of time, then it throws TimedOutException at run time.

Script timeout : We can set the amount of time to wait for an asynchronous script to finish execution before throwing any error.
e.g. driver.manage().timeouts().setScriptTimeout(20, TimeUnit.SECONDS);
Once added in the script, the WebDriver instance waits for 20 seconds for every asynchronous script to get executed on the web page before throwing an exception.
If the timeout is negative, then the script will be allowed to run indefinitely.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
How to handle dropdown
Using Select Class in Selenium
Select oSelect = new Select(driver.findElement(By.id("yy_date_8")));
oSelect.selectByVisibleText("xza");
  
List out all methods available in Select class
deselectByIndex(int index)
deselectByValue(java.lang.String value)
deselectByVisibleText(java.lang.String text)
getAllSelectedOptions()
getFirstSelectedOption() 
getOptions()
isMultiple()
selectByIndex(int index)
selectByValue(java.lang.String value)
selectByVisibleText(java.lang.String text)

How to capture all the value from the dropdown
WebElement selectElement = driver.findElement(By.id("s");
Select select = new Select(selectElement);
List<WebElement> allOptions = select.getOptions();

How to capture only Selected value from the dropdown
Select sel = new Select(driver.findElement(By.id("")));
List<WebElement> alloption = sel.getOptions();
for (WebElement webElement : alloption) {
boolean check=webElement.isSelected();
if(check==true) {
System.out.println("selected elements : "+webElement.getText());
   }
}

How to capture only non-selected value from the dropdown
Select sel = new Select(driver.findElement(By.id("")));
List<WebElement> alloption = sel.getOptions();
for (WebElement webElement : alloption) {
boolean check=webElement.isSelected();
if(check==false) {
System.out.println("selected elements : "+webElement.getText());
How to multiselect value from the dropdown
Select selectElement = new Select(driver.findElement(By.Id("pr")));
if (selectElement.isMultiple()) {
List<WebElement> options = selectElement.getOptions();
for (WebElement we : options) {
we.selectByVisibleText(we.getText());
}
} else {
 log();
 }

How to select all the similar value from the dropdown e.g. we have multiSelect dropdown, like automation testing , manual testing , sql testing , java , we should all the option which contains “testing” word
There is no built-in way to match a select option by regex.We'll have to iterate over options and check each of them:
Select selectElement = new Select(driver.findElement(By.Id("pr")));
if (selectElement.isMultiple()) {
List<WebElement> options = selectElement.getOptions();
for (WebElement we : options) {
 if(we.getText().contains("testing")){
we.selectByVisibleText(we.getText());
 }     
}
} else {
}


How to work with custom select dropdown/ auto suggest dropDown
We will have to use dynamic xpath to select from auto suggest drop down

How to take mouse over operation on the element
By using action class
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
WebElement toolTipElement = driver.findElement(By.cssSelector(".ui-tooltip"));
// To get the tool tip text
String toolTipText = toolTipElement.getText();

How to perform keyboard operation
Handling special keyboard and mouse events are done using the Advanced User Interactions API. It contains the Actions and the Action classes or by using Robot Class of Java

How to perform “control+c”


Difference between build() & perform()
actions.moveToElement("xpth").perform();
actions.moveToElement("xpth").build().perform();
In above scenario it won’t make difference using both. The difference occurs at place when we have multiple actions to be performed like below:
Actions builder = new Actions(driver);
builder.clickAndHold(element1).clickAndHold(element2).build().perform();
In the above code we are performing more than one operations so we have to use build() to compile all the actions into a single step. Thus build () method is used compile all the listed actions into a single step. We use build () when we are performing sequence of operations and no need to use build() , if we are performing single action.

How to perform drogAndDrop Operation
Using Action class
WebElement From = driver.findElement(By.xpath("//*"));
WebElement To = driver.findElement(By.xpath("//*"));
Actions action = new Actions(driver);
action.clickAndHold(From).moveToElement(To).release(To).build().perform();

How to perform rightClick operation
We can use built in method 'contextClick' of action class, later this action is followed by pressing up/down arrow keys and enter key to select desired context menu.
Actions action = new Actions(driver);
WebElement element = driver.findElement(By.id("elementId"));
action.contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).perform();
               
How to work with new Tab, new Browser-window
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");

How to work with new Tab, new Browser-window with our GetWindowHandles() methods
String winHandleBefore = driver.getWindowHandle();
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
// Perform the actions on new window, Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);

How to handle Alert popup
Alert alert = driver.switchTo().alert();
alert.accept();

How to work Calendar Pop-up
We will create a method in which I will pass date as an argument, I will be using dynamic xpath which will be used to navigate through picker.

How to work with advertisement popup
An advertisement popup can be an alert, an ad in iframe or/and an ad in new window.
So if its alert then driver.switchTo("alert").accept, if its add in iframe then.
driver.switchTo.frame(driver.findElement(By.id("")));
driver.findElement(By.id("")).click(); //Close Ad
 driver.switchTo().defaultContent(); // Return to main window
if add is in a new window then.            
String mainWinHandle = driver.getWindowHandle(); // Get your main window
String subWinHandle = null;
Set<String> allHandle = driver.getWindowHandles(); // Fetch all handles
Iterator<String> iterator = allHandle.iterator();
                while (iterator.hasNext()){
                                subWindowHandler = iterator.next();
                }
driver.switchTo().window(subWindowHandler); // switch to popup
driver.switchTo().window(parentWindowHandler);      


How to work with SSL pop-up
SSL : Secure Socket Layer
SSL Certificate Error Handling in Firefox
For handling SSL certificate error in Firefox, we need to use desired capabilities of Selenium Webdriver and follow the following steps.
Step 1): First we need to create a new firefox profile say "myProfile".Google the steps to create firefox profile if u dont know.
Step 2): Now access myProfile in the script as below and create the FirefoxProfile object.
ProfilesIni prof = new ProfilesIni()                                                    
FirefoxProfile ffProfile= prof.getProfile ("myProfile")
Step 3): Now we need to set "setAcceptUntrustedCertificates" and "setAssumeUntrustedCertificateIssuer" properties in the Fire Fox profile.
ffProfile.setAcceptUntrustedCertificates(true)
ffProfile.setAssumeUntrustedCertificateIssuer(false)
Step 4): Now use the FireFox profile in the FireFox driver object.
WebDriver driver = new FirefoxDriver (ffProfile)
SSL Certificate Error Handling in Chrome
For handling SSL error in Chrome, we need to use desired capabilities of Selenium Webdriver. The below code will help to accept all the SSL certificate in chrome, and the user will not receive any SSL certificate related error using this code.
We need to create instance of DesiredCapabilities class as below: -
DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ()      
handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true)
WebDriver driver = new ChromeDriver (handlSSLErr);
For IE we will be doing same way by desired capabilities.
 How to File Download PopUP
We can do this using firefoxprofile/desired capabilities
For detailed explanation :  https://www.seleniumeasy.com/selenium-tutorials/how-to-download-a-file-with-webdriver
               
How to handle File Upload Pop-up using AutoIT
We need to write script to upload file so we will use some method of AutoIt.
Each method will have some own functionality
ControlFocus-  This will give focus on the window
ControlSetText-This will set the file path
ControlClick-  This will click on button
Write script using above three methods and save it in au3 format. Then convert it to exe files using autoit inbuilt tool. Now write below line in your selenium script .
Runtime.getRuntime().exec("PATH OF YOUR SCRIPT");


How to Handle File Upload Pop-up using ROBOT class
If we are working with AutoIT, sikuli and all we will have to use some extrafiles, jars etc. (because suppose u are using autoIT then first u will write steps for uploading file afdter saving it , it will be in au3 format, then u will have to convert it in exe format and lastly you will have to call it in your script) but with the use of Robot Class these things are not there.
Robot robot = new Robot();
driver.findElement(By.id("")).click();
robot.setAutoDelay(2000);
StringSelection selection = new StringSelection("D:\\Selenium\\Clean.bat");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection,null);    //this is for setting contents in clip board
robot.setAutoDelay(1000);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
robot.setAutoDelay(1000);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
How to Handle Browser Scroll-bar
Using JavaScript executor
JavascriptExecutor js = (JavascriptExecutor) driver; 
js.executeScript("window.scrollBy(0,1000)");               //scroll the page by 1000 pixels, the syntax of scrollby method is like executeScript("window.scrollBy(x-pixels,y-pixels)");
//To scroll down the web page by the visibility of the element.
WebElement ele = driver.findElement(By.linkText(""));
//This will scroll the page till the element is found                      
js.executeScript("arguments[0].scrollIntoView();", ele);
arguments[0] is a reference to the arguments you pass in. In this case the index is 0 because you're passing in the element reference as the 0th argument in the executeScript call the parameter after the String containing the script
               
How to execute java-script
refer above answer
JavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver.
JavaScriptExecutor provides two methods "executescript" & "executeAsyncScript"

How to work with frame-Window
Int size = driver.findElements(By.tagName("iframe")).size();
driver.switchTo().frame(0);

How to Work with nested Frame
We will write a method using recursion, it is going to find out all the frames and then switch into frame by the name of argument passed.

How many ways to work with frame
U can switch to frame by using index, name, id or WebElement

How to work frames, when frame does not have id & @name attribute
We will switch into it by index

What is Illegal State Exception
The root cause of java.lang.illegalstateexception is we have not specified the path of the driver with the system property. Until you do not specify, driver details Selenium Webdriver will throw java.lang.illegalstateexception. To solve this just correct the driver path in system property.
NoSuchElementException:- This exception occurs when WebDriver is unable to identify the elements during run time. Due to wrong selector or selector, which is, not exist. ElementNotVisibleException:- Hidden Elements, which has presence in DOM and it, is not visible. Visibility means the height and width should be greater than zero.
Hidden Elements are defined in HTML using of type=”hidden”.
Check page source element attribute is not hidden
NoSuchFrameException:- This Exception occurs when the driver is switching to an invalid frame, which is not available.
NoAlertPresentException:- This Exception occurs when the driver is switching to an invalid Alert, which is not available.
NoSuchWindowException:- This Exception occurs when the driver is switching to an invalid Window, which is not available.
WebDriverException:- This Exception occurs when the driver is performing the action after immediately closing the browser.
SessionNotFoundException:- This Exception occurs when the driver is performing the action after immediately quitting the browser.
StaleElementReferenceException:- This Exception occurs because of below two reasons:-
            1 -The element has been deleted entirely.
                2- The element is no longer attached to the DOM.
To solve this you have to just refresh and loop over 'cause some times it takes while to attach element to DOM


How to work with IE , Chrome browser
System.setProperty("webdriver.ie.driver", "pathofchromedriver\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.manage().window().maximize();

How to write xpath in IE & chrome browser

What is framework , Explain types of framework
Data driven , keyword driven, hybrid, bdd

Which framework you have used& WHY?

Explain framework, with components

What is TestNG, why it is required
Unit testing framework Tool, used for parallel , grouping , parallel execution , Assertion , HTML Report

With OUT TESTNG, what all the challenges you faced
Without TestNG we will have to write code for everything like reporting, retry failed TCs, parallel execution etc. which TestNG framework gives us by default

Why TestNG, Why not JUNIT
Parallel execution is not possible with Junit and there are other annotation advantages over Junit like 1. Additional annotation 2. HTML reporting 3. Grouping 4. Parameterization 5. Support both java, .net
               
What is Annotation, explain all the annotation with real time EG:
      @beforeClass                  // global config like Launch browser
      @AfterClass                   // close browser
      @beforeMethod           // login
      @AfterMEthod             // logout
      @test                             // actual test script



What is the use @beforeTest, @afterTest in testing
@BeforTest will be executed, Before executing all the <Classes> available with Test-Runner. RealTime usage: in case of cross browser parallel execution, we do use before test annotation to set the browser

What is the use @beforeSuite, @afterSuite in testing
@BeforeSuite annotated method represents an event before the suite starts, so all the @BeforeSuite methods will be executed before the first test declared within the test element is invoked.

Explain the hierarchy of testNG annotation
BeforeSuite, BeforeTest, BeforeClass, BeforeMethod, Test, AfterMethod, AfterClass, AfterTest, AfterSuite

What is batch execution & how to achieve batch execution
Batch execution is the execution of tests using windows batch file. In order to achive batch execution we need to have testNG.xml file which contains classes to be executed          and we will be invoking this xml using a bat file. Your testNG.xml will look something like this:
    
       
           

            Now to run we just must invoke this xml using bat file.
               

What is grouping execution,& how to achieve group execution
use group annotation before tests like below:

Now create a testNG xml and specify this -Regression- group there

Now run this xml run as testNGtest

FYI:



What is parallel execution & how to achieve parallel execution

How to achieve CROSS browser testing using Selenium
Pass ‘Browser Type’ as parameters using TestNG annotations to the before method of the TestNG class. This method will launch only the browser, which will be provided as parameter.
like @Parameters("browser") in test case and in testNg xml define parameter like
<parameter name="browser" value="firefox" />


How to disable the testing test scripts
@test(enabled=false)

 How to execute same test with multiple times
We will use annotation like this and @test(invocationCount=10), in order to parameterize this we will have to use IAnnotationTransformer listner.

What is ASSERTION, & how many assertion you used in real-time selenium testscripts , explain with real time examples
Assert.assertEquals(“actcomNAme”, “expComNAme”)
Assert.assertTrute(logoStatus)

What is @parameter annotation in testNG , how to send parameter to testNG test
@parameter is used to parameterize the test. we will call it in test and define it in testNG xml.

How to execute same test with multiple data
@dataprrovider
example
   
        
When it will be run in console it will run twice and display
  testuser_1,Test@123
  testuser_2,Test@123
 
What is the @Listner annotation in TestNG
TestNG provide many listeners which are Java Interfaces. Listeners gives us flexibility to modify default TestNG behaviours. By using TestNG listeners 'ITestListener' or 'IAnnotationTransformer'
 we can change the default behaviour write our own implementation when a Test fails or Skips,invokes etc.
Let us take example of test case invoking. Suppose we want to run a particular test case multiple times then we can use @test(invocationCount=10) annotation before any test.
Now suppose we want to pass this 10 count from outside, then in that case we will have to modify default behavior of @test annotation.
So suppose your testNG test looks like this
            @Test(invocationCount = 2)
             
            public void testCase1() throws Exception {
                        System.out.println("Listner implementation example");
            }
           
            now we will have to write a class which alters default behaviour of this @test
            public class MyTransformer implements IAnnotationTransformer {
            @Override
            public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
            if ("testCase1".equals(testMethod.getName())) {
                 annotation.setInvocationCount(3);         // We can pass this 3 from properties file or xml file from outside
               }
               }
            }
           
            now we will have to put line in our xml for listners
            <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
            <suite name="Parallel test suite" parallel="methods" thread-count="2">
                        <listeners>
                                    <listener class-name="automationPackage.MyTransformer"/>
                        </listeners>
                        <test name="Regression 1">
                        <classes>
                        <class name="automationPackage.TestNG"/>
                                </classes>
                        </test>
            </suite>
           
            Run this suite as test NG test , it will run test 3 times
               
               
Difference between testNG-Listner & webdriver Listner
Selenium WebDriver Event Listener is used to perform customized tasks and generate selenium action logs.

Step#1: Create a class with any any like WebEventListener which implements WebdriverEventListener (**and extends any base class where you are creating WebDriver object and setting Browser driver exe's)
Step#2: ** Goto ur base class and create object of EventFiringWebDriver and pass it driver object i.e. EventFiringWebDriver e_driver = new EventFiringWebDriver(driver);
Step#3: Create object of class which u created at Step#1 i.e.  WebEventListener eventListner = new WebEventListener();
Step#4: Register EventFiringWebDriver object with object of eventListner

Step#5: Assign EventFiringWebDriver object to driver object
           


Detailed Explanation is @http://toolsqa.com/selenium-webdriver/event-listener/
Refer Answer 81 for TestNG listners
               
How to execute only failed test only, when batch execution is Done
After the batch execution, refresh the folder than automatically we get testing-falied.xml (inside test-output), just run this xml file


How to execute dependent test-Scripts
@Test(dependsOnMethods={"testLogin"}) , here this test will only execute when 'testLogin' test passes else it will not execute or we can prioritize the test case use annotation 'priority', we can give priority starting from 0 and the test case with lowest digit  will be executed first.
like this ….

here testCase2 will be executed before testCase1

How to execute failed  test multiple times
We can use IRetryAnalyzer interface. example
 First create class which implements IRetryAnalyzer interface and then override its retry method like below

Now inorder to trigger this class from testNG suite we will have to use annotation transformer mechanism, so inorder to achive that create class which implement listner--IAnnotationTransformer
Now override transfrom method of interface IAnnotationTransformer like below.
  

Now tell testNG xml to implement this listener and then run xml as testNG suite
  
             
When ever we get build which test-scripts , you will execute first
Using grouping concept , we will execute smokeTest first
we will mark test cases like @Test(groups ={"smoke"}), and put group node in testNG xml
  
  
What is SVN or GitHub.
Git is a distributed version controlling system unlike svn which is central version controlling system.
In SVN we have a centralized repository from which we take update or check in our changes. But suppose if we do not have internet connectivity then we wont be able to commit our changes.
But in case of git everyone has their own repository which they can merge with the centralized repository.
But along with benefits git comes with added complexity like git clone vs git checkout, git commit vs git push
fyi: clone is for fetching repositories you don't have, checkout is for switching between branches in a repository you already have.pull is a fetch plus merge.
commit: adding changes to the local repository,push: to transfer the last commit(s) to a remote server
fyi: some of the git coomands are git init,git add .,git status,git commit,git commit -m 'changes' etc.

What is the Role of SVN/Github in Automation
SVN/Github plays a very pivotal role in automation. Suppose there is a team and each member will be having different task to perform to automate a system. Now there must be a single synchronized repository where everyone puts there changes and update code from there, so that all can be on same page. Also, this centralized repository link we can pass it to any CI/CD tool and configure it in such a way that it can run daily nightly , when changes are made to repository and so on.

What store & get File from SVN
take svn checkout.
fyi: checkout creates a working copy, whereas update brings down changes to an existing working copy.

What is the advantages of SVN
It’s easy to use, there will be backup of your code and people can sit remotely and work.
What is Maven/ ANT
Both Ant and Maven are build tool provided by Apache. The main purpose of these tools is to ease the build process of a project.

What is Role of Maven Framework
Selenium WebDriver is great for browser automation. But, when using it for testing and building a test framework, it feels underpowered. Integrating Maven with Selenium provides following benefits
·         Maven is used to define project structure, dependencies, build, and test management.
·         Using pom.xml(Maven) you can configure dependencies needed for building testing and running code.
·         Maven automatically downloads the necessary files from the repository while building the project.
               
What is dependencies , how to handle dependencies in framework
Dependencies are jars which are required by the build (it can be build of any build tool like maven, ant, gradle etc.) process. These dependencies are mentioned with version in build.gradle or pom.xml of maven so that when our build is put on new system all the required jars automatically download and set themselves up to process the build rather than manually setting up environment on every VM.


What of Project Object Model  [POM .xml]
POM.xml is a fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project.
If all the details are mentioned correctly in pom.xml, you can build your entire project from pom.xml.
You must just import it in eclipse and maven will download your source code, download all dependency jars like spring, apache etc., run the test cases, and display the result.

Explain the maven Plugin you used in your  framework
Not used in my project but there are core plugins like clean etc., then there are reporting plugins which generate reports based on unit test results etc.
[In gradle project the groovy plugin was used.
gradle --clean --continue sanityWindows]

How to Execute TEstNG.xml in Maven POM.xml
--- Maven-surefire-plugin: Surefire-plugin is responsible for running tests that are placed in test source directory /src/test/java.
put below lines in pom.xml

What is Jenkins
Jenkins is a CI tool. Basically Continuous Integration is the practice of running your tests on a non-developer machine automatically every time someone pushes new code into the source repository.

What is the Role of Jenkins in Framework
We can configure it and schedule jobs to run at specific time or when someone pushes new code in non-developer environment.

What is the Advantages of Jenkins
·         It is open source tool
·         It is simple to use
·         Huge plugin repository
·         Huge community to help you in case of issues
·         Build in java hence portable on all major platforms etc.
How to configure Jenkines
·         Download and install jenkins once done goto http://localhost:8080
·         Click on new item and select project type like maven project
·         Click manage jenkins and then click on configure system
·         Goto build section and give pom.xml path in case of maven
·         Click Apply and build now

Difference between xpath & css-selector
The only advantage that css selector have is it is a little faster than xpath but it has many disadvantages too like older browsers do not support all css features, backward and forward travesing in css selector is not possible like the way we can do in xpath

Where we have used contractor in selenium

How to execute Java-scripts in Selenium, or how to work with browser scroll bar
JavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver. JavaScriptExecutor provides two methods "executescript" & "executeAsyncScript".
The main difference between those are that scripts executed with async must explicitly signal they are finished, by invoking the provided callback. This callback is always injected into the executed function as the last argument. ex.

//*****************  Browser scroll
WebElement ele = driver.findElement(By.linkText(""));        
js.executeScript("arguments[0].scrollIntoView();",ele);

How to handle SSL popup in IE
 SSL is used to keep sensitive information which is sent across the Internet encrypted so that only the intended recipient understand it.So some times you must have seen browser saying
like do u trust this site, when u click on yes then you are able to see the site.
So handling SSL in chrome/firefox is easy like..
             DesiredCapabilities capability = DesiredCapabilities.chrome();
             capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
             System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
            WebDriver driver = new ChromeDriver(capability);
             
             FirefoxProfile profile = new FirefoxProfile();
             profile.setAcceptUntrustedCertificates(true);
             profile.setAssumeUntrustedCertificateIssuer(false);
             driver = new FirefoxDriver(profile);
             
             In IE u will have to handle ssl using javascript
             driver.get("javascript:document.getElementById('overridelink').click();");


What is use Selenium-Grid
Grid is used to perform parallel testing on different browsers using cluster of machines

What is the Use DesiredCapabalites in SELENIUM
Desired capabilities is a class which provides information to webdriver about the environment on which we need to run our scripts.
It is mainly used when the script execution needs to be done using selenium grid or on cloud plateforms.
In this we pass information in the form of key-value pairs. example.
           
            DesiredCapabilities dc = DesiredCapabilities.firefox();
            dc.setcapability("version","5");
            dc.setcapability("plateform","xp");
            WebDriver driver = new RemoteWebDriver(new URL(""),dc);
               
Non-automatable test case in your Project
·         TestCases which needs to be run only once
·         TestCases in which human interaction and user experience is required
·         TestCases involving aesthetics to be seen and usability




///////


Handling Element is not clickable at point SeleniumWebdriverException
1> Use WebDriverWait ExpectedConditions like visiblily of , element is clickable
2> Use javascript executor to scroll element into view then clickable
3> Use actions class , action.movetoelement.click.perform
4> click using javascript executor

@CacheLookup: This annotation when applied over a WebElement instructs Selenium to keep a cache of the WebElement instead of searching
for the WebElement every time from the WebPage. This helps us save a lot of time.
Use it with caution, suppose page got refreshed the casehed webelement will get corrupted and you will get stale element exception.
Ques: How will u increase performance of ur scripting/part-6-loops
Ans: We can use @CacheLookup


Extent Report
Extent Report is used for the reporting purpose.
Step#1: Put extent report jar at your build path or if u are using build tool like maven then put extent report dependency in maven - pom.xml
Step#2: Create a package in your framework/project and then in that create a class give any name like ExtentReporterNG.java
Step#3: Implement IReporter interface of testNG(make sure you are implementing IReporter of TestNG).
Step#4: Paste extent report methods

Step#5: In testNG.xml , put this class path in listener tag after suite and before test





>>Handling Browser level notification like :

For chrome we can use chromeoptions class

ChromeOptions option = new ChromeOptions();
option.addArguments("--disable-notifications");
System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver.exe");


For Firefox

System.setProperty("webdriver.gecko.driver","C:\\Z_Drivers\\geckodriver.exe"); 
FirefoxOptions option = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("dom.webnotifications.enabled", false);
option.setProfile(profile);
WebDriver driver = new FirefoxDriver(option);
driver.get("https://web-push-book.gauntface.com/demos/notification-examples/");



Difference between POM and PageFactory:

POM is a design pattern to create Object Repository .
Page Factory is an extension to POM design pattern.

Page Object Model is a design pattern to create Object Repository for web UI elements while Page Factory is a way to initialize the web elements you want to interact with within the page object when you create an instance of it.



Difference between FindAll and FindBys:

@FindBys : When the required WebElement objects need to match all of the given criteria use @FindBys annotation

@FindAll : When required WebElement objects need to match at least one of the given criteria use @FindAll annotation

@FindBy in a single list.

@FindBys have AND conditional relationship among the @FindBy whereas @FindAll has OR conditional relationship.

Note that elements are not guaranteed to be in document order which are located by FindBy.