You are on page 1of 17

4 Automation Interview Questions for Experienced Candidates:

1. Explain your current automation project.

2. Explain your automation framework. What are the core tools and supporting tools (if any)
implemented in your automation framework and why?

3. Explain the execution flow of your automation framework.

4. What was your approach towards creating automation scripts after receiving the first build of test
application?
i. Thorough testing is crucial to the success of a software product. If your software doesn’t work properly, chances are strong that
most people won’t buy or use it…at least not for long.
ii. But testing to find defects – or bugs – is time-consuming, expensive, often repetitive, and subject to human error.
iii. Automated testing, in which Quality Assurance teams use software tools to run detailed, repetitive, and data-intensive tests
automatically, helps teams improve software quality and make the most of their always-limited testing resources.
iv. In order for software testing to be successful and we get the maximum return on investment (ROI):
1. Decide what Test Cases to Automate
2. Test Early and Test Often
3. Select the Right Automated Testing Tool
4. Divide your Automated Testing Efforts
5. Create Good, Quality Test Data
6. Create Automated Tests that are Resistant to Changes in the UI

1. Decide what Test Cases to Automate


Most benefit out of your automated testing efforts by automating:
 Repetitive tests that run for multiple builds.
 Tests that tend to cause human error.
 Tests that require multiple data sets.
 Frequently used functionality that introduces high risk conditions.
 Tests that are impossible to perform manually.
 Tests that run on several different hardware or software platforms and configurations.
 Tests that take a lot of effort and time when manual testing.

2. Test Early and Test Often


 To get the most out of your automated testing, testing should be started as early as possible and ran as often as
needed.
 The earlier testers get involved in the life cycle of the project the better, and the more you test, the more bugs you
find.
 Automated unit testing can be implemented on day one and then you can gradually build your automated test suite.
 Bugs detected early are a lot cheaper to fix than those discovered later in production or deployment

3. Select the Right Automated Testing Tool

These key points when selecting an automated testing tool:


 Support for your platforms and technology. Are you testing .Net, C# or WPF applications and on what operating
systems? Are you going to test web applications? Do you need support for mobile application testing? Do you work with
Android or iOS, or do you work with both operating systems?
 Flexibility for testers of all skill levels. Can your QA department write automated test scripts or is there a need
for keyword testing?
 Feature rich but also easy to create automated tests. Does the automated testing tool support record-and-playback test
creation as well as manual creation of automated tests; does it include features for implementing checkpoints to verify values,
databases, or key functionality of your application?
 Create automated tests that are reusable, maintainable and resistant to changes in the applications UI. Will my automated
tests break if my UI changes?

4. Divide your Automated Testing Efforts

 Usually, the creation of different tests is based on the QA engineers’ skill levels.
 It is important to identify the level of experience and skills for each of your team members and divide your automated
testing efforts accordingly.
 For instance, writing automated test scripts requires expert knowledge of scripting languages. Thus, in order to perform
these tasks, you should have QA engineers that know the script language provided by the automated testing tool.
 You should also collaborate on your automated testing project with other QA engineers in your department.
 Testing performed by a team is more effective for finding defects and the right automated testing tool allows you to share
your projects with several testers.

5. Create Good, Quality Test Data


 Good test data is extremely useful for data-driven testing. The data that should be entered into input fields during an
automated test is usually stored in an external file.
 This data might be read from a database or any other data source like text or XML files, Excel sheets, and database tables.
 A good automated testing tool actually understands the contents of the data files and iterates over the contents in the
automated test.
 Using external data makes your automated tests reusable and easier to maintain.
 To add different testing scenarios, the data files can be easily extended with new data without needing to edit the actual
automated test.
 Creating test data for your automated tests is boring, but you should invest time and effort into creating data that is well
structured.
 With good test data available, writing automated tests becomes a lot easier. The earlier you create good-quality data, the
easier it is to extend existing automated tests along with the application's development.

6. Create Automated Tests that are Resistant to Changes in the UI


 Automated tests created with scripts or keyword tests are dependent on the application under test. The user
interface of the application may change between builds, especially in the early stages.
 These changes may affect the test results, or your automated tests may no longer work with future versions of
the application.
 The problem is automated testing tools use a series of properties to identify and locate an object. Sometimes a
testing tool relies on location coordinates to find the object.
 For instance, if the control caption or its location has changed, the automated test will no longer be able to find
the object when it runs and will fail.
 To run the automated test successfully, you may need to replace old names with new ones in the entire project,
before running the test against the new version of the application.
 However, if you provide unique names for your controls, it makes your automated tests resistant to these UI
changes and ensures that your automated tests work without having to make changes to the test itself.
 This also eliminates the automated testing tool from relying on location coordinates to find the control, which is
less stable and breaks easily.

5. Explain the process followed in your orgnization to deliver an automation project.


1. Convince the Management
2. Finding Automation tool experts
3. Using the correct tool for automation
4. Analyzing various applications to determine those which are best suited for automation
5. Training the Team
6. Creating the test automation Framework
7. Developing an Execution Plan
8. Writing Scripts
9. Reporting
10. Maintenance of Scripts

1. Convince the Management


 Tell them about the benefits of test automation in detail.
 Tell them, that test automation is expensive and it will cost you money initially but then the cost will be
reduced once scripts are prepared and start executing.
 Tell them that they have to wait for around 3 months before expecting any result from test automation.
 Tell them, that test automation is not to replace manual testers, but to aid manual testers as they will able
to test more at the same time.
 Test automation does not mean more testing in less time; it means more testing at the same time.

2. Finding Automation tool experts


There are two kinds of automation experts. 1. Automation architects 2. Automation engineers

Automation architects are experienced in different kinds of tools and they usually know the strengths and weaknesses of
each tool. They will also help the management in selecting the right tool for automation by carefully analyzing the
application and technologies used in that application.

Automation engineers, on the other hand, are the people who will convert manual test cases into automated scripts. They
will work under an automation architect and will be responsible for creating and executing scripts.

3. Using the correct tool for automation


The most important things to consider while selecting the right tools are:
1. The tool must be in your budget. The automation tools are really expensive. So the company should have the
budget to purchase the tool.
2. The tool must support technologies used in your application. If your application is using flash or Silverlight, the
tool must support it. If your application is running on mobile, the tool must be able to execute scripts on mobile.
You can purchase a single tool that supports all technologies used in your application or you can purchase separate
tools for each technology. For example, you can use selenium for your web applications, Robotium for your
Android applications and MS Coded UI for desktop applications. Whatever the decision, this should be in your
budget.
3. You must have the necessary skilled resources who can use this tool or learn that tool in less time. For example,
you have hired the automation architect who has only experienced in QTP, and you are purchasing a license for MS
Coded UI, the resource might not be comfortable using it. Tools are like good cars, but you must have good drivers
too to drive these good cars.
4. The tool must have a good reporting mechanism to show the results to stakeholders after each execution.

4. Analyzing various applications to determine those which are best suited for automation
The application which should be automated must have these factors:
1. The application should not be in the early stages of its development. (The application should have all or
some modules which are stable and tested by manual testers)
2. The UI of the application must be stable. (The UI must not change frequently)
3. The manual test cases of this application should be in written form.

5. Training the Team


 If manual testers are converted into automation engineers, they have to be trained on automation
terminologies and concepts.
 If automation architect is hired from outside, he must get knowledge about the product to test, the
manual testing process and what management is expecting.
 Give resources some time to try different things until they finally come up with a winning automation strategy.
 Train them on the tools which organization is already using bug tracking software and requirements management
software.

6. Creating the test automation Framework


 The biggest task for the automation architect is to come up with an automation framework that should
support automated testing for the long run.
 Automation framework is basically the set of rules and careful planning to write the scripts in a manner
which results in the least amount of maintenance.
 If anything changes in the application, the scripts need little or no updating to cope up with that change.
That is the beauty of an automation framework.

7. Developing an Execution Plan


 The execution plan includes selecting which environments the scripts will be executed. The environment includes
OS, Browser and different hardware configurations.
 EX: if the test case demands that it should check the website in 3 browsers, namely, Chrome, Firefox and IE, then
the automation team will write the script in such a manner that it will be able to execute in each browser.

8. Writing Scripts
 When the framework is designed, the execution plan is known and resources are trained on the new tool, now it’s
the right time to start writing scripts.
 Scripts should be written in an organized manner with proper naming convention.
 The source code should be maintained in a source control to avoid code loss.
 Version control and history should be maintained. Test automation is just like software development.
 All best programming practices should be taken care while writing the scripts.

9.Reporting
 The reporting feature is usually provided by the tool. But we can create custom reporting mechanisms like auto-
emailing the results to management.
 We can create reports at the end of each execution in the form of charts and tables if management needs it. The
management should always be informed about the test case coverage, that means which manual test cases are
covered in automation and which of them are remaining.

10.Maintenance of Scripts
 If best programming practices are followed and framework is good, then maintenance will not be a
problem.
 Maintenance usually occurs when there is a change request an application. The scripts should
immediately be updated to cope with that change to ensure flawless execution.

5. What are the set of steps followed by you after you vitness a failure in test suite execution?
i. When you have a Selenium test case that fails, the first thing you need to do is examine the stack trace returned by
Java (or the programming language you are using) and see what error occurred.
ii. Was it an Element Not Found exception? Element Not Interactable exception? Some other exception? This will
give you an idea of what happened.
iii. What you need to do is determine why the error is happening. Is there an error in the logic or flow of your Selenium
code? Is the error on your end? Then you’ll need to fix your test case and run it again.
iv. Did the error occur because some component has changed or disappeared? Did it’s ID or xPath change?
v. If yes then you’ll need to change your test case to reflect the changes in the system but only after verifying that the
change was really supposed to happen.
vi. Never change Selenium code that used to run properly without verifying that any given change is indeed correct.
vii. If no, then it’s a bug and you’ll fail your test case and leave your code as it is.
viii. You’ll either open a ticket or inform the proper team members. That’s because something changed that shouldn’t
have changed and you caught a regression.

7. How many builds did you receive in your project?

8. What approach do you follow to design an automation framework?


1. Check whether the application is compatible with Selenium or Not. The evaluation of Test Automation is
called as POC
2. Execute or Review all Manual Test Cases at-least once to get functional knowledge of Application and this
will help to identify feasible Test Cases for Automation (There are chances out of 100 TC, 60 TC can be
automated)
3. Provide Automation Estimation — How many days to automate for All or Selected Modules OR identified Test
Case
4. Identify and then develop the Framework for Project
5. Prepare Test Script for All identified Test Cases
6. Integrate Test Script with Framework for Execution
7. If any Build change is identified, update all Test Cases which will be impacted,
8. Capture Execution Summary report after execution is over. Share this report to Management.

9. How did you receive test build for your project?


 A build mainly contains the compiled package which could include the executable bat, exe, the libraries like dll, lib,
and archives like zip files. Development Team creates the build and provide it to the deployment team for
installation.
 The compilation of the source code is mainly taken care by the development team and after they have generated the
build, they place it at some specified location which is accessible by deployment team for deploying to a different
environment.
 Once the build is deployed, QA team is notified to do the build verification testing (BVT) and if it is successful, the
team performs the rest of the functional testing.
 Deployment is a process through which the code/build is moved from one environment to another. Most of the
organization these days follows a proper channel for the deployment, and maintains a separate team who takes care
of all these.

10. What was your approach to convert manual test cases into automation scripts?
 Useful to execute routine tasks like Smoke tests and Regression tests.
 Useful in preparing the Test data.
 Helps to execute the Test cases which involve complex business logic.
 Good to execute the cross-platform test cases (like different OS, browsers, etc.)
 Great to execute the test cases which are a bit difficult to execute manually.
 When the number of iterations of the test case executions is not known.

11. What were the technical challenges faced by your during your automation project?
1. Sync issue or Timeout
2. Integration with different tools
3. Smart locators
4. Cross browser testing
5. Framework enhancement
6. Pop up handling
7. Complex Programming

1. Sync issue or I would say timeout issue is one of the most challenging tasks in any test automation tool. If we
do not handle sync issue then most of the script will fail. In one of the test survey, it as found that 80% of
scripts fail due to improper syn while performing actions.
We can avoid this by using smart wait which is present in Selenium like implicit wait, explicit
wait, fluent wait or even you can write your custom method which will handle this sync issues.

2. Since Selenium is an open source and we all are using many open source like Maven, Jenkins, AutoIT etc. so
integration between all tools is sometimes a very challenging task.

3. As we all know that locators are the core part of any scripting and We need to keep on enhancing our XPath and CSS for
script stability because if XPath and CSS are not proper then it fails in upcoming releases.
We should always write dynamic or custom XPath or class which can make our script more stable.

4. While designing we always focus on one browser and we design our script for that browser only but when it comes
to real execution of the script then we have to make sure that our script should run in all browser which is known
as Cross Browser Testing (Chrome, FF, IE at least).
I had been struggling with this because few locators will work in one browser but not on the other. In order to avoid
failure once the script is developed keep on running them on the different browser and analyze the result. If it is failing
on another browser then we need to change locator strategy.

5. We always work for the framework but framework designing and maintenance is not a one-day activity we
have to keep on adding new features or library so that we can minimize execution time and maintenance task.

6. In many application, you will find random pop keeps coming and their behavior is not persistence so we also
have to take care of these unwanted pop up which stops our execution.

7.Selenium support multiple languages and in order to work we should know at least one programming
language so in order to build a framework we need some expertise in a specific language

12. A few real time scenarios to write automation scripts.


1) Automated Test Case Scope is High than Manual Test Case. ...
2) Test Data is not mandatory for every Test Case. ...
3) Prepare Expected Test Result. ...
4) Conduct Positive and Negative Testing. ...
5) Negative Testing is bigger than Positive Testing.
Automated Test Case Scope is High than Manual Test Case
Generally, in a Manual Test Case we insert/use one or two verification points only, because human user can’t concentrate
on multiple verification points at a time during Test Execution.
In an Automated Test Case/Test Script we can insert multiple verification points, Test Tool can concentrate on multiple
verification points at a time during Test Execution, because Test Tool is Software, It can concentrate on multiple tasks at a
time.
So Automated Test Cases / Test Scripts scope is high than Manual Test Cases, Suppose if you want to automate 100 Manual
Test Cases, 100 Automated Tests are not required using a few Automated Tests you can automated those Manual Test
Cases.
Test Data is not mandatory for every Test Case
Input or Test Data is required for some Test Cases only, not required for all Test Cases, for ex: if you want to execute Login Test
case, for that Login credentials (Username, Password) are required, Suppose you want verify particular element existence in a
web page, for that no input is required.

Prepare Expected Test Result


Generally we prepared Expected Result for Test cases using our Requirements, but if an expected result is related to
Application design then we need to collect that expected result from Developers

Conduct Positive and Negative Testing


Completeness of Software Testing is Positive Testing and Negative Testing, we use valid input to conduct Positive Testing
and invalid input for Negative Testing, suppose if there is no Test Data/Input for our Test Case then how to conduct
Negative Testing? by using incorrect Expected Result we can conduct Negative Testing for those Test Cases.

Negative Testing is bigger than Positive Testing


We already disused that Completeness of Software Testing is Positive and Negative Testing, Suppose for valid input and
operations our application is working fine, but what about handling the invalid input and invalid operations. It has to accept
valid input and operations and prevent invalid and input and operations.

13. What locators were most used by you in your automation project.
A locator should be as small as possible

A locator should not get effected by changes to its parents

A locator should survive changes to its own properties

14. What java oops concepts have been implemented in your automation framework and scripts?
ABSTRACTION: In Page Object Model design pattern, we write locators (such as id, name, xpath etc.,) in a Page Class.
We utilize these locators in tests but we can’t see these locators in the tests. Literally we hide the locators from the
tests.
Abstraction is the methodology of hiding the implementation of internal details and showing the functionality to the users.

INTERFACE Basic statement we all know in Selenium is WebDriver driver = new FirefoxDriver();
WebDriver itself is an Interface. So based on the above statement WebDriver driver = new FirefoxDriver(); we are
initializing Firefox 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 as mentioned earlier and FirefoxDriver is a
class.
An interface can have methods and variables just like the class but the methods declared in interface are by default abstract.
We can achieve 100% abstraction and multiple inheritance in Java with Interface.

INHERITANCE We create a Base Class in the Framework to initialize WebDriver interface, WebDriver waits, Property
files, Excels, etc., in the Base Class.
We extend the Base Class in other classes such as Tests and Utility Class. Extending one class into other class is known as
Inheritance.

POLYMORPHISM Combination of overloading and overriding is known as Polymorphism. We will see both overloading
and overriding below.
Polymorphism allows us to perform a task in multiple ways.
METHOD OVERLOADING We use implicit wait in Selenium. Implicit wait is an example of overloading. In Implicit wait
we use different time stamps such as SECONDS, MINUTES, HOURS etc.,
A class having multiple methods with same name but different parameters is called Method Overloading

METHOD OVERRIDING We use a method which was already implemented in another class by changing its parameters.
To understand this you need to understand Overriding in Java.
Declaring a method in child class which is already present in the parent class is called Method Overriding. Examples are
get and navigate methods of different drivers in Selenium .

ENCAPSULATION All the classes in a framework are an example of Encapsulation. In POM classes, we declare the data
members using @FindBy and initialization of data members will be done using Constructor to utilize those in
methods.

Encapsulation is a mechanism of binding code and data together in a single unit.

WEB ELEMENT: Web element is an interface used to identify the elements in a web page.

WEBDRIVER: WebDriver is an interface used to launch different browsers such as Firefox, Chrome, Internet Explorer,
Safari etc.,

FIND BY: FindBy is an annotation used in Page Object Model design pattern to identify the elements.

FIND ELEMENT: Find Element is a method in POM to identify the elements in a web page.

15. Explain TestNG annotations hierarchy. What is the difference between @BeforeTest and
@BeforeMethod?

@BeforeTest - The annotated method will be run before any test method belonging to
the classes inside the <test> tag is run.

@BeforeMethod - The annotated method will be run after all the test methods in the
current class have been run.

So, BeforeTest will be initiated before execution of selected package or classes or


methods inside <test> tag starts.

On other hand, @BeforeMethod will be executed just before any function/method with
@Test annotation starts.
16. Why did you use TestNG as a core tool in your automation framework?
TestNG is a testing framework inspired from JUnit and NUnit with more functionality added to make execution more
efficient and powerful. It is an open source automated testing framework. It is similar to JUnit but it is more powerful than
JUnit. TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more
flexible and powerful tests with help of easy annotations, grouping, sequencing & parameterising.
Benefits of TestNG
Major advantages of testing are:
• Logs can be generated
• Annotations make code efficient and easy to manage
• Ability to produce HTML Reports of execution
• Test cases can be Grouped & Prioritised
• Parallel testing is possible
• Data Parameterization is possible

17. What is your approach to reduce total execution time of your entire test suite?

The Selenium WebDriver scripts are very slow because they run through the browser.

There are multiple things that can improve the Selenium WebDriver scripts’ speed:

1. use fast selectors


2. use fewer locators
3. create atomic tests
4. dont test the same functionality twice
5. write good tests
6. use only explicit waits
7. use the chrome driver
8. use drivers for headless browsers
9. re-use the browser instance
10. run scripts in parallel
11. use HTTP parse libraries
12. pre-populate cookies
13. do not load images in the web page

18. What is parameterization in TestNG?


Parameterization in TestNG using testng. ... TestNG allows the user to pass values to test methods as
arguments by using parameter annotations through testng. xml file. Some times it may be required for us
to pass values to test methods during run time.

19. Can you perform parallel execution on multiple instances of same browser?
TestNG is a testing framework for Java that helps to organize tests in a structured way and enhances maintainability and
readability to the scripts. TestNG has made it easier for automation testers owing to its large feature set. One of which is
parallel testing or parallel execution. TestNG provides an auto-defined XML file, where one can set the parallel attribute to
method/tests/classes and by using the concept of multi-threading of Java, one can set the number of threads, one wants to
create for parallel execution. Below is the structure for defining this attribute in the TestNG XML:
The parallel attribute can be extended for multiple values, as below:
 Methods: Helps run methods in separate threads
 Tests: Help to run all methods belonging to the same tag in the same thread
 Classes: Helps to run all methods belonging to a class in a single thread
 Instances: Helps run all methods in the same instance in the same thread

20. Write a code to capture application page screen shot in case of failure in automation test.
import java.io.File;import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

public class Utility


{ public static void captureScreenshot(WebDriver driver,String screenshotName)
{
try
{ TakesScreenshot ts=(TakesScreenshot)driver;

File source=ts.getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(source, new File("./Screenshots/"+screenshotName+".png"));

System.out.println("Screenshot taken");
}
catch (Exception e)
{
System.out.println("Exception while taking screenshot "+e.getMessage());
}}}

21. What is testng listener and how can you implement it in your framework?
TestNG listeners in Selenium WebDriver, some of them are used very frequently by the testing community & some are
almost forgotten. In this TestNG tutorial, I will demonstrate the most popular TestNG listeners with examples but before
that, let me enlist the various TestNG listeners in Selenium WebDriver.
1. ITestListener
2. IAnnotationTransformer
3. IInvokedMethodListener
4. ISuiteListener
5. IReporter
6. IConfigurable
7. IExecutionListener
8. IHookable
9. IMethodInterceptor
10. IConfigurationListener
1. ITestListener is the most adopted TestNG listener in Selenium WebDriver. Providing you with an easy to implement
interface through a normal Java class, where the class overrides every method declared inside the ITestListener. Following
are some methods provided by this interface:
onStart: This method is invoked before any test method gets executed. This can be used to get the directory from where
the tests are running.

onFinish: This method is invoked after all tests methods gets executed. This can be used to store information of all the tests
that were run.

onTestStart: This method is invoked before any tests method is invoked. This can be used to indicate that the particular
test method has been started.

onTestSkipped: This method is invoked when each test method is skipped. This can be used to indicate that the particular
test method has been skipped.

onTestSuccess: This method is invoked when any test method gets succeeded. This can be used to indicate that the
particular test method has successfully finished its execution.

onTestFailure: This method is invoked when any test method gets failed. This can be used to indicate that the particular
test method has been failed. You can create an event of taking a screenshot which would show where the test has been
failed.

onTestFailedButWithinSuccessPercentage: This method is invoked each time the test method fails but is within the
success percentage mentioned.

2. IAnnotationTransformer

IAnnotationTransformer is an interface that provides a method “transform” which would get invoked by TestNG to modify
the behaviour of Test annotation method in our test class. The transform method provides various parameters:
annotation: The annotation that would get read from the test class.
testClass: If the annotation found on a class, this parameter would represent that same class.
testConstructor: If the annotation found on a constructor, this parameter would represent that same constructor.
testMethod: If the annotation found on a method, this parameter would represent that same method.

3. IInvokedMethodListener
This interface allows you to perform some action before and after a method has been executed. This listener gets invoked
for configuration and test methods. This TestNG listener in Selenium WebDriver works same as the ITestListerner and the
ISuiteListerner. However, there is a difference that you should make a note of & that is, in IInvokedMethodListener, it
makes the call before and after every method.

There are two methods to be implemented: beforeInvocation(): This method is invoked prior every method.

afterInvocation(): This method is invoked post every method.

4. ISuiteListener
This TestNG listener in Selenium WebDriver is implemented at a suite level called ISuiteListener. It has 2 methods:
onStart: This method is invoked prior the test suite execution.
onFinish: This method is invoked post the test suite execution.
This listener basically listen to the events to have occurred before and after the execution of the suite.If the parent suite
further contains child suites then child suites are executed before running the parent suite.

5.IReporter
This TestNG listener in Selenium WebDriver provides an interface which helps you to customize the test report generated
by TestNG. It provides generateReport method which would get invoked after execution of all the suites. The method
further contains three parameters:
xmlSuite: it provides you with a list of multiple suites presented in the testng xml file that goes under execution.

suites: This object represents a great deal of information about the classes, packages, test execution result, along with all
the test methods. Basically, it represents detailed information around the suite after the final execution.

outputDirectory: contains the output folder path where the report gets generated.

6. IConfigurationListener
This TestNG listener in Selenium WebDriver is used to create an event only when the configuration method is passed,
failed or skipped. Below are the unimplemented methods provided by this listener:
onConfigurationSuccess: It gets invoked when the configuration method gets succeeded.
onConfigurationFailure: It gets invoked when the configuration method gets failed.
onConfigurationSkip: As the name suggests, when your configuration method is skipped, it calls for onConfigurationSkip
method.

7. IExecutionListener
This listener is used to keep track when the test or suite run start and finish. It provides two methods:
onExecutionStart: It is invoked before the suite or test starts running.
onExecutionFinish: It is invoked after the suite or test gets executed.
Note: It is not possible for this listener to prevent the execution but only to create events in some way. Also, you can
provide more than one “IExecution” listener as you configure TestNG.

8. IHookable
This interface skips the invocation of test methods and provides a run method which gets invoked instead of each @Test
method found. The test method is then invoked once the callBack() method of the IHookCallBack parameter is called.
IHookable listener is utilized when you wish to perform testing on classes which require JAAS authentication. This can be
used to set permissions i.e. for whom the test method should run and when the test method should get skipped.

9. IMethodInterceptor
→To return the list of IMethodInstance, post-execution of TestNG.
→ To sort the list of test methods.
TestNG would execute the tests methods in the same order defined in the returned value.
IMethodInterceptor interface includes only one method to implement “intercept” which returns the modified list of test
methods.

10. IConfigurable
The ICongurable listener is somewhat similar to IHookable listener. This interface skips the invocation of test methods and
provides a run method which gets invoked instead of each configuration method found. The configuration method is then
invoked once the callBack() method of the IConfigureCallBack parameter is called.

23. How is pom.xml linked to testng.xml file while test suite execution when you give a maven run
to your project?

24. What was the total number of automation scripts in your project and how many did you write?

25. What was the total execution time of your automation test suite?

26. How can you re-execute only failed and skipped test scripts automatically after end of the test
suite execution?
Case 1: Execute failed test cases using TestNG in Selenium – By using “testng-failed.xml”
Steps To follow: 1.After the first run of an automated test run. Right click on Project – Click on Refresh
2. A folder will be generated named “test-output” folder. Inside “test-output” folder, you could find “testng-failed.xml”
3. Run “testng-failed.xml” to execute the failed test cases again.
Case 2: Execute failed test cases using TestNG in Selenium – By Implementing TestNG IRetryAnalyzer.
Create a class to implement IRetryAnalyzer. Here I am creating a class (say, RetryFailedTestCases) and implementing
IRetryAnalyzer.
Let’s create another class ‘RetryListenerClass’ by Implementing ‘IAnnotationTransaformer’ interface. transform method is
called for every test during test run.
A simple implementation of this ‘IAnnotationTransformer’ interface can help us set the ‘setRetryAnalyzer’ for
‘ITestAnnotation’.
Add the above class name (RetryFailedTestCases.class) in the below program. This interface does its work in run time by
adding annotation to the test methods.

27. Which version of selenium have you worked with? How do you capture the entire web page screen shot in
selenium latest version?

[Test]
public void TakingWebDriverScreenshot()
{
using (var driver = new InternetExplorerDriver())
{
driver.Navigate().GoToUrl(@"https://automatetheplanet.com");
var screenshot = ((ITakesScreenshot)driver).GetScreenshot();
var tempFilePath = Path.GetTempFileName().Replace(".tmp", ".png");
screenshot.SaveAsFile(tempFilePath, ScreenshotImageFormat.Png);
}
}

28. Write an xpath to select all the elements present in a webpage.

29. What could be the reason for a button not being clicked using all the possible locators?What will
be your approach to click on a button if the provided xpath or any other locator is not working?
30. What approach have you used in your project to achieve synchronization?

31. Which attribute you should consider throughout the script in frame for “if no frame Id as well as
no frame name” is available?

32. Explain what is Datadriven framework and Keyword driven?

33. Explain how you can handle colors in web driver?

34. How do you handle frames in selenium?


35. What were the different Selenium exceptions handled by you in your automation project?

36. Give a real time example of abstraction.

37. What is static keyword in java and a basic code question on same.

38. Have you used collections concepts in your project?

39. What is String in java and how does it differ from String Buffer and String builder?

40. What is the difference between creating String as new() and literal?

41. What is constructor chaining in java?

42. Give a real time example of auto upcasting in your automation project.

43. Pattern programs.

44. Difference between final, finalize and finally?

45. Difference between poll() and remove() method?

46. How do you print Array in Java?

47. Write code to remove elements from ArrayList while iterating?

48. How to extract only numeric digits in a given String?

49. What is the interface? Why you use it if you cannot write anything concrete on it?

50. Which Java design pattern have you used in your automation framework and why?

51. What is Stale Element Reference Exception ?How do you handle it in selenium?

You might also like