Automation Testing Interview Questions and Answers
Complete List of Automation Testing Interview Questions and Answers for Beginners to Advanced level.
1. What is a Framework?
A set of rules which we can follow in a systematic way to achieve the desired results.
A set of guidelines, assumptions, concepts, and coding practices for creating an execution environment in which the tests will be automated.
2. Examples of Test Automation Frameworks?
Hybrid Testing Framework
Data-Driven Testing Framework
Behavior Driven Development Framework
Modular Testing Framework
Keyword Driven Testing Framework
3. Why to use a Framework?
In order to organize and manage all the files used in the project and to finish all the tasks in a systematic way.
4. Good coding practices while automation?
Run your scripts regularly.
Follow the language-specific coding conventions.
Maintain the test data in a separate file.
Add appropriate comments.
Identify the reusable methods and write them in a separate file.
5. Which test you think should not be automated?
Test which is executed quickly manually.
6. How to select an automation tool?
Consider the below factors:
Type of support available for the tool.
The scope of the application which we want to automate.
Time to learn and implement the tool.
Limitation of the tool
Management overhead like cost and budget.
7. List the Important modules of an automation testing framework?
Build Management Tool:
The framework needs to be built and deployed for the use of creating test scripts.
For thise test case which needs to take the user data, Frameworks data module should take care of the data intake for test scripts and the global variables.
A reporting tool is required to generate a readable report after the test cases are executed for a better view of the steps, results, and failures. It should be an emailable report.
Test Assertion Tool:
This tool will provide assert statements for testing the expected values in the application under test. For Example. TestNG, Junit, etc.
The logging tool in the framework helps in better debugging of the error and bugs. For Exaple. Log4j
Continuous integration tool:
With CICD in place, a continuous integration tool is required for integrating and deploying the changes done in the framework at each iteration. For Exaple Zenkins
8. What is browser automation?
We programmatically launching a web application in a browser and automatically executing various actions, and test cases. Browser testing gives you the speed and efficiency that would be not possible for a human tester.
Examples: Protractor, Cypress, and Selenium
9. What are the basic activities performed in browser automation?
Launch multiple instances of the browsers with different test users and ensure that concurrent actions work as expected.
Navigate to the application URL and make sure it launches
Test the various links on the web page and ensure they are not broken.
Perform load and performance testing on your web application.
Keep a record of the broken links on the page.
10. Explain cross-browser testing?
The goal of the cross-browser testing is to launch the application on various browsers running on different operating systems, e.g. Windows, Mac OS, Linux, etc., and verify that the application works as expected. The tester looks for the design/rendering issues, the functionality of the application, and device-specific functionality.
Cross-browser testing is a type of browser automation testing where the tester verifies if the web application will work smoothly on different browsers. Some of the popular browsers include Google Chrome, Mozilla Firefox, Safari, etc
11. Importance of cross-browser testing?
With web applications, you don’t know in advance which browsers your users will use. Hence, it’s crucial to test the web application or the website on multiple major browsers running on different operating systems.
12. What is automated regression testing?
In regression testing, we make sure that the new features didn’t break any existing functionality.
Its goal is to ensure that previously developed and tested functionality still works after adding new code.
In automated regression testing, a tester runs the suite of regression tests after each new release of the software. If the tests pass, then the tester continues with other types of testing. However, if it fails, then there is no point in further proceeding with tests until the developers fix the broken regression tests. Hence, they also act as a time-saver for the tester and ensure quality in software before shipping it.
13. What are some of the best practices in test automation?
Decide what to automate
Assign test cases based on skill and experience
Whenever new bugs are found by the automation tool or by the testers, they should be recorded in a bug tracking tool with the exact steps to reproduce the bugs and other details.
It’s not possible or practical to automate certain tests, such as usability, accessibility, exploratory testing, or non-repetitive test cases that frequently change.
Choosing the right frameworks and tools
Removing Uncertainty: The whole goal of test automation is to have reliable, accurate, consistent tests that provide helpful feedback to the tester.
14. Steps to automate basic login functionality.
1. Understand requirement
2. Prepare the test scenarios
For login functionality, the possible test scenarios are:
Blank username and password
Invalid username and password
A valid username and invalid password
Valid username and password
3. Prepare a Data input file as per the scenario.
4. Launch the tool from the program.
5. Identify the web element username field, password field, and the login button.
6. For each test scenario, get the data from the data file and enter into the corresponding fields. Program click on the login button after entering the data.
7. Validate the error message for negative scenarios and the success message for positive scenarios in the test script using assertions.
8. Run the test suite and generate the report.
15. What are some development practices to follow while performing automation?
The software development rules apply when writing automated tests.
Validating the tests failure
The test should fail if the feature under test doesn’t meet the criteria.
A test that never fails is worse than having no tests, as it gives a false assurance that the feature is working.
Don’t Repeat Yourself (DRY)
Avoiding duplication in code is crucial.
The benefit of this strategy is that the change is isolated to a single location, preventing bugs and errors.
Keep Functions Small
Since the testers who are creating automated tests are not familiar with good coding standards, it’s easy to fall into the trap of creating giant functions that try to do everything.
This quickly results in unmaintainable code that the team is afraid to touch when the requirements change, resulting in out-of-date tests that test the legacy behavior of the system.
Write Good Documentation
Important for everyone who try to understand the tests.
It can also help the person who wrote the tests when they try to modify/understand the tests in the future.
16. What framework you have used in your current Project?
We have used TestNG as a unit testing framework with a Data-driven approach & design pattern used is Page Object Model.
17. What is a singleton design pattern?
In Java then you must have used new keyword. This new keyword creates an Object of class whenever required. But there are some scenarios where you don’t want to create individual objects for different purposes. Singleton Pattern ensures that one and only one object is instantiated for a given class. Whenever the object of a given class is required, only single(No more than one object) Object get returned
We will create a private Constructor and also a static method to create object of the same class.
18. Can you achieve the Singleton design pattern using final keyword?
19. What did you keep in excel and .properties?
In Excel, we keep all the data, such as multiple combinations of user names and passwords.
In the properties file, we keep xpaths, URL, default username and password, etc.
20. Give me few points about what is the use of the Framework.
- Reusability of code
- Maximum coverage
- Recovery scenario
- Low-cost maintenance
- Minimal manual intervention
- Easy Reporting
21. Have you tested in different browsers? If yes how?
Yes, this can be done in two ways,
1) We can pass the browser names in Framework itself through CONFIG.Properties file (it will be sequential execution).
2) By using Grid we can test our application in multiple Browsers at a time (it will be parallel execution).
22. Once a framework is developed will you do any changes to the framework?
Yes. There could be few changes related to reports. There could be a few enhancements or changes in methods.
23. What are the components of the framework?
General Framework components:
Properties files, configuration files, Datasheets, Testbase class, Utilities Class, Test cases, Reports, Logs
24. Can you brief me about yourself?
Hi, my name is James Bond.
I started my career as a Testing Executive 4.5 years back with Infosys currently I am working as Test Engineer.
My responsibility is to understand Business Requirement specifications and High-Level scenarios and to convert them into test cases & Automation scripts if required. Execution of test cases and reporting of defects to the developer if there any and get them fixed. I have experience in Functional, Automation, Regression, Smoke, Sanity, Web accessibility, Web Analytics, Mobile Testing.
In my previous project, I have worked on Automation testing where we have used Selenium with java and TestNG Cucumber framework for the BDD approach. We have used the Page object model where we have separated our test cases with page objects, and we performed testing on the same. For the build management tool, we are using Maven for version controlling we are using Git, and for automating our jobs for a 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 BrowserStack, DeviceAnywhere, Toadsql,
I am working in an Agile environment we have daily standup calls and we have a 2-week sprint cycle. I am part of an 8-member team out of which we are 3-Tester, 2- dev, 1- manager, 1-scrum master.
25. Tell me your Day to Day activities as QA?
First thing I do after login in to 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. The 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 a test case, Execution, Defect retesting if any.
26. Do you have created a 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.
27. How much do you rate yourself in Java out of 10?
Out of 10, I will rate myself 6 in java as a QA Automation engineer.
28. Can you tell me Oops concepts and relate them 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 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.
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.
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.
Polymorphism allows us to perform a single action in different ways. In Java polymorphism can be achieved in two ways:
1. Method Overloading:
When there are multiple methods with the 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.
2. 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).
29. How can you use the interface and how it is different from the 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.
30. 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.
Yes, we can, but we got one warning that you need to access it via Direct or By class name.
33. How to call non-static method and variable in java?
For calling non static method we need to create object first.
34. Can we overload & override the main method?
35. 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.
36. Can you convert string a =”110a” in integer?
No, we got NumberFormatException while converting the above string.
37. 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.
38. What do you mean by Exceptions in Java?
Exception is like any interruption in our normal flow. Like if we are running anything and we got issues in our script this is we called exception, we have 2 types of exception Run Time & Compile Time. (checked & Unchecked exceptions)
39. Can you tell me about the difference between Throw and Throws keywords?
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 might occur in that particular function. Throws keyword followed by instance name and Throw keyword is followed by class name of that exception.
40. How much do you rate yourself in selenium out of 5?
Out of 5, I will rate myself 3.5 in selenium.
41. Which locator you are using in your framework and why?
Mostly we used ID and Xpath because Id is the fastest and unique one and after that we prefer Xpath. Anyways we have other locators as well like CSS , class name, tag name, Link text, Partial Link text.
42. What is the difference between findelement & findelements?
findelement will give the first appearance of that element which matches our locator, whereas findelements will give us list of all the elements which is present over the webpage and matching our locator. And if we don’t find the element findelement will give us nosuchelementexception whereas findelements will return NULL/Empty list.
43. Why declaring the driver object as static in base class is not a good practice in selenium? What are the challenges we might face if we do the same?
If you perform sequential test case execution, then it will work perfectly. But when you do the same thing for parallel execution it will stop the execution because your first test case will use your driver object but at the same, another testcase running parallelly will also grab the driver object so it may through null pointer exception or may get some weird result and your script will fail. But if you want to declare driver object as static you can do. By defining local variable of driver object in each class.
44. What are the conditions that throws ClassCastException?
Integer to string, string is not a subclass of Integer, so a Class Cast Exception will be thrown. Object I = Integer.valueOf(42);
String s = (String)i;
45. Can you tell me how you will handle multiple windows 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.
46. How you will move from one window to another?
First we will check what all windows are open by using driver.getwindowhandles, to get set of opened windows , then I use iterator to iterate over each of the pages and inside for loop will check like Current URL matches with the excepted page, if match then switch to that window by using driver.switchTo(Destination window) -> to return back to main parent window use driver.defaultContent().
47. 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.
48. Can you tell me some exceptions in selenium?
NoSuchElementException, NoSuchWindowException NoSuchframeException, StaleElementReferenceException, TimeoutException.
49. Can you tell me about StaleElementReferenceException?
Stale means old or decayed, here it sounds like element which was present on that page is no longer there or decayed. To handle this, we can refresh the webpage before pointing to that element. We can write script for waiting via explicit wait by writing expected condition.refresh. Or we can go with page object model in that we can over come this stale element exception.
50. What do you mean by User Defined Exception?
User Defined Exception or custom exception is creating your own exception class and throws
that exception using ‘throw’ keyword. This can be done by extending the class Exception. … The keyword “throw” is used to create a new Exception and throw it to the catch block.
51. Can you tell me what is assert in TestNG?
Assert is like verification where we check like expected thing and actual thing are same or not.
52. Which assert you have used in TestNg?
We have used Hard assert and Soft assert, while applying Hard assert if we found any glitch in expected and actual then it will through exception and move to next @test while Soft assert it won’t give exception and move to next step of that test. And to get all the exceptions in console we need to write at the end assert.all.
53. Can you tell me about the order of TestNG annotations? @BeforeSuite
54. 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.
55. 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.
56. What is the difference between scenario & scenario outline?
When we have single scenario and we need to run it one time at that place we use Scenario.
If you want some parametrization or Data Driven testing at that time, we can use scenario outline where we have to use Example keyword like if we are running this scenario for 3 different data set like username & pass. so, it will run 3 times.
57. Can you tell me more about Background Keyword?
Background is used when we have some common Given part. Suppose we have pre-condition that we have to check this before each scenario. so in order to avoid rewriting same step we can write it in Background.
58. What is the use of Dry Run in cucumber?
Dry run is not running our whole application it will check whether all features are mapped with Step definition.
59. What is hooks in cucumber?
In cucumber we use hooks for common functionalities, hooks are like we want to run before & after each of the scenario. In hooks we have 2 different @before, @ after which run before and after of each scenario. Also @beforestep, @afterstep which run before and after each step.
60. 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.
61. 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.
62. Can you explain me TestNG?
TestNG is advanced version of Junit only. It is mainly used by Dev/QA 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.
63. How to run single method multiple time in TestNG?
We have invocation count attribute in @test annotiation. We can write invocation count as 3 if we want to run it 3 times. Apart from that we can write threadpull.size if we want to run that case in multiple thread.
64. 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.
65. 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.
66. How to solve Merge conflict in GIT?
As we are only 2 tester working on this project, if we have any merge conflict I used to pull all the latest file/scripts to my local system. Then I will analyze the difference between that particular file and merge file. After that I will check with my team member whether all his imp things are covered then I will add my steps and push the script to the central repo.
67. 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.
68. What is the difference between Smoke & Sanity Testing?
Smoke and Sanity we can are like same thing because both are checking important functionality. Smoke testing is done on first stable build from developer to check like whether it is stable enough to move further or not. While Sanity testing is subset of regression test which we perform on stable build and here also we used to check all the imp functionality.
69. What is Agile ceremony?
We have 4 Agile ceremony -Sprint planning, Sprint review, Sprint Retrospective, Daily scrum meeting.
70. Why the main method is static?
Java main() method is always static, so that compiler can call it without the creation of an object or before the creation of an object of the class. Static method of a class can be called by using the class name only.