Automation Testing Real Time Interview Questions
Automation Testing Real Time Interview Questions
By : Jaikishan Mohanty
1. Can you brief me about yourself?
Hi, my name is Pankaj. I started my career as a Testing Executive 4.5 years back with Infosys currently I am
working as Test Engineer.
In my previous project I have worked on Automation testing where we have used Selenium with java and
TestNG Cucumber framework for BDD approach. We have used Page object model where we have separated
our test cases with page objects, and we performed testing on the same. For build management tool we are
using Maven for version controlling we are using Git and for automating our jobs for nightly run or any schedule
we are using Jenkins,.
For defect management & test case management we have used JIRA, TEST RAIL & HP ALM. I have worked
on tools like BrowseStack, DeviceAnywhere, Toadsql,
I am working on Agile environment we have daily standup call and we have 2-week sprint cycle. I am part of
8-member team out of which we are 3-Tester, 2- dev, 1- manager, 1-scrum master
2. Tell me your Day to Day activities as QA?
First thing I do after login in my system. I check the active
sprint in Jira for our project code. There I can see my
assigned open tasks. After that I will check my mail if there is
any important mail I need to take action on. Then we have our
daily scrum meeting where we used to tell our previous day
actions what we did, what we are planning for today and if we
have any blocker to discuss. Product owner and scrum master
help us to resolve that blocker. After that I need to take the
pending task and do needed action whether creating test
case, Execution, Defect retesting if any.
3. Do you have created framework from scratch, or
you have maintained that?
I have not created Framework from scratch by
myself but yes, I was part of framework creation and
created some part of it.
4. How much you rate yourself in Java out of 10?
1) DATA ABSTRACTION : Data Abstraction means to handle complexity by hiding unnecessary details from the user. In java,
abstraction is achieved by interfaces and abstract classes. We can achieve 100% abstraction using interfaces.
We initialize the Chrome Browser using Selenium Webdriver. It means we are creating a reference variable (driver) of the interface
(WebDriver) and creating an Object. Here WebDriver is an Interface and ChromeDriver is a class.
We can apply Data Abstraction in a Selenium framework by using the Page Object Model design pattern. We define all our locators
and their methods in the page class. We can use these locators in our tests but we cannot see the implementation of their underlying
methods. So we only show the locators in the tests but hide the implementation. This is a simple example of how we can use Data
Abstraction in our Automation Framework.
2) ENCAPSULATION : Encapsulation is defined as the wrapping up of data
under a single unit. It is the mechanism that binds together code and the
data it manipulates. Encapsulation can be achieved by: Declaring all the
variables in the class as private and writing public methods in the class to
set and get the values of variables. All the classes in an Automation
Framework are an example of Encapsulation. In Page Object Model
classes, we declare the data members using @FindBy and initialization of
data members will be done using Constructor to utilize those in methods.
3) INHERITANCE Inheritance is the mechanism in java by which one class
is allowed to inherit the features (fields and methods) of another class. We
can apply Inheritance in our Automation Framework by creating a Base
Class to initialize the WebDriver interface, browsers, waits, reports, logging,
etc. and then we can extend this Base Class and its methods in other
classes like Tests or Utilities. This is a simple example of how we can apply
Inheritance in our framework.
4) POLYMORPHISM Polymorphism allows us to perform a single action in different
ways. In Java polymorphism can be achieved by two ways: –
Method Overloading: When there are multiple methods with same name but different
parameters then these methods are said to be overloaded. Methods can be
overloaded by change in number of arguments or/and change in type of arguments.
In Selenium Automation, Implicit wait is an example of Method Overloading. In
Implicit wait we use different time stamps such as SECONDS, MINUTES, HOURS
etc. –
Method Overriding: It occurs when a derived class has a definition for one of the
member functions of the base class. That base function is said to be overridden. In
Selenium Automation, Method Overriding can be achieved by overriding any
WebDriver method. For example, we can override the findElement method In
assertion we have used overload because in assertion we used to like
asset.true(actual, expected) and second time we can use same assert.true(actual,
expected, message).
6. How can you use interface and how it is different
from Abstract class?
Abstract class may have Abstract and concrete
methods, and there is not any compulsion in adding
abstract method in abstract class. But in Interface,
we do have only abstract methods and we don’t
need to write abstract keyword in Interface this is by
default public and abstract.
7. What do you mean by Static keyword in Java?
THANK YOU
Automation Testing Real
Time Interview Questions
With answers
Part - 2
By : Jaikishan Mohanty
11. What do you mean by wrapper class and how will you
do data conversion?
Wrapper class in java are used for data conversion. In data
conversion if user wants to convert Int to string, String to int,
Boolean, double then we use Wrapper class.
integer.parseInt(); -To convert string to Integer
Double.parseDouble(); -To convert string to Double
Boolean.parse Boolean(); -To convert string to Boolean
String.valueof(); -To convert Integer to String
12. Can you convert string a =”110a” in integer?
No we got NumberFormatException while converting
the above string.
13. What do you mean by Call by Value & Call by
Reference in Java?
Call by value means suppose we have created one
sum method with input parameter int a, int b. So
while calling the creating the object and running we
provide values that is know as call by value.
14. What do you mean by Exceptions in Java?
THANK YOU
Automation Testing Real
Time Interview Questions
With answers
Part - 3
By : Jaikishan Mohanty
21.Tell me the difference between Implicit & Explicit wait?
Implicit wait applies for all the elements and all the tests like if we
give 10 sec of implicit wait it will wait for 10 sec for each element
before giving nosuchelement exceptions.
While Explicit wait can be applied for any particular step for which
you want extra wait time so we can use explicit wait.
● We can use mix of both waits to depend on the situation of the
step
Link : https://www.guru99.com/implicit-explicit-waits-selenium.html
22. Can you tell me some exceptions in selenium?
● NoSuchElementException
● NoSuchWindowException
● NoSuchframeException
● StaleElementReferenceException
● TimeoutException.
Link :
https://www.guru99.com/exception-handling-seleniu
m.html
23. What do you mean by User Defined Exception?
@BeforeTest
@BeforeClass
@BeforeMethod
@Test
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite
27. Do you heard about Priority in TestNg can we set
-ve priority?
Yes, like priority is 0, -1, TestNg will run -1 then 0
then 1.
And if we have any @test which is not having any
priority set, then in that case it will search via
alphabetic order whichever comes first and execute
test respectively.
28. Can you explain me TestNG?
THANK YOU
Automation Testing Real
Time Interview Questions
With answers
Part - 4
By : Jaikishan Mohanty
31.Have you used GIT in your project can you explain
about it?
Yes I have used GIT, It is a version control tool. Where we can
maintain our central repo. we used to manage our code via GIT
only.
We use Git to maintain our project in our local system. So, if
someone like to work on that project I need to send complete update
copy to him and after that he can work on that.
There are chances that single project is handled by multiple teams
across the globe. So, it will be difficult if we won’t use GIT.
32. Can you give me some GIT commands which you
used on daily basis?
Git status- which shows status of all the files,if we have
some files which is not yet added to our repo so it will
give us untracked file.
After that we can use GIT add command after adding it
will added to particular index and we can commit this file
using Git Commit -m(Message) we can commit this
untracked file. Also we have Git Merge, Git Push, Git
Pull, Git checkout in etc
33. How to solve Merge conflict in GIT?
For more :
https://www.geeksforgeeks.org/difference-between-list-a
nd-set-in-java/
40. Method overloading and overriding?
● Method overriding is used to provide the specific
implementation of the method that is already provided by its
super class.
● Method overloading is performed within class.
● Method overriding occurs in two classes that have IS-A
(inheritance) relationship.
● In case of method overloading, parameter must be different
Link :
https://www.javatpoint.com/method-overloading-vs-method-ove
rriding-in-java
Part 5 will be coming soon.
Stay tuned with our channel.
THANK YOU
Automation Testing Real
Time Interview Questions
With answers
Part - 5
By : Jaikishan Mohanty
41. Use of constructor?
The main difference between checked and unchecked exception is that the checked
exceptions are checked at compile-time while unchecked exceptions are checked
at runtime.
checked exceptions –
SQLException,IOException,ClassNotFoundException,InvocationTargetException
unchecked exceptions –
NullPointerException,ArrayIndexOutOfBoundsException,ArithmeticException,IllegalA
rgumentException NumberFormatException
50. Apart from sendkeys, are there any different
ways, to type content onto the editable field?
WebDriver driver = new FirefoxDriver();
JavascriptExecutor executor =
(JavascriptExecutor)driver;
executor.executeScript("document.getElementBy
Id("textbox_id").value='new value';);
Part 6 will be coming soon.
Stay tuned with our channel.
Part - 6
By : Jaikishan Mohanty
51. Annotations in Cucumber?
HashMap and HashSet both are one of the most important classes of Java
Collection framework. ... HashMap Stores elements in form of key-value
pair i.e each element has its corresponding key which is required for its
retrieval during iteration. HashSet stores only objects no such key value
pairs maintained.
Links :
https://www.geeksforgeeks.org/difference-between-hashmap-and-hashset/
https://www.javatpoint.com/difference-between-hashset-and-hashmap
53. Where do you use a hashmap??
Maps are used for when you want to associate a key with
a value and Lists are an ordered collection. Map is an
interface in the Java Collection Framework and a
HashMap is one implementation of the Map interface.
HashMap are efficient for locating a value based on a
key and inserting and deleting values based on a key.
HashMap map = new HashMap<>();.
Example :
// Add elements to the map
map.put("vishal", 10);
map.put("sachin", 30);
map.put("vaibhav", 20);
// Print size and content
System.out.println("Size of map is:- "+ map.size());
System.out.println(map);
// Check if a key is present and if present, print value
if (map.containsKey("vishal")) { Integer a = map.get("vishal");
System.out.println("value for key"+ " \"vishal\" is:- " + a);
54. How do you handle if XPath is changing dynamically?
Option 1: Look for any other attribute which Is not changing every time In that div node like name,
class etc. So If this div node has class attribute then we can write xpath as bellow.
//div[@class='post-body entry-content']/div[1]/form[1]/input[1]
Option 2: We can use absolute xpath (full xpath) where you do not need to give any attribute
names In xpath.
/html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/div/div
[1]/div[2]/div[1]/form[1]/input[1]
Option 3: We can use starts-with function. In this xpath's ID attribute, "post-body-" part remains
same every time. //div[starts-with(@id,'post-body-')]/div[1]/form[1]/input[1]
Option 4: We can use contains function. Same way you can use contains function as Above
//div[contains(@id,'post-body-')]/div[1]/form[1]/input[1]
55. Does Jenkins require a local system for CI??
The finally block always executes when the try block exits. This
ensures that the finally block is executed even if an unexpected
exception occurs.
57.How many times you can write catch block?
Part - 7
By : Jaikishan Mohanty
One Liner Answer
61. How many types of WebDriver API ’s are available in
selenium?
● Chrome
● Geko
● Chromium
● Edge
● Html
● android
62. What are the different exception you faced in selenium
webdriver?
Webdriver exc, noalertpresent exc, nosuchwindow
exc, nosuchelement exc, timeout exc.
63. How do you scroll down a page using javascript
in selenium?
window.scrollby( , ) function
E.g:
js.executeScript("window.scrollBy(0,1000)"); //Scroll vertically down
by 1000 pixels
Link:
https://www.guru99.com/scroll-up-down-selenium-webdriver.html
64. How do you scroll down to a particular element?
Part - 8
One Liner Answer & By : Jaikishan Mohanty
Coding Questions
71. What does means Public static void
main(variable,value) ?
1. int i = 0;
for(char c: str.toCharArray()) {
i++;
OR
2. Sysout(str.toCharArray().length);
Sysout(str.lastIndexOf(“”));
Link: https://java2blog.com/find-length-of-string-without-using/
77.How to swap two numbers without using a third
variable?
public static void swapNumbers(int a, int b) {
b = b + a;
a = b - a;
b = b - a;
}
78. Write down syntax of iterator function?
Iterator<String> it = studentList.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
79. How to reverse any array?