0% found this document useful (0 votes)
3 views8 pages

Day 15 of 30

The document contains a series of automation testing interview questions and answers, covering topics such as design patterns, testing methodologies, and Java exceptions. Key concepts discussed include the Page Object Model, the 3 Amigos approach in Agile, and the differences between smoke and sanity testing, as well as regression and retesting. Additionally, it provides practical advice on implementing TestNG listeners for capturing screenshots on test failures and using the Maven Surefire Plugin for running tests.

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Day 15 of 30

The document contains a series of automation testing interview questions and answers, covering topics such as design patterns, testing methodologies, and Java exceptions. Key concepts discussed include the Page Object Model, the 3 Amigos approach in Agile, and the differences between smoke and sanity testing, as well as regression and retesting. Additionally, it provides practical advice on implementing TestNG listeners for capturing screenshots on test failures and using the Maven Surefire Plugin for running tests.

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

On Weekend

DAY 15 : Automation Testing Interview Questions

/Junaid Aziz /Qasim Nazir


On Weekend

Q : Which design pattern you have used in framework ?


Ans :
Page Object Model (POM)

 Description: Each web page in the application is represented as a class, and the web
elements on the page are defined as variables within that class. Actions that can be performed
on those elements are defined as methods.
 Benefits:
o Improves code readability and maintainability.
o Reduces code duplication.
o Easy to update in case of UI changes.

Factory Design Pattern

 Description: This pattern is used in combination with POM for creating page objects. The
@FindBy annotations are initialized using the PageFactory class.
 Benefits:
o Simplifies the object initialization process.
o Reduces boilerplate code.

Singleton Design Pattern

 Description: Ensures that only one instance of the WebDriver is created throughout the test
execution.
 Benefits:
o Prevents multiple WebDriver instances from being created unnecessarily.
o Saves memory and improves performance.

Q : Difference between Comparable and Comparator ?


Ans :
Comparable:

 Used to define the natural ordering of objects.


 Sorting logic is part of the class whose objects need to be sorted.

Comparator:

 Used to define custom sorting logic that can differ from natural ordering.
 Sorting logic is external to the class, often implemented in a separate class.

Q : What are cases where you will use finally block ?

Ans :
The finally block in Java is used to execute a block of code regardless of whether an exception is
thrown or not in the associated try block. It ensures cleanup or resource release operations are
performed, which is crucial for preventing resource leaks.

/Junaid Aziz /Qasim Nazir


On Weekend

Q : What is 3 Amigos ?

Ans :
3 Amigos is a collaborative approach often used in Agile development to ensure a shared
understanding of requirements and improve the quality of deliverables. It involves three key roles
working together—Business Analyst (BA), Developer (Dev), and Tester (QA)—to refine user stories,
clarify requirements, and plan testing strategies.

Purpose of 3 Amigos

The goal is to prevent miscommunication and reduce misunderstandings by involving all


perspectives in the development process, leading to:

 Better understanding of requirements.


 Improved acceptance criteria.
 Early identification of risks or ambiguities.
 Enhanced collaboration across roles.

Q : Smoke VS Sanity Testing , Regression vs Retesting .


Ans :
Smoke Testing vs. Sanity Testing
Aspect Smoke Testing Sanity Testing
Definition A preliminary test to check A narrow, focused test to
whether the critical ensure specific changes or
functionalities of the fixes work as expected.
application are working and if
it's stable enough for further
testing.
Purpose Verify the stability of the build Verify that specific functionality
for further testing. works after changes or fixes.
When Performed Conducted on a new build to Conducted after receiving a
ensure it is testable. build with minor changes or
bug fixes.
Scope Broad testing of major Narrow and focused testing of
functionalities. specific areas.
Depth of Testing Shallow and wide; does not go Deep and focused; checks
into details. functionality in detail.
Automation Suitability Often automated to save time. Can be automated but often
performed manually due to its
narrow focus.
Performed By Generally done by developers Usually performed by testers.
or testers.
Example Verifying login, navigation, and Checking if a bug fix in the login
main page loading after page resolves the issue without
receiving a new build. new defects.

/Junaid Aziz /Qasim Nazir


On Weekend

Regression Testing vs. Retesting

Aspect Regression Testing Retesting


Definition Ensures that recent changes or Verifies that a specific defect
fixes have not affected existing has been fixed in the latest
functionality. build.
Purpose Detect unintended side effects Confirm that the specific bug or
of changes. issue is resolved.
When Performed Conducted after any code Conducted after a defect is
change, bug fix, or fixed and a new build is
enhancement. received.
Scope Tests both the modified Focuses only on the specific
functionality and surrounding functionality or defect that was
features. fixed.
Test Cases Reuses existing test cases and Uses the same test cases that
may include newly created initially detected the defect.
ones.
Automation Suitability Highly suitable for automation, Usually done manually but can
especially for repeated tests. be automated if required.
Performed By Testers (can also involve Testers.
automation testers).
Example Ensuring that fixing a payment Verifying that the "Add to Cart"
gateway bug hasn’t affected issue reported earlier has been
the cart functionality. resolved.

Q : In TestNg how will you ensure that screenshots will be taken only for fail test cases.
Ans :

To ensure that screenshots are taken only for failed test cases in TestNG, you can use the IListener
Interface, specifically the ITestListener implementation. Here's a step-by-step guide to achieve this:

Steps to Take Screenshots for Failed Test Cases

1. Create a Listener Class: Implement the ITestListener interface and override the
onTestFailure() method to capture screenshots when a test case fails.
2. Write the Screenshot Logic: Use Selenium's TakesScreenshot interface to capture
screenshots in the onTestFailure() method.
3. Attach the Listener to Your Test Suite: Add the listener to your TestNG XML file or annotate
your test class with @Listeners.

Example :

Create a Listener Class

/Junaid Aziz /Qasim Nazir


On Weekend

@Override
public void onTestFailure(ITestResult result) {

captureScreenshot(result.getName());
}

try {

e.printStackTrace();
}

}
}
}

Attach Listener to Test Suite

public class YourTestClass {

Add to TestNG XML

<listeners>

</listeners>

<classes>

</classes>
</test>

/Junaid Aziz /Qasim Nazir


On Weekend

Q : What is maven surefire plugin ?


Ans :
The Maven Surefire Plugin is a plugin used in Maven to run unit tests, primarily for JUnit and
TestNG. It is designed to execute the test cases during the build process and provide feedback on the
tests' execution status. The plugin helps in running tests in a clean and consistent environment,
making it essential for continuous integration (CI) workflows.

Q : Explain how do you pick which test cases to automate ?


Ans :
1. Test Cases that are Repeated Frequently
2. Stable Test Cases
3. High-Risk Areas
4. Tests with Large Data Sets
5. Repetitive Test Cases
6. Non-UI Test Cases
7. Regression Testing
8. Tests that Require Cross-Browser or Cross-Platform Validation

Q : Write code to find Broken Links in Selenium


Ans :
To find broken links using Selenium in Java, we can use the WebDriver to fetch all the links on a
webpage, then send an HTTP request to each link to check if it is working (i.e., returns a successful
HTTP status code like 200). If the link returns a failure status code (e.g., 404 or 500), it's considered a
broken link.

ChromeOptions options = new ChromeOptions();

/Junaid Aziz /Qasim Nazir


On Weekend

try {

URL(url).openConnection();

httpURLConnection.connect();

if (responseCode >= 400) {

}
}

}
}

Q : You have 10 links how will you print title of each link using selenium. Give Optimal approach

Ans :

ChromeOptions options = new ChromeOptions();

/Junaid Aziz /Qasim Nazir


On Weekend

// Print the link text and href

if (linkHref != null ss !linkHref.isEmpty()) {

try {

}
}

}
}

Q : What is null pointer exception.


Ans :

A NullPointerException (NPE) in Java is a runtime exception that occurs when your code attempts to
use an object reference that has not been initialized or has been set to null. Essentially, it happens when
you try to call methods, access properties, or perform operations on an object that doesn't point to any
memory location (i.e., it is null).

/Junaid Aziz /Qasim Nazir

You might also like