Accenture - Automation - Interview Question
Accenture - Automation - Interview Question
com
9123820085
Accenture QA
Automation
interview real time
Question
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
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.
• Can you tell me Oops concepts and relate it with your Framework?
We have Polymorphism, Inheritance, Encapsulation and Abstraction in
Oops. So, we will start with
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.
In Selenium, WebDriver itself acts as an interface. Consider
the below statement: WebDriver driver = new
ChromeDriver();
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
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
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
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• 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.
• What do you mean by Static keyword in Java?
Static means it is at class level not at instance level, we have static
method, static variable & static inner class. When we have any variable
as static so it will remain same for all the instance of our classes, and
static/Private/Final methods can’t be over-ridden like if we have
initialized any method as Static so we cannot override it in any child
class.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• 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.
• Can you tell me about difference between Throw and Throws keyword?
Throw is a keyword used inside a body of function. And Throws used
while initializing any method. By using Throw we can throw only one
exception while for Throws we can declare multiple exceptions which
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• Can you tell me how you will handle multiple window in selenium.
We have windowhandle & windowhandles function for handling
Multiple windows. Windowhandle will give the string value of only the
active window that is open whereas windowhandles will give set of all
the windows that are open in browser.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
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.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• Do you work in cucumber, can you tell me what all files required in
cucumber?
In cucumber we have Feature file, Step Definition file and Test Runner file.
In feature file we used to write scenario in gherkin language which is
most like in plain English language. Here we use some of the keywords
like feature, scenario, scenario outline, given, when, then, and, example,
background keywords for writing our test scenarios steps.
In Step Definition file we write mapping code for all the scenario of feature
file.
In test Runner file we provide the address of the feature file, step
definition file, and all-important Tags, Plugin, Listeners in that.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• Can you tell me how you will re-run failed scenario in cucumber?
For that we can use re-run attribute in our test runner file. After that we
can write one file location. Where all the test cases which failed while
execution get stored. So next time while running execution we can give
this file location and run the failed TC.
• You have worked in Cucumber & TestNG according to you which one is
best?
I will consider Cucumber as it is most likely understood by Laymen
people which is English plain language. Because in order to
understand the functionality flow no need to go look and script/code.
Via Scenario steps lines only we can get clear understanding about
the functionality.
It helps to come all the QA members Dev, Client, Product Owner on same
page.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
for maintain the code easily and for unit testing. It provides lots of
benefits to us like we can create a suite and we can write all the
required Tc in one go only using that suite. We can group our Tc we can
set priority we can run our tc in parallel mode, We can generate good
reports via TestNG. We can write functionality depends on methods,
depends on group. We can run single tc multiple time with single set of
data of multiple set of Data.
• 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.
• 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-
(Message) we can commit this untracked file. Also we have Git Merge,
Git Post, Git Pull, Git It in etc.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
are covered then I will add my steps and push the script to the central
repo.
• You have worked in Jenkins can you tell me how you have created jobs
in Jenkins?
We have separate Dev-Ops Team to create Jenkins jobs at broad level
but we also have access to jenkins, so we have created jobs for our
internal purpose.
For creating any job we have click on create new job->inside that give
name of your job->select freestyle project->then add. Beside that we
can provide description of our project and in source code
management we can choose Git-> provide repo url ->after that
provide some schedule if you want to run the job on any specific
schedule time.-> select window batch command-file location-save-
click on build now for running. After triggering we can check log in
console.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
The main difference between List and Set is that Set is unordered and
contains different elements, whereas the list is ordered and can
contain the same elements in it.
• Use of constructor.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Step 7: Pull the Most Recent Files From the Organization Repo
Step 8: Merge the Master Branch Into the Feature Branch
Step 9: Push Your Code to your GitHub Repo
Step 10: Make a Pull Request to the Organization Repo
Step 2 − In the next screen, enter the Item name, in this case we have named it
Helloworld. Choose the ‘Freestyle project option’
Step 3 − The following screen will come up in which you can specify the details
of the job.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Note − If you repository if hosted on Github, you can also enter the url of that
repository here. In addition to this, you would need to click on the Add
button for the credentials to add a user name and password to the github
repository so that the code can be picked up from the remote repository.
Step 5 − Now go to the Build section and click on Add build step → Execute
Windows batch command
Step 6 − In the command window, enter the following commands and then
click on the Save button.
Javac HelloWorld.java
Java HelloWorld
Step 7 − Once saved, you can click on the Build Now option to see if you have
successfully defined the job.
Step 8 − Once the build is scheduled, it will run. The following Build history
section shows that a build is in progress.
Step 9 − Once the build is completed, a status of the build will show if the
build was successful or not. In our case, the following build has been
executed successfully. Click on the #1 in the Build history to bring up the
details of the build.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Step 10 − Click on the Console Output link to see the details of the build
• Can we declare many interfaces object class inside the interface class.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
that loop enclosing 'continue' and made executional flow inside the
loop again
Abstract class can inherit another class using extends keyword and
implement
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
checked exceptions –
SQLException,IOException,ClassNotFoundException,InvocationTargetException
unchecked exceptions –
NullPointerException,ArrayIndexOutOfBoundsException,ArithmeticException,Illeg
alArgumentException
NumberFormatException
• Apart from sendkeys, are there any different ways, to type content onto
the editable field?
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Using Robot Class: // Create Robot class Robot rb = new Robot(); // Press
control keyboard key rb.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• 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.
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<String, Integer> map
= new HashMap<>();
map.put("vishal", 10);
map.put("sachin", 30);
map.put("vaibhav", 20);
"
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
+ map.size());
System.out.println(map);
if (map.containsKey("vishal")) {
Integer a = map.get("vishal");
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/di v/div[1]/div[2]/div[1]/form[1]/input[1]
Option 4: We can use contains function. Same way you can use contains
function as bellow.div[contains(@id,'post-body-')]/div[1]/form[1]/input[1]
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
The finally block always executes when the try block exits.
This ensures that the finally block is executed even if an
unexpected exception occurs.
maximum one catch block will be executed. No, we can write multiple
catch block but only one is executed at a time.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
POM is an acronym for Project Object Model. The pom. xml file
contains information of project and configuration information for
the maven to build the project such as dependencies, build
directory, source directory, test source directory, plugin, goals etc.
Maven reads the pom.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• java file mai ek hi public class hoti hai, uske alava aur classes v ho sakti
hai par public ek hi.
• If we need to create one variable for multiple values, we need to use
Array concept.
• Int marks[] = new int[5]
• Array can store only homogenous data, int for int array, string for string,
• If we need to add heterogeneous data in array, we need to create
object array.
• Object a[] = new Object[5]; now we can add different data type
objects.
• Array is fixed in size, which we define while creating.
• If we try to access index value >= given index value, we got
arrayOutOfBundException.
• Arrays are not defined by any data layer structure so we can’t run
readymade methods on
it.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
COLLECTION FRAMEWORK
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• Thread Safety-When multiple threads are working on same data, and the
value of our data is
changing, that scenario is not thread-safe and we will get inconsistent
results. When a thread is already working on an object and prevent
another thread on working on the same object is known as thread
safety. We can achieve Thread safety via Synchronization, Volatile
Keyword, Atomic variable, Final Keyword.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Array List:
• ArrayList<Object Type> ar = new ArrayList<Object Type>();
• ArrayList is Dynamic in nature.
• Virtual Capacity of ArrayList by default is 10 but Physical capacity if we did
not add any object is
0. Once we start adding Physical objects Virtual Capacity got decreased
by same.
Hashmap:
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
======================================================
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• boolean contains()
• toUpperCase() – convert to upper case
• toLowerCase() – convert to lower case
• trim() – remove spaces from both sides of string
• substring() -- returns part of string
• boolean endsWith()
• boolean startWith() – ends with specified suffix or not
• int length()
• replace()
• int num = Integer.parseInt(str);- Convert String to int using
Integer.parseInt(String)
• int num = Integer.valueOf(str);- Convert String to int using
Integer.valueOf(String)
• Convert int to String using String.valueOf()
String int ivar = 123;
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
System.out.println(555+str);
====================================================
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
if(element>max){ max=element;
}}
MIN
public class maxmin {
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
}}
====================================================
int l = arr.length;
arr[l-i-1]= temp;
for(int element:arr)
}}
====================================================
int k=Array.length-1;
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
for(k=Array.length-1;k>=0;k--){
}}
====================================================
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• How will you print length of string without using length method.
String str = “Pankaj”
Sysout(str.toCharArray().leng
th);
Sysout(str.lastIndexOf(“”));
Sysout(rev);
2.
Create a string-> create new stringBuffer and here you can apply reverse
fuction.
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
Sysout(str);
int rev = 0;
while(num !=0){
Sysout (rev)
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
• driver.getText();
• driver.findElement(B
y.id("findID")).
getAttribute("value");
• driver.getWindowHandle();
driver.findElement(By.partialLinkText(“abode”)).click();
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
driver.switchTo().frame(0);
• b) frame(Name of Frame)
driver.switchTo().frame(“name of the frame”);
• c) frame(WebElement element)
Select Parent Window
driver.switchTo().defaultContent();
• driver.quit();- closes all the windows that were opened by the WebDriver
instance
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics
kasperanalytics.com
9123820085
hr@kasperanalytics.com
kasper-analytics