Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Yes we can declare abstract class (AB) without AB method .but no use because we
can’t create instantiate the abstract class
@Override
public abstract void travel();
package javasample;
package javasample;
}
public abstract void travel();
}
What is class?
What is object?
Instance of a class
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
public class A {
int aabc=10;
public void testa(){
}
}
package javasample;
Acquiring the properties of that class. Also we can use all visible methods and
variables of that class and its hierarchy classes
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:
return a;
Class b extends a{
return b;
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:- To create Methods that will exist independently of any instances
created for the class
Can we implement multiple inheritances in java
Interface:
}
public void mul(){
}
}
Multiple inheritance A class may inherit several A class may inherit only one
interfaces. abstract class.
Uses of interface
Polymorphism?
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 .
Constructor
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());
}
}
What is exception.
Exception handling.
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’
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;
}
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;
System.out.println("add");
}
Overloading(){
System.out.println();
}
}
package javasample;
import org.testng.annotations.Test;
}
}
Access modifiers (public,static,final,protected,private,default)
Final Variables
For the Static and instance variables no need to perform initialization, JVM Will
Provide default 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
What is array?
Array is a container or utility that stores only same type of data, for eg, integers, strings, float
values etc.
Array List is a utility that can store any type of data in the form of objects.
Array List wont have fixed length , u can store any no. of values.
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();
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.
@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);
Iteration is difficult
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
What is UI mapping?
A centralized repository for the locators to avoid hard coded values and duplicate
locators
Iterator is a interface. Which is used to iterate the values in array list and hash
set?
Selenium RC:
What is ur framework.
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)
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.
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
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)
For Dynamic content (or partially refreshed ) we have created our own utility
called wait For Element
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
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 .
runtime.getRuntime().exec(command);
What are the critical issues u have faced while automating in selenium
Autoit issue
Table operations
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
Type Keys it types each key one time of the given value
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).
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
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.
TESTNG QUESTIONS;
What is annotation?
[@test,@beforeSuite,@afterSuite,@dataprovide,@beforemethod,@aftermethod
@beforetest,@Aftertest]
Person to person it varies
What is dataprovider
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?
What is suite
At a current point of time what u want test. That data should be given in suite
What type of test cases u want to run at a given point of time that should contain
in tags.
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
Properties.setproperties(“111”,”obul”);
Properties.store(“src/common/abc.properties”,null);
MAVEN QUESTIONS
What is pom.xml
It contains one or more group of test in it . Which is designed according to our preferences
Contents of pom.xml
It contains our work tools in it (build and plug-ins and suite files)
Profiessional experience
Project is///////
Testing framework
Rc works
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