Sei sulla pagina 1di 24

What is abstract

It has undefined values or methods.

What is abstract class?

A class which contains one or more unimplemented /abstract methods.

AND Subclasses have to provide the implementation for the un implemented


methods or else it has declared to be abstract class.

Can we declare an abstract class without any abstract methods?

Yes we can declare abstract class (AB) without AB method .but no use because we
can’t create instantiate the abstract class

What is the use of it?

Whenever a method which needs to be implemented in different ways by


different sub classes

Example For Abstract Class and Methods


package javasample;

public abstract class AbstExample extends AbstMethod {

@Override
public abstract void travel();

package javasample;

public class AbstExample2 {

public void travel(){


System.out.println("clour is red");
}
}

package javasample;

public abstract class AbstMethod {

public void employee(){


System.out.println(" blue dress");

}
public abstract void travel();
}

What is class?

It is a blue print and that has methods and variables in it.

What is object?

Instance of a class

Example for Class


package javasample;

public class A {

int aabc=10;
public void test(){

}
}

What is Inheritance?

Acquiring the properties of a super class to sub classes. it can use all the methods
and variables of super class to subclass

Example for Inheritance


package javasample;

public class A {

int aabc=10;
public void testa(){

}
}

package javasample;

public class B extends A {

public void testb(){}


}
Object creation:

Acquiring the properties of that class. Also we can use all visible methods and
variables of that class and its hierarchy classes

Example for Object Creation


package javasample;

public class A {

int aabc=10;
public void testa(){

}
}

package javasample;

public class B {
A a= new A();
public void testb(){}

different datatypes(int,float,long,double)
int
The most commonly used datatype is int.
size = 4 bytes

long
if int is not enough to hold big values then we should go for long-datatype
size = 8 bytes

floating-point
for representing real numbers(numbers with decimal points)
float size = 4 bytes
double size = 4 bytes

Garbage collection :

Final,finally,finalized:

Final – constant declaration.


Final method: A java method with final keyword is called final method and it cannot
be overridden in sub-class.
example for Final method:
Class a{

Public final String getName()

return a;

Class b extends a{

Public final String getName()[

return b;

Final class: Final class is complete in nature and cannot be sub-classed or


inherited.
Example For Final Class:
Final Class a{

Public String getName()

return a;

Finally – The finally block always executes when the try block exits. This ensures
that the finally block is executed even if an unexpected exception occurs .

Finalize () – Method helps in garbage collection. A method that is invoked before
an object is discarded by the garbage collector, allowing it to clean up its state.

Static:- methods and variables


Static Variables: - To create variables that will exist independently of any
instances created for the class

Static Methods:- To create Methods that will exist independently of any instances
created for the class
Can we implement multiple inheritances in java

No we can’t .but we can implement by using interface

Interface:

It contains only unimplemented methods in it. It is designed for future


implementation.

In interface we can add multiple inheritances.

Example for interface;


public interface IntFace {

public void add();


public void sub();
public void mul();

public class IntFaceExp1 implements IntFace {

public void add(){

public void sub(){

}
public void mul(){

}
}

Difference b/w interface and abstract class


Feature Interface Abstract class

Multiple inheritance A class may inherit several A class may inherit only one
interfaces. abstract class.

Default implementation An interface cannot provide An abstract class can provide


any code, just the signature. complete, default code and/or
just the details that have to be
overridden.

Access Modifiers An interface cannot have An abstract class can contain


access modifiers for the subs, access modifiers for the subs,
functions, properties etc functions, properties
everything is assumed as
public

Uses of interface

1. To maintain the Standardization or uniformity in the method definition


2. It enables to implement differently.

Polymorphism?

One interface in multiple forms


Oops concepts?

Inheritance, Polymorphism, Encapsulation, interface, abstraction..


Encapsulation?

In a class methods are declared as a public and variables are declared as privates
is called
Differences b/w JDK and JRE.

Jdk occurs in compile time(which converts .java file into .class file).

jre occurs in run time(creates a object in jvm and the object will be killed after the
execution)

String operations…...(string,string.split,string.tirm,string.format,etc…)
Difference b/w string and string buffer, sting builder.

String is immutable.....

String class is one which stores set of characters. String is By default immutable,
(i.e) the content in String class cannot be changed or altered .

whenever u try to append or modify a string value every time, a new object will
be created for dat value.

String Buffer and String Builder are same as String class but these two are
mutable.(i.e.), u can append or modify the value and it will be done in same
object .

Difference b/w .equals and ==.

For integers (a==b), string (a.equals(b))

Constructor

Classes should define one or more methods to create or construct instances of


the class
their name is the same as the class name

 
If you don’t define a constructor, a default one will be created.
Constructors automatically invoke the zero argument constructor of their super
class when they begin

Note: deviation from convention that methods begin with lower case
Constructors are differentiated by the number and types of their arguments

Hashcode:

This contains different variables name with same value which will be containing
same locating value
public class HashCode {
String name = "obul";
String name1 = "obul";
@Test
public void test(){

System.out.println(name.hashCode());
System.out.println(name1.hashCode());

}
}

Util package:- refer to the java util package

i/o packacge:- refer to the java i/o package

Java.Lang:- refer to the java i/o package

What is exception.

It is an undesired behavior occurs while compiling(Checked Exception) and


executing(Un Checked Exception) the program.

Exception handling.

we can handle compile time Exceptions in d middle of compilation by throwing


the exception to the next hierarchy levels. By doing this, we have to always throw
the exception to next levels.
eg: Thread.sleep() , when u call a method of one class in other class ,then it will
ask to throw the Exception.

We can use try(),catch() methods instead of throwing exceptions.

U can put the risky code in try() Block , if u know the exception exactly ,then put it
in catch () Block.

Even if both try() and catch() r not executed then u can write the mandatory code
in the finally() Block.

Exception Hierarchy
Throw able is the parent of entire java exception hierarchy. It has 2 child classes
1) Exception.
2) Error.
Exception
These are recoverable. Most of the cases exceptions are raised due to program code only.
Error
Errors are non-recoverable. Most of the cases errors are due to lack of system resources but not due
to our programs.
Checked Vs UnChecked
The Exceptions which are checked by the compiler for smooth execution of the program at
runtime
are called ‘checked exception’
Ex:- IOException, ServletException, InterruptedException.
The Exceptions which are unable to checked by the compiler are called ‘unchecked exceptions’

exceptions and all the remaining considered as checked.


Whether the exception is checked or unchecked it always occur at runtime only.
Partially checked Vs fully checked
A checked exception is said to be fully checked iff all it’s child classes also checked.
Ex:- IOException.
A checked exception is said to be partially checked if some of it’s child classes are not checked.
Ex:- Exception, Throwable.
Exception Handling By Using try ,catch
We have to place the risky code inside the try block and the corresponding exception handling
code inside

Try/catch Example:
catch block.
try
{
//Risky code
}
catch (X e)
{
//handling code
}
Overloading.

A class which contains two or more methods having same name with different
signatures is called

Overloading Example:
package javasample;

public class Overloading {

public void add(){


System.out.println("add");
}
public String add(String a, String b)
return a+b;

}
Overloading(){
System.out.println();
}
}

Overriding.

If both subclass and super class contains same methods and variables with same
signatures in that case subclass overrides super class.
Example for overriding:
package javasample;

public class Overloading {

public void add(){

System.out.println("add");

public String add(String a, String b){


return a+b;

}
Overloading(){
System.out.println();
}
}

package javasample;

import org.testng.annotations.Test;

public class OverRiding extends Overloading {


public void add(){
System.out.println("123");
}
@Test
public void name(){
add();
super.add();

}
}
Access modifiers (public,static,final,protected,private,default)

Static: static is the modifier is applicable for methods and variables.


we can’t declare top level classes as static but inner classes can be declares as
static( static nested class).

Final Variables
For the Static and instance variables no need to perform initialization, JVM Will
Provide default initialization

Final static Variables


For the final static variables compulsory we should perform initialization.

protected members
If a member declared as protected then we can access that member from
anywhere within the
current package and only in child classes from outside package.

private members
If a member declared as private we can access that member only in the current
class.

<default> members
If a member declared as a default we can access that member only in the current
package.

public members
we can access public members from anywhere but the corresponding class must
be visible.

collections

This interface is the root interface for entire collection framework.


This interface can be used for representing a group of objects as single entity.
This interface defines the most common general methods which can be applicable
for any collection
Object.
There is no concrete class which implements collection interface directly.

What is array?
Array is a container or utility that stores only same type of data, for eg, integers, strings, float
values etc.

What is array list?

Array List is a utility that can store any type of data in the form of objects.

Array List is ordered.

Array List wont have fixed length , u can store any no. of values.

Data manipulation and modification is possible and easy in Array List.

What is order in array list

Array List is ordered. Dat means it stores the values in the order which has been
given by us.

What is hasset
public class Hasset {
set set=new HashSet();

public void test(){


set.add("obul");
set.add("reddy");
set.add(123);
set.add("obul");
System.out.println("result"+ set.size());
Iterator it= set.iterator();
while(it.hasNext()){
System.out.println("result" + it.next());
}

What is hash map

This can be used for representing a group of objects as key value pairs. Both key
and value are
objects only.
Student Name Student Roll No
Phone Number contact details
word meaning
IP Address Domain-name
Map interface is not child interface of collection.

public class Mapppppp {


Map map=new HashMap();
public Selenium selenium = new
DefaultSelenium("localhost",4444,"*firefox","http://www.abc.com");

@Test
public void test2() throws Exception{
map.put(111, "sai");
map.put(222, "amar");
map.put(333, "obul");
map.put(444, "sai");
map.put(555, "mahendher");
map.put(666, "mahendher");
System.out.println(map);

Difference b/w array and array list,

Array is fixed length

Handles only similar data types..

Data manipulation is difficult

Iteration is difficult

Handling dynamic data is difficult in array

Difference b/w hash set, hash map

In hash set it doesn’t allow duplicate values in it. And it not ordered

In has map it contains key’s which doesn’t allow duplicate .and it also contains
values to keys it can contain duplicate values and it ordered
Two-dimensional arrays

Two-dimensional arrays are defined as "an array of arrays".

What is UI mapping?

A centralized repository for the locators to avoid hard coded values and duplicate
locators

What is iterator where do u use it.

Iterator is a interface. Which is used to iterate the values in array list and hash
set?

Selenium RC:
What is ur framework.

We use Selenium RC as a automation tool, and Java as programming language,


Test NG to test the test case, and Maven as a project management tool, and for
continuous integration we use Jenkins.

We are using customized framework which has data driver, ui mapping and
keyword flavors

Data driver- we use data provider whenever we need to test a single test case
with multiple sets of data (we read test data from excel sheet using jxl api)

Keyword - we use different re-usable methods like login

UI mapping - We are using object .properties file to store locators

Package structure – we have different levels of package structure, the first level is
application independent which is called base package, contains base xyz class and
object reader, config reader, excel, xml reader etc, base level will have all the
objects of these classes along with selenium related stuff Eg: selenium object,
wait for element, second level in the hierarchies is commons which contains
application related common components, example login, logout and common
navigations and common test which extends the base test, then we have different
module level packages contains respective module test classes. All the test classes
extend common xyz test class so that we can re-use all the components in super
class and we write only test related code.

Where do you store test data?

We store them in src/test/resources

How do you achieve data driven approach or data provider

We use Test NG data provider approach to achieve it, in this approach we have 2
functions one is data provider and test method, in the first method we keep
@Data Provider annotation for the method, this method returns 2 dimensional
array object, one array contains no of sets of data and other contains columns
and test method and in test case we will pass the data provider method name
which means this test will be executed according to the data given by the data
provider ie, test will be executed number of times

Implicit wait is nothing but our set time out (selenium.setTimeOut();)

Explicit wait is nothing but utility we create like wait of element.

What is object identification (or) how to do you locate ur object.

Identifying the object in a given web page.

By using firebug we will go through the properties of the object. Acc to w3school
we will go with id because id should be unique. If object doesn’t contain id then
we will go other properties.(class, name, xpath: position, parent, relative)

How do you handle partially dynamic element

I can go with contains or startsWith or EndsWith

How to handle fully dynamic elements

We will go with parent properties (Xpath)

How to u handle dynamic content /ajax’s content/j-query content


Selenium supports full refresh of the page by using wait For Page To Load

For Dynamic content (or partially refreshed ) we have created our own utility
called wait For Element

How to does WaitForElement work

We created a method which takes an element as parameter. We will iterate


through for loop with threshold time which has 100ms time intervals, iteration
stops if the element is found in any of the interval. Or else it will Wait till the
threshold time.

How do u execute the java script from selenium rc

We have selenium.executeQuery but I didn’t get chance to work on it

SeleniumRC workflow (or) selenium hierarchy

There are 4 components in selenium RC( Java code, selenium RC


server(standalone server), selenium core, proxy browser)

Firstly we need to run selenium RC server (standalone sever) which is a


prerequisite, then command start-> in java program goes to selenium server, then
RC server starts selenium core and the proxy browser (or desired browser) .while
opening the proxy browser selenium core injects the java code inside it and then
command goes back to java program Note: selenium core is JavaScript driven.
Request goes to server again and types in the address bar and then goes back to
server again. RC server contacts the website server for the content and once the
content is received it will be rendered on the proxy browser via selenium core,
after that depends on the request RC goes to the browser and web site server

How do u handle multiple windows or child windows or pop-up’s.(model dialogue,


windows pop-up’s)

There are 4 types of windows (java script alert, child windows, browser popup’s,
module dialogue, windows pop-up’s)
For java script alerts we can use selenium commands
a) Selenium.chooseOkOnNextConformation

b) Selenium.chooseCancelOnNextConformation
ChildWindow operations:

Clicking on the element we may get the child window to perform the operations
(or ) to access the window. First I will get the parent window title and store in the
string .then I will click on the element to get the child window. Then by using
getallwindowTitles (or) id’s, name’s, then I will store in a string array, then I will
iterate through an string array till I get the desired window

i.e, if the string doesn’t matches the main window then it is a child window

What is our approach in case in u have more than one child window.

We get unique element from the desired page and while iterating the string
array I will check for that unique element in that page. If I get that element I
will perform the operations in that page or I will move to another page

Model dialogue:-> we will handle by using autoit

What is autoit

First we will create .au3 file and we will convert into .exe file because java
can’t run .au3 file . Upon clicking the upload (or) Download a new window will
be opened to upload/save the file. We can’t handle this box/window. Using
java runtime object .

String[] command = “C:/userlocation/desktop/upload.exe”;

Runtime runtime = null;

runtime.getRuntime().exec(command);

How to u handle firefox profile

How do u handle security exceptions

What are the critical issues u have faced while automating in selenium
Autoit issue

We have child window with no title or name or id but need to be handled

Limitations of selenium Rc:

Works on firefox verywell but not on other browers

Table operations

How do u get content of desired column in a table(only one row)

By using selenium.getTable(//table.row num.colum num);

How do u handle table data

I will get the xpathcount which gives me the no.of rows in the table. With that
I can iterate to that table and handle the data.

SeleniumRC Commands

[SELENIUM, click, type, start, open, typekeys, clcikAt, getText, gettable,


getXapthcount, etc…]

Difference b/w type and typekeys,

Type it is done as one time operation of the given value

Type Keys it types each key one time of the given value

Differnce b/w click and clickAt

click is the operation done to click on the link (or) object (or) locator in a webpage

ckickAt is the operation done to click on the link (or) object (or) locator in a
webpage by using coordinates(x,y).

How to u capture the screenshot, entire capture screenshot

Selenium.captureScreenShot(“ LOCATION WHERE U WANT TO SAVE”);


Selenium. captureEntirePageScreenShot(“ LOCATION WHERE U WANT TO SAVE”);
the desired wepage only

Dynamic table

We will get one locator from that table and while iterating we will use that locator
as isElementPresent(Locator) then iterator will go throw that and if the element
present in that table then it will enter into that table.

Static table

We can go with table name (or) table title, or which we can find a unique locator
in it.

What is an iframe

Iframes is an html inside a html (Nested iframe : ->Contains iframe in a iframe)

How do u handle iframes

First I will getXpathcount of the frames. And then I will iterate with frames count
and if I want perform operation in the desired iframe then I will get a locator in
that iframe and I will give that locator while iterating if the desired locator is
found then I can enter into that iframe and then i can perform the operation in
that iframe. if it doesn’t contain the locator then we need to use relative=up
command. To come out of that iframe.

Drawbacks of IDE (or)selenium Rc

Test suite maintenance is difficult

TESTNG QUESTIONS;

What is annotation?

What kind of annotation do u used so far and their differences?

[@test,@beforeSuite,@afterSuite,@dataprovide,@beforemethod,@aftermethod
@beforetest,@Aftertest]
Person to person it varies

What is data driven testing

Testing a single test case with multiple data is data driven

What is dataprovider

What is dependency in testcases?

It depends on the test while running the test which run first or last

What is priority?

While executing the program which test should run first we can prioritize that in
the code

What do u do If u have 1000 test cases I want to run only 50 test cases?

If 50 test cases that should be in same group

What is suite

At a current point of time what u want test. That data should be given in suite

Contents of xml.suite (or)testing suite

Test, group, package, class, methods.

What do u have in test tags?

What type of test cases u want to run at a given point of time that should contain
in tags.

How to skip the execution of the testcase?

It depends on methods and or depends on groups

Where u can use at @test?

Where u want to run that methods


What is grouping?

It is nothing but combination of different test cases.

What is @BeforeTest ;->Runs before the suite

@BeforeMethod;-> before desired method runs

Test design pattern:

Ui mapping: Having a centralized repository for the locators to avoid hard


coded values and duplicate locators

DataDriven: Testing a single test case with multiple data is data driven

Pageobject: Having different classes which contain the functions of that class
which in test class we run with methods

KeyWord: OR Table driven: Having a sheet are ui mapping (login method)

How to you load jdbc:


Class.forName("com.mysql.jdbc.Driver");
Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement statement = connection.createStatement();
resultSet = statement.executeQuery(query);

properties file reader


Properties properties= new Properties(); //properties ki object creation
File file =new File("Object.properties"); //create the file object
FileInputStream fileInputStream = new FileInputStream(file); //fileinputstream object created
properties.load(fileInputStream); //fileinputsteam object added
return properties.getProperty(key);

how to create object file


Properties properties= new Properties();

Properties.setproperties(“111”,”obul”);
Properties.store(“src/common/abc.properties”,null);

MAVEN QUESTIONS

How do you add dependencies in pom.xml


By using dependency management we will add whatever tools we need in the project give a
plug-in of the tool in the dependency management. Then it will add jar self by it self

What is pom.xml

It contains build and dependencies in it


What is suite

It contains one or more group of test in it . Which is designed according to our preferences

How do you retrieve data from jdbc


By adding vender specific tool jar in dependencies

Contents of pom.xml
It contains our work tools in it (build and plug-ins and suite files)

Education qualification and univ etc.

Profiessional experience

I have 3+ exp in selenium Automation

I am working clinet XXXX few lines about tht company

Currently I am working with xyx from 3+

Project is///////

I am responsible for Test script Automation and maintenance

We USED customized framework


We are using selenium, java, testing and maven

Java programming language

Selenium Rc as automation tool

Testing framework

Maven Bulid tool or proj management tool

For continuous integration we are using Jenkins

We are using selenium java testing and maven

Differences b/w rc and web driver

Rc works

It works on proxy browser

Strat the server

Advanced user interactions

No head less browser

Navigation,select,bulid,

Jenkins
What is Jenkins?

Jenkins is a continuous integration reporting tool, it’s a place where we can run
our job and generate customized reports

What is continuous integration?

Is a process which integrates the code repository like svn/cvs with


Jenkins/hadson i.e every latest checkin is reflected in the Jenkins immediately
and make sure that this jobs executed with the latest code..

Potrebbero piacerti anche