Friday, July 17

Testing Profile Q&A

 Scenario 1: Handling Conflicts Within the Team

Q: One of your QA team members is in constant disagreement with a developer, leading to delays. How do you handle it?

A:"I would begin by speaking to both parties individually to understand their perspectives without judgment. Then, I’d arrange a joint meeting to mediate and identify the root cause—often it's either unclear requirements or misaligned expectations. I’d ensure both sides agree on common ground and establish a more collaborative process—like using clearly defined acceptance criteria, improving documentation, or involving both roles early in the sprint planning. Building mutual respect is key."

 Scenario 2: Sprint Ends and Bugs Are Still Open
Q: Your sprint is ending, but several high-priority bugs are not fixed. What will you do?

A:"I’d prioritize the bugs based on severity and risk. I would collaborate with the PO and developers to assess if any of them are showstoppers. If so, I’d escalate and recommend a release delay. If not, I’d document the risks, and plan a hotfix or patch post-release. Retrospectively, I’d analyze why we couldn’t close these in time—maybe insufficient test planning or late builds—and adjust our processes accordingly."

 Scenario 3: New QA Joins During a Critical Phase
Q: A new QA joins your team in the middle of a high-pressure release. How do you onboard them effectively?

A:"I’d provide a concise onboarding kit with the test strategy, application architecture, and critical test cases. I’d assign a mentor and give the new member manageable tasks that contribute to the release (like regression testing). Meanwhile, I’d keep the pressure off them for the first sprint so they can learn the environment properly. Clear documentation and buddy support are key in such fast-paced situations."

 Scenario 4: Automation vs. Manual Testing Conflict
Q: Developers push for full automation, but your team says manual testing is still necessary. What’s your stance?

A:"I’d advocate a balanced approach. Automation is ideal for regression, repetitive flows, and CI/CD pipelines, but manual testing is critical for exploratory, usability, and complex scenarios. I’d present metrics and examples showing where automation saves time and where manual testing finds edge-case bugs. It’s not a conflict—it’s about aligning the right tool with the right task."

 Scenario 5: Pressure from Management for Faster Releases
Q: Management wants faster releases but your QA team is concerned about quality. How do you handle it?

A:"I’d highlight the potential risks of cutting QA cycles using data—like bug leakage rate, customer impact, etc. Then, I’d propose solutions like increased automation, parallel testing, or risk-based testing to speed up the process without sacrificing quality. Communicating the value of QA through KPIs helps bridge this gap. I’d also work with product and development to plan better so quality isn’t compromised."

 Scenario 6: Team Morale is Dropping
Q: Your QA team is demotivated due to repetitive work and lack of recognition. What would you do?

A:"I’d talk to the team to understand specific concerns. Then I’d rotate responsibilities, include team members in sprint demos or decision-making, and advocate for automation or tools that reduce repetitive tasks. Publicly recognizing efforts in team meetings or via company-wide channels helps too. A motivated QA team is one that feels valued and challenged."

 Smoke Testing Interview Questions & Answers

  1.  What is Smoke Testing?

Answer:Smoke Testing is a preliminary testing process where the basic and critical functionalities of an application are tested to ensure the build is stable enough for further testing. It's often called “build verification testing” and acts as a gatekeeper to deeper functional testing.

  1.  Why is Smoke Testing important?

Answer:Smoke Testing helps identify critical issues in the early stages of testing. It prevents wasted effort by ensuring that QA doesn't spend time testing a broken build. It’s quick and cost-effective and helps maintain the quality of builds delivered from development.

  1.  When is Smoke Testing performed?

Answer:Smoke Testing is typically performed after a new build is deployed to QA but before any detailed functional or regression testing. It happens at the beginning of each test cycle.

  1.  Who performs Smoke Testing — Developer or QA?

Answer:Typically, the QA team performs Smoke Testing. However, in some agile or DevOps environments, developers may perform a pre-check (called sanity or developer smoke test) before handing off the build to QA.

  1.  What are some examples of Smoke Tests?

Examples:

  • Can the application launch successfully?
  • Can a user log in with valid credentials?
  • Is the home/dashboard page loading?
  • Can navigation between key modules (like product list, cart, checkout) happen?
  • Are APIs returning a 200 status code?
  1.  What is the difference between Smoke Testing and Sanity Testing?

Answer:

FeatureSmoke TestingSanity Testing
PurposeTo verify build stabilityTo verify bug fixes or new functionality
DepthShallow and wideNarrow and deep
Performed when?Initial build deploymentAfter receiving minor changes/fixes
Automation Ready?Yes – often automatedSometimes – but mostly manual
  1.  Is Smoke Testing manual or automated?

Answer:Smoke Tests can be both manual and automated. In modern CI/CD pipelines, smoke tests are often automated and run immediately after a build is deployed to staging or QA environments.

  1. How do you select test cases for Smoke Testing?

Answer:We select high-priority test cases that cover core functionality, such as login, navigation, data retrieval, and basic CRUD operations. The goal is not to find every bug but to ensure the system is not critically broken.

  1.  How do you handle a failed Smoke Test?

Answer:If a smoke test fails, we reject the build and report the issues to the development team. We stop further testing until the critical issues are resolved and a stable build is provided.

  1.  What tools can be used for Smoke Testing?

Answer:

  • For Web: Selenium, Cypress, Playwright
  • For API: Postman, REST Assured
  • In CI/CD: Jenkins, GitHub Actions, Azure DevOps pipelines
  • Reporting: Allure, TestNG, JUnit, Extent Reports

 Sanity Testing – Interview Questions & Answers

  1.  What is Sanity Testing?

Answer:Sanity Testing is a type of software testing performed after receiving a new build or bug fix to verify that specific functionalities are working as expected and that recent changes have not broken existing functionality. It’s a focused subset of regression testing.

  1.  How is Sanity Testing different from Smoke Testing?

Answer:

FeatureSmoke TestingSanity Testing
PurposeVerify stability of the entire buildVerify specific functionality or bug fix
CoverageBroad and shallowNarrow and deep
When performedInitial build verificationAfter minor bug fixes or changes
AutomationOften automatedMostly manual, but can be automated
Decision FocusBuild acceptanceFunctionality verification
  1.  When do you perform Sanity Testing?

Answer:Sanity Testing is performed after receiving a new build with minor changes or after bug fixes to confirm that the reported issue has been resolved and no related functionality is broken.

  1.  Who performs Sanity Testing?

Answer:Sanity Testing is generally done by QA testers who are familiar with the application modules affected by recent changes.

  1.  What’s an example scenario of Sanity Testing?

Example:If a bug was reported that “users can't update their email address,” after a fix is implemented, Sanity Testing will:

  • Confirm the email update is working.
  • Check if the updated email reflects in the user profile.
  • Optionally verify that login/logout still works with the new email.
  1.  Is Sanity Testing documented with test cases?

Answer:Usually, Sanity Testing is done without formal test case documentation. It is informal and focuses on logical test flows, though in some teams, it can be tracked using exploratory test charters or lightweight test scripts.

  1.  Can Sanity Testing be automated?

Answer:Yes, sanity checks can be automated, especially in CI/CD environments where key functional paths need to be validated quickly. However, it is often done manually for speed and flexibility.

  1.  What do you do if Sanity Testing fails?

Answer:If sanity testing fails, the build is rejected, and no further testing is carried out. The issues are immediately reported to the development team, and a new, corrected build is requested.

  1.  How do you choose what to test in Sanity Testing?

Answer:We select tests based on:

  • Features that were modified
  • Modules affected by the changes
  • High-priority and business-critical flows
  • Previously failing test cases marked as resolved
  1.  Why is Sanity Testing important in Agile?

Answer:In Agile, where builds are frequent and time is limited, sanity testing helps QA quickly verify if fixes and changes work without impacting other functionalities. It saves time and ensures fast feedback to developers.

 Scenario-Based QA Interview Questions & Answers

  1.  Scenario: You receive a build with multiple critical bugs. What do you do?

Answer:I would immediately report the critical bugs with clear reproduction steps, logs, and screenshots. I would communicate with the development team and project manager about the issues. Depending on severity, I’d halt further testing until a stable build is received. Meanwhile, I’d test unaffected modules or perform documentation reviews to save time.

  1.  Scenario: The developer says, “It works on my machine,” but the bug is reproducible on QA. How do you handle it?

Answer:I’d ensure I’m testing in a consistent environment and provide detailed reproduction steps, including browser/version, device, data used, and logs/screenshots. If the issue still occurs, I’d invite the developer for a joint debug session or use screen sharing to demonstrate the issue in the QA environment.

  1.  Scenario: A client finds a bug in production that QA missed. What’s your response?

Answer:I’d first verify and reproduce the issue, assess its impact, and document it. Then, I’d conduct a root cause analysis — was it due to missing test coverage, miscommunication, or environment mismatch? I’d then update test cases, enhance regression coverage, and share learnings in the retrospective to prevent recurrence.

  1.  Scenario: You have limited time to test a release. How do you prioritize?

Answer:I’d do risk-based testing. I’d focus on high-risk areas, core functionalities, and recently modified features. I’d also check for customer-reported issues or business-critical workflows. If needed, I’d suggest cutting lower-priority test cases or parallelize testing with the team.

  1.  Scenario: A teammate delivers poor-quality test cases. How do you address it?

Answer:I’d offer constructive feedback privately, showing examples of well-written test cases. I’d share test case writing guidelines and templates. If needed, I’d suggest peer reviews and mentoring to help them improve over time, ensuring team quality without demotivation.

  1.  Scenario: You’re assigned to a project with no documentation. What’s your approach?

Answer:I’d start by exploring the application and identifying core flows. I’d speak to product owners, developers, or business analysts to gather requirements. I’d use reverse engineering techniques and tools like Postman for API exploration. Meanwhile, I’d create test cases and maintain living documentation as I learn.

  1.  Scenario: Your automation scripts are failing after a UI redesign. What do you do?

Answer:I’d assess which selectors or elements changed and update locators accordingly. To make scripts more resilient, I’d switch to dynamic locators or implement page object models. I’d also coordinate with developers to align on stable IDs or add test-friendly attributes to the new UI.

  1.  Scenario: A build passed smoke testing but failed in regression. What could be wrong?

Answer:Smoke testing checks only core functionalities; regression covers broader functionality. It's possible that changes in one module affected another indirectly. This indicates a need for better impact analysis and more comprehensive regression coverage. I’d investigate, log the bug, and enhance regression suites.

  1.  Scenario: A release is pushed live, and users report slowness. How would QA help?

Answer:I’d assist by reproducing the issue under different loads and collecting performance logs, memory usage, and response times. I’d use tools like JMeter or browser dev tools to profile performance and report findings to the DevOps and backend teams.

  1.  Scenario: You find a defect, but the product owner marks it as "not a bug." What would you do?

Answer:I’d clarify the expected behavior with user stories or acceptance criteria. If there’s a gap in understanding, I’d discuss it collaboratively. If it's a usability or ambiguity issue, I’d document it as a suggestion. Communication and alignment with stakeholders are key.

 GENERAL QA INTERVIEW QUESTIONS & ANSWERS

  1.  What is the role of QA in the software development life cycle (SDLC)?
    Answer:
    QA ensures the quality of software by validating that it meets business and technical requirements. QA’s role includes test planning, test case creation, test execution, defect reporting, and collaborating with development and product teams to ensure quality from start to finish.
  2.  What is the difference between Verification and Validation?
    Answer:
TermDefinition
VerificationEnsures the product is built correctly (e.g., design, code reviews)
ValidationEnsures the correct product is built (e.g., testing against requirements)
  1.  What are the different levels of testing?
    Answer:
  • Unit Testing
  • Integration Testing
  • System Testing
  • Acceptance Testing (UAT)
  1.  What is the difference between Regression and Retesting?
    Answer:
TypePurpose
RetestingTo verify that a specific bug fix works
RegressionTo ensure that new changes didn’t break existing functionality
  1.  What is the difference between Smoke and Sanity Testing?
    Answer:
Smoke TestingSanity Testing
Broad, basic checksFocused, deep checks
After every new buildAfter a bug fix or small update
  1.  What is a Test Case?
    Answer:
    A test case is a set of steps and conditions used to verify whether a specific feature or functionality of an application works as expected.
  2.  What is a Bug Life Cycle?
    Answer:
  • New → Assigned → Open → Fixed → Retest → Verified → Closed
  • If not resolved properly: Reopen or Deferred → Rejected → Closed
  1.  What is the difference between Severity and Priority?
TermMeaning
SeverityHow bad the bug is (technical impact)
PriorityHow soon it needs to be fixed (business impact/urgency)
  1.  What is Exploratory Testing?
    Answer:Exploratory testing is an informal testing method where testers explore the application on the fly, using intuition, experience, and creativity without predefined test cases.
  2.  What is your approach when you find a high-priority bug just before release?
    Answer:I would immediately report and escalate the issue to the product manager and development team, provide reproduction steps, and recommend whether the release should be delayed or the bug patched quickly. I’d also assess the risk and impact of the bug in production.

 AUTOMATION QA QUESTIONS (If applicable)

  1.  Which automation tools have you used?
    Answer:I have used Selenium with Python/Java, Appium for mobile automation, Postman for API testing, and JMeter/Locust for performance testing. I’ve also integrated test scripts with Jenkins/GitHub Actions for CI/CD.
  2.  How do you handle dynamic web elements in Selenium?
    Answer:I use dynamic XPath, CSS selectors, and wait strategies like WebDriverWait or FluentWait to handle dynamic elements.
  3.  What is the Page Object Model (POM)?
    Answer:POM is a design pattern in automation that promotes better code organization by separating locators and test logic into different classes. It improves reusability and maintainability of test scripts.
  4.  How do you decide what to automate?
    Answer:I prioritize automating repetitive, high-risk, stable, and time-consuming test cases — especially regression, smoke, and data-driven tests.

 BEHAVIORAL QUESTIONS

  1.  Tell me about a time when you found a critical bug under tight deadlines.
    Answer:In one release, I found a payment failure issue during smoke testing. I documented the bug with logs, steps, and video. I escalated it immediately, and our team fixed it within a few hours, avoiding customer impact. It emphasized the importance of early smoke checks.
  2.  How do you handle conflicts with developers?
    Answer:I maintain professionalism and use data and examples to explain issues. I focus on collaboration rather than blame, and when needed, I involve product managers or leads to clarify expectations.

 Additional QA Interview Questions & Answers

 Manual Testing

  1.  What is boundary value analysis (BVA)?
    Answer:It is a test design technique where test cases are created around boundary values (e.g., if the valid age range is 18–60, test with 17, 18, 19 and 59, 60, 61).
  2.  What is equivalence partitioning?
    Answer:It divides input data into valid and invalid partitions. You test one value from each partition instead of every possible input.
  3.  What is an entry and exit criterion in testing?
    Answer:Entry: Conditions that must be met before testing begins (e.g., test environment setup, build availability).
    Exit: Conditions to stop testing (e.g., 95% test case pass rate, all critical defects resolved).
  4.  What is defect leakage?
    Answer:It refers to a bug that is missed in testing and found by the customer after release. A high leakage rate indicates poor test coverage.
  5.  What is test coverage?
    Answer:Test coverage measures how much of the application is tested (e.g., requirement coverage, code coverage, branch coverage).

 Agile & DevOps

  1.  What is your role in an Agile sprint?
    Answer:In Agile, I participate in sprint planning, write test cases for user stories, execute tests, log bugs, and contribute to daily stand-ups, sprint reviews, and retrospectives.
  2.  What is a user story and how do you test it?
    Answer:A user story is a requirement described from the end user’s perspective. I test it by writing test cases for its acceptance criteria, executing them during the sprint, and validating end-to-end functionality.
  3.  How do you ensure testing fits into CI/CD?
    Answer:I integrate automated test scripts into CI pipelines using Jenkins/GitHub Actions, ensure smoke/regression tests run on every build, and provide quick feedback to the team.
  4.  What are some challenges in Agile QA?
    Answer:Frequent changes, short testing windows, incomplete requirements, maintaining automation with rapid changes. I overcome these with exploratory testing, test prioritization, and close communication with developers.

 Automation Testing

  1.  How do you handle synchronization issues in Selenium?
    Answer:I use explicit waits (WebDriverWait with expected conditions), implicit waits, or FluentWait to handle dynamic loading elements instead of hard-coded sleeps.
  2.  What is the difference between findElement and findElements?
    Answer:findElement returns the first matching element or throws an exception. findElements returns a list of all matching elements or an empty list if none found.
  3.  What are some advantages of test automation?
    Answer:
  • Faster execution
  • Reusability of scripts
  • Supports CI/CD
  • More test coverage in less time
  • Reduces human error
  1.  How do you perform API testing?
    Answer:I use tools like Postman or REST Assured to test endpoints. I verify status codes, response times, headers, and data validity. I also validate negative and edge cases.
  2.  What is a test framework? Which have you used?
    Answer:A test framework provides structure for automation (e.g., test scripts, reporting, logging). I’ve used PyTest/TestNG with Selenium, along with frameworks like POM, Data-Driven, and BDD (using Cucumber/Behave).

 Miscellaneous / Advanced

  1.  How do you ensure quality under tight deadlines?
    Answer:I use risk-based testing to prioritize critical features, perform exploratory testing, communicate effectively, and involve the team early in defect triage to save time.
  2.  What’s the difference between Quality Assurance and Quality Control?
    Answer:QA is process-oriented — focuses on preventing defects. QC is product-oriented — focuses on identifying defects in the final product.
  3.  How do you manage test data?
    Answer:I use mock data, SQL scripts, data factories, or staging environments. For automation, I store data in JSON, Excel, or databases to drive the tests.
  4.  How do you maintain your test cases?
    Answer:I version-control test cases in tools like TestRail or Zephyr. I periodically review and update them to reflect application changes and remove obsolete cases.
  5.  What metrics do you track during testing?
    Answer:
  • Defect density
  • Test execution progress (% complete)
  • Pass/fail rate
  • Defect rejection and leakage rate
  • Automation coverage
  • Mean time to detect/fix bugs
  1.  What makes a good bug report?
    Answer:
  • Clear title
  • Environment details
  • Steps to reproduce
  • Actual vs expected results
  • Screenshots or logs
  • Priority/severity classification

 Automation Testing Interview Questions & Answers

 1. What is Automation Testing?

Answer:Automation Testing is the process of using specialized tools and scripts to automatically execute test cases, compare actual outcomes with expected outcomes, and report the results. It reduces manual effort and increases test efficiency and coverage.

 2. What are the advantages of Automation Testing?

Answer:

  • Faster test execution
  • Repeatability and reusability
  • Better accuracy (fewer human errors)
  • Supports regression testing
  • Enables CI/CD integration
  • Cost-effective over time

 3. Which test cases should be automated?

Answer:

  • Repetitive test cases (regression/smoke)
  • High-risk business critical scenarios
  • Tests with large data sets
  • Tests that are time-consuming manually
  • Stable application modules

 4. What tools have you used for automation?

Answer:I’ve used Selenium WebDriver for web automation, Appium for mobile, PyTest/TestNG as test frameworks, Postman/REST Assured for API automation, JMeter/Locust for performance testing, and integrated tests with Jenkins and GitHub Actions.

 5. What is the difference between Selenium and Appium?

Answer:

FeatureSeleniumAppium
Used forWeb application testingMobile (iOS/Android) app testing
Language supportJava, Python, C#, JS, etc.Java, Python, JS, etc.
PlatformBrowsers onlyNative, hybrid, and mobile web apps

 6. What is a test automation framework?

Answer:A test framework provides structure and guidelines for creating and managing automated test scripts. Examples include:

  • Data-Driven Framework
  • Keyword-Driven Framework
  • Page Object Model (POM)
  • Behavior Driven Development (BDD) – Cucumber/Behave

 7. What is Page Object Model (POM)?

Answer:POM is a design pattern that enhances test maintainability by separating page-specific operations and locators into separate classes, making code reusable and easier to manage.

 8. What is the difference between assert and verify?

Answer:

  • Assert: Stops test execution if the condition fails.
  • Verify: Logs the failure but continues test execution.

 9. How do you handle dynamic elements in Selenium?

Answer:

  • Use dynamic XPath or CSS Selectors
  • Apply waits (explicit/FluentWait)
  • Use JavaScriptExecutor for complex DOM elements
  • Avoid brittle locators like index or absolute XPath

 10. What is implicit vs explicit wait?

Answer:

  • Implicit Wait: Applies to all elements globally. Waits until timeout or element is found.
  • Explicit Wait: Waits for a specific condition (element visible/clickable) for a specific element.

 11. What is TestNG / PyTest?

Answer:

  • TestNG: A testing framework in Java offering annotations, parallel test execution, reporting, and dependency handling.
  • PyTest: A Python testing framework supporting fixtures, parameterization, assertions, and plugin support.

 12. How do you perform data-driven testing?

Answer:By externalizing test data in Excel, CSV, JSON, or databases, and reading it using Apache POI (Java), pandas/openpyxl (Python), or libraries in the automation framework to loop through datasets and feed them into test scripts.

 13. How do you integrate automation into a CI/CD pipeline?

Answer:

  • Trigger tests on every build/merge using Jenkins, GitHub Actions, or GitLab CI
  • Store test results and reports
  • Fail the build if critical tests fail
  • Use plugins for Allure or HTML reports for visibility

 14. What types of testing can be automated?

Answer:

  • Functional testing (UI/API)
  • Regression testing
  • Smoke/Sanity testing
  • Performance testing (via JMeter/Locust)
  • Load and stress testing
  • Cross-browser testing (via BrowserStack/Sauce Labs)

 15. What are some common challenges in automation testing?

Answer:

  • Handling dynamic UI elements
  • Test data management
  • Maintenance with UI changes
  • Flaky tests
  • Environment inconsistencies
  • Choosing the right framework/tool

 16. How do you generate test reports?

Answer:

  • TestNG: Generates HTML/XML reports
  • PyTest: Supports Allure, HTML reports
  • CI Tools: Display reports using plugins or dashboards (Jenkins + Allure)

 17. What is BDD and how is it used?

Answer:Behavior Driven Development (BDD) is a testing approach where test cases are written in natural language (Given-When-Then format). Tools like Cucumber (Java) or Behave (Python) help link these to step definitions.

 18. How do you handle file uploads in automation?

Answer:

  • Use sendKeys() with file path in Selenium (if file input is accessible)
  • Use Robot class (Java) or pyautogui (Python) if file dialog box appears
  • Use third-party tools like AutoIT or Sikuli if necessary

 19. How do you test APIs in automation?

Answer:

  • Use tools like Postman or REST Assured for HTTP methods (GET, POST, PUT, DELETE)
  • Validate status codes, headers, JSON/XML response, response time
  • Automate API tests via code and run them in CI pipeline

 20. How do you handle exceptions in automation scripts?

Answer:

  • Use try-catch (Java) or try-except (Python) to gracefully handle errors
  • Log stack traces
  • Take screenshots on failure
  • Use custom exception handlers in frameworks

TestNG Interview Questions & Answers

1. What is TestNG?
TestNG is a Java testing framework inspired by JUnit and NUnit. It supports annotations, flexible test configuration, data-driven testing, parallel execution, and detailed HTML reporting.

2. What are some key features of TestNG?

  • Annotations to define test methods
  • Support for parameterized and data-driven tests
  • Ability to run tests in parallel
  • Dependency testing between methods
  • Generates detailed HTML and XML reports
  • Supports grouping and prioritization of tests

3. What is the difference between @BeforeSuite, @BeforeTest, and @BeforeClass?

  • @BeforeSuite: Runs once before all tests in the suite.
  • @BeforeTest: Runs before any test method in the <test> tag in TestNG XML.
  • @BeforeClass: Runs once before the first method in the current class.

4. How do you prioritize tests in TestNG?
You use the priority attribute in the @Test annotation, e.g., @Test(priority=1). Lower priority runs first.

5. What is the use of dependsOnMethods in TestNG?
It defines dependencies between test methods. If the method it depends on fails, the dependent method will be skipped.

6. How can you run a group of tests in TestNG?
Using the groups attribute in @Test and specifying groups in the TestNG XML file or using filters.

7. What is the difference between assert and softAssert in TestNG?

  • assert: Stops execution immediately if the assertion fails.
  • softAssert: Collects all assertion failures and continues executing, reporting all failures at the end.

8. How do you run tests in parallel in TestNG?
By configuring the TestNG XML with the parallel attribute (methods, tests, or classes) and setting the thread-count.

Example:

<suite name="Suite" parallel="methods" thread-count="5">

9. What is a TestNG Listener?
Listeners are interfaces that allow you to modify TestNG behavior. Common listeners include ITestListener and ISuiteListener for tracking test execution events (start, success, failure, etc.).

10. How do you parameterize tests in TestNG?
Using @Parameters annotation with values defined in the TestNG XML or by using @DataProvider for data-driven testing.

11. What is @DataProvider in TestNG?
@DataProvider allows running a test method multiple times with different sets of data. The method annotated with @DataProvider returns an Object array with test data.

12. How do you generate TestNG reports?
TestNG automatically generates HTML and XML reports after test execution which can be found in the test-output folder.

13. Can you explain TestNG XML file?
The XML file configures test suites, tests, classes, methods, groups, parameters, and execution flow for TestNG. It’s used to organize and control test runs.

14. How do you skip tests in TestNG?
You can skip tests by:

  • Setting a condition inside the test method and calling throw new SkipException("message").
  • Using dependencies where a dependent test skips if the prerequisite fails.

15. How do you handle exceptions in TestNG tests?
You can specify expectedExceptions in @Test, so the test passes if the specified exception is thrown.

Example:

@Test(expectedExceptions = ArithmeticException.class)
public void testDivision() {
    int result = 1 / 0;
}

Advanced TestNG Interview Questions & Answers

16. What are the different annotations available in TestNG?

  • @BeforeSuite / @AfterSuite
  • @BeforeTest / @AfterTest
  • @BeforeClass / @AfterClass
  • @BeforeMethod / @AfterMethod
  • @Test
  • @DataProvider
  • @Factory
  • @Listeners
  • @Parameters

17. What is the difference between @Factory and @DataProvider?

  • @Factory is used to create instances of test classes dynamically.
  • @DataProvider provides data to a single test method for parameterized testing.

18. How do you run a subset of test methods from a class?
Using the TestNG XML <methods> tag inside the <class> tag, specifying the method names to include or exclude.

Example:

<class name="com.example.TestClass">
  <methods>
    <include name="testMethod1"/>
    <exclude name="testMethod2"/>
  </methods>
</class>

19. How can you change the order of test execution without using priority?
TestNG executes tests alphabetically by default if priority is not set.

20. What happens if a test method depends on multiple methods and one of them fails?
The dependent test will be skipped if any one of the methods it depends on fails.

21. How do you create parallel test execution for multiple classes?
In the TestNG XML file, set parallel="classes" and specify thread-count.

22. What is the use of the alwaysRun attribute?
Setting alwaysRun=true forces a configuration method to run even if a dependent method fails.

Example:

@BeforeMethod(alwaysRun=true)
public void setup() {
    // setup code
}

23. How do you retry failed test cases in TestNG?
By implementing the IRetryAnalyzer interface and overriding the retry method. You attach this to test methods with retryAnalyzer attribute.

24. What is the use of @Listeners annotation?
It is used to attach listener classes to a test class to monitor events like test start, test success, failure, etc.

25. How do you pass parameters from the TestNG XML file to test methods?
By using the @Parameters annotation and defining parameters in the XML file.

Example XML snippet:

<parameter name="browser" value="chrome"/>

Test method:

@Test
@Parameters("browser")
public void testMethod(String browser) {
    // use browser parameter
}

26. Can TestNG tests be executed from the command line? If yes, how?
Yes. Using the TestNG jar and the XML suite file:

java -cp "path/to/testng.jar;path/to/your/tests" org.testng.TestNG testng.xml

27. What is the difference between @Test(enabled=false) and commenting out the test method?
enabled=false skips the test but keeps it in the suite, useful for temporarily disabling tests without removing code. Commenting removes the test from execution permanently.

28. What is the use of @Test(invocationCount=10)?
Runs the test method 10 times in a row.

29. How can you group tests and execute only a specific group?
Assign groups to tests via @Test(groups = {"smoke"}) and specify the group in TestNG XML or command line to run only that group.

30. How do you generate custom reports in TestNG?
By implementing the IReporter interface and overriding the generateReport method, or by using third-party reporting tools like Allure integrated with TestNG.

TestNG Study Guide for QA Automation Interview

1. What is TestNG?

  • A Java-based testing framework inspired by JUnit.
  • Supports annotations, parallel execution, data-driven testing, and detailed reporting.
  • Integrates well with Selenium WebDriver and CI/CD tools.

2. Key TestNG Annotations & Usage

AnnotationWhen it RunsExample Usage
@BeforeSuiteBefore all tests in suite@BeforeSuite public void beforeSuite() {}
@AfterSuiteAfter all tests in suite@AfterSuite public void afterSuite() {}
@BeforeTestBefore <test> in TestNG XML@BeforeTest public void beforeTest() {}
@AfterTestAfter <test> in TestNG XML@AfterTest public void afterTest() {}
@BeforeClassBefore first method in current class@BeforeClass public void beforeClass() {}
@AfterClassAfter all methods in current class@AfterClass public void afterClass() {}
@BeforeMethodBefore each test method@BeforeMethod public void beforeMethod() {}
@AfterMethodAfter each test method@AfterMethod public void afterMethod() {}
@TestThe actual test method@Test public void testMethod() {}
@DataProviderSupplies data to test methods@DataProvider(name="data") public Object[][] data() {}
@ParametersPasses parameters from XML to tests@Parameters({"browser"}) @Test public void test(String browser) {}
@FactoryCreates test class instances dynamically@Factory public Object[] factoryMethod() {}

3. Basic TestNG Test with Priority and Groups

import org.testng.annotations.Test;

public class SampleTests {

    @Test(priority = 1, groups = {"smoke"})
    public void loginTest() {
        System.out.println("Login test");
    }

    @Test(priority = 2, groups = {"regression"})
    public void searchTest() {
        System.out.println("Search test");
    }

    @Test(priority = 3, dependsOnMethods = {"loginTest"})
    public void checkoutTest() {
        System.out.println("Checkout test");
    }
}

4. Data-Driven Testing with @DataProvider

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class DataDrivenTests {

    @DataProvider(name = "userData")
    public Object[][] userData() {
        return new Object[][] {
            {"user1", "pass1"},
            {"user2", "pass2"},
            {"user3", "pass3"}
        };
    }

    @Test(dataProvider = "userData")
    public void loginTest(String username, String password) {
        System.out.println("Logging in with " + username + " / " + password);
        // add assertions and test logic
    }
}

5. Parameterizing Tests Using TestNG XML and @Parameters

testng.xml

<suite name="Suite1">
  <test name="Test on Chrome">
    <parameter name="browser" value="chrome" />
    <classes>
      <class name="com.example.BrowserTest" />
    </classes>
  </test>
</suite>

Test Code

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class BrowserTest {

    @Test
    @Parameters("browser")
    public void launchBrowser(String browser) {
        System.out.println("Launching browser: " + browser);
        // add code to initialize browser driver
    }
}

6. Running Tests in Parallel (TestNG XML Example)

<suite name="ParallelSuite" parallel="methods" thread-count="3">
  <test name="ParallelTests">
    <classes>
      <class name="com.example.SampleTests" />
    </classes>
  </test>
</suite>

7. Retry Failed Tests with IRetryAnalyzer

import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

public class RetryFailedTests implements IRetryAnalyzer {

    private int retryCount = 0;
    private static final int maxRetryCount = 2;

    @Override
    public boolean retry(ITestResult result) {
        if (retryCount < maxRetryCount) {
            retryCount++;
            return true;
        }
        return false;
    }
}

Attach RetryAnalyzer:

@Test(retryAnalyzer = RetryFailedTests.class)
public void testMethod() {
    // test logic
}

8. Listener Example (ITestListener)

import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;

public class TestListener implements ITestListener {

    @Override
    public void onTestStart(ITestResult result) {
        System.out.println("Test Started: " + result.getName());
    }

    @Override
    public void onTestSuccess(ITestResult result) {
        System.out.println("Test Passed: " + result.getName());
    }

    @Override
    public void onTestFailure(ITestResult result) {
        System.out.println("Test Failed: " + result.getName());
        // Add screenshot code here
    }

    @Override
    public void onFinish(ITestContext context) {
        System.out.println("All tests finished.");
    }

    // other methods can be overridden as needed
}

Attach listener in test class:

import org.testng.annotations.Listeners;

@Listeners(TestListener.class)
public class SampleTests {
    // test methods
}

9. Skipping Tests Programmatically

import org.testng.SkipException;
import org.testng.annotations.Test;

public class SkipTests {

    @Test
    public void testToSkip() {
        if (someCondition()) {
            throw new SkipException("Skipping test due to condition");
        }
        // test code
    }

    private boolean someCondition() {
        return true;
    }
}

10. Generating TestNG Reports

  • After execution, check the test-output folder in your project root.
  • Open index.html to view the summary report.
  • Use plugins like Allure or ExtentReports for more advanced reporting.
  1. What is Selenium?
    Selenium is an open-source automation testing tool for web applications. It supports multiple languages like Java, Python, C#, and can run tests across browsers (Chrome, Firefox, Safari, etc.) and platforms.
  2. What are the components of Selenium?
  • Selenium WebDriver
  • Selenium IDE
  • Selenium Grid
  1. How do you locate elements in Selenium?
    By using:
  • id
  • name
  • className
  • tagName
  • linkText
  • partialLinkText
  • cssSelector
  • xpath
  1. What is the difference between driver.findElement() and driver.findElements()?
  • findElement() returns the first matching element or throws NoSuchElementException.
  • findElements() returns a list of matching elements. If none are found, it returns an empty list.
  1. How do you handle dynamic elements in Selenium?
    Use dynamic XPath or CSS selectors. Techniques like contains(), starts-with(), or sibling navigation in XPath are common.
  2. How do you handle alerts/popups in Selenium?
    Using Alert interface:
    Alert alert = driver.switchTo().alert();
    alert.accept();
  3. What are waits in Selenium?
  • Implicit Wait: Sets a default wait time before throwing NoSuchElementException.
  • Explicit Wait: Waits for specific conditions using WebDriverWait.
  • Fluent Wait: Like Explicit Wait with more control over polling frequency and exceptions.
  1. Can Selenium handle file uploads/downloads?
  • File upload: Use sendKeys() with file path.
  • File download: Use browser profile configurations or third-party tools.
  1. How do you run Selenium tests in parallel?
    Use TestNG’s parallel execution or Selenium Grid.
  2. What are limitations of Selenium?
  • Cannot test desktop/mobile apps
  • No built-in reporting
  • Requires programming skills
  • Can’t handle CAPTCHA or barcode scanning

Cypress Interview Questions & Answers

  1. What is Cypress?
    Cypress is a modern front-end testing framework built on JavaScript for fast, reliable testing of anything that runs in the browser.
  2. How is Cypress different from Selenium?
  • Cypress runs inside the browser, Selenium runs externally via the WebDriver.
  • Cypress uses a single language (JavaScript), Selenium supports multiple.
  • Cypress is asynchronous and auto-waits for commands.
  1. What are Cypress fixtures?
    Fixtures are external pieces of static data (e.g. JSON files) used for mocking data in tests. They reside in the /fixtures folder.
  2. What is cy.get() in Cypress?
    cy.get() is used to select elements from the DOM using CSS selectors.
  3. How does Cypress handle waits?
    Cypress automatically waits for DOM to be ready and for elements to appear. Manual waits like cy.wait() can also be used but are discouraged.
  4. How do you test APIs in Cypress?
    Using cy.request():
    cy.request('GET', '/api/users').then((response) => {
    expect(response.status).to.eq(200);
    });
  5. Can Cypress run in headless mode?
    Yes. Run cypress run --headless.
  6. What is Cypress Dashboard?
    A cloud service that records test runs, displays results, screenshots, and videos. Useful for CI/CD integration.
  7. Can Cypress handle multi-tab or cross-domain testing?
    No, Cypress has limitations with multiple tabs or domains due to security restrictions.
  8. What are Cypress plugins?
    Plugins extend Cypress functionality. Example: cypress-file-upload, cypress-axe for accessibility.

Playwright Interview Questions & Answers

  1. What is Playwright?
    Playwright is an open-source Node.js library from Microsoft for end-to-end testing of web applications. It supports Chromium, Firefox, and WebKit.
  2. How is Playwright different from Cypress or Selenium?
  • Playwright supports multiple languages (JavaScript, Python, C#, Java)
  • Handles multiple tabs and browser contexts better
  • Allows testing mobile emulation, geolocation, and browser permissions
  1. How do you launch a browser in Playwright?
    const { chromium } = require('playwright');
    const browser = await chromium.launch();
  2. How do you capture screenshots in Playwright?
    await page.screenshot({ path: 'screenshot.png' });
  3. How do you handle waits in Playwright?
    Playwright auto-waits for elements. Manual waits can use await page.waitForSelector() or await page.waitForTimeout().
  4. Can Playwright handle file uploads and downloads?
    Yes. You can use setInputFiles() for upload and browserContext.on('download') for downloads.
  5. How do you test across browsers in Playwright?
    Playwright supports Chromium, Firefox, and WebKit out-of-the-box:
    await firefox.launch();
    await webkit.launch();
  6. Can Playwright run tests in parallel?
    Yes. Use the Playwright Test Runner’s parallelism options or configure it in playwright.config.ts.
  7. How do you record a test script in Playwright?
    Use npx playwright codegen <url> to launch a GUI recorder.
  8. Does Playwright support mobile and geolocation testing?
    Yes. Use browser.newContext with device descriptors and geolocation.

Absolutely! Below are 100+ interview questions and answers covering Selenium, Cypress, and Playwright. These are the types of questions asked in TCS, Infosys, Capgemini, Accenture, Cognizant, Wipro, HCL, Deloitte, EY, PwC, IBM, LTI Mindtree, Tech Mahindra, Oracle, and Product-based companies.

SELENIUM INTERVIEW QUESTIONS & ANSWERS

1. Why Selenium WebDriver instead of Selenium IDE?

Answer:

  • Supports programming languages
  • Better for framework development
  • Cross-browser support
  • CI/CD integration
  • Dynamic element handling
  • Better reporting support

2. Why WebDriver is better than RC?

Answer:

Selenium RCWebDriver
Uses Selenium ServerDirect browser communication
SlowFaster
JavaScript injectionNative browser automation
Less stableMore stable

3. Explain Selenium Architecture.

Answer:

Test Script
      ↓
WebDriver API
      ↓
Browser Driver
(ChromeDriver)
      ↓
Browser

4. Difference between Absolute XPath and Relative XPath?

Absolute XPath

/html/body/div[1]/table/tr/td
  • Starts from root
  • Not recommended
  • Breaks easily

Relative XPath

//input[@id='username']
  • Flexible
  • Faster
  • Recommended

5. Which locator is fastest?

Interview Answer

ID
↓

Name
↓

CSS Selector
↓

XPath

6. Difference between CSS Selector and XPath?

CSSXPath
FasterSlightly slower
Cannot move backwardCan move backward
Easy syntaxComplex syntax
Better performanceMore powerful

7. Difference between close() and quit()

close()

Closes current browser window

quit()

Closes all browser windows
Ends WebDriver session

8. Difference between get() and navigate().to()

get()

Loads page

Cannot go back

navigate()

Loads page

Can refresh

Can back()

Can forward()

9. Difference between click() and submit()

click()

Clicks any element

submit()

Works only for forms

10. How to handle Dropdown?

Select s = new Select(element);

s.selectByVisibleText();

s.selectByValue();

s.selectByIndex();

11. How to handle Auto Suggestion?

Example

Google Search

SendKeys("iphone")

Collect suggestions

Loop through suggestions

Click matching suggestion

12. How to handle Dynamic Web Table?

Answer

  • Find rows
  • Find columns
  • Loop through
  • Compare values
  • Click desired row

13. How to handle Multiple Windows?

driver.getWindowHandles()

driver.switchTo().window(id)

14. Difference between getWindowHandle() and getWindowHandles()

getWindowHandle()

Returns current window

getWindowHandles()

Returns all windows

15. How to take Screenshot?

TakesScreenshot ts =
(TakesScreenshot)driver;

ts.getScreenshotAs(OutputType.FILE);

16. What exceptions have you handled?

Common Answers

  • NoSuchElementException
  • TimeoutException
  • StaleElementReferenceException
  • ElementClickInterceptedException
  • ElementNotInteractableException

17. What is StaleElementReferenceException?

Element was found.

DOM changed.

Reference becomes invalid.

Need to locate again.

18. How do you handle Synchronization?

Best Interview Answer

Explicit Wait

WebDriverWait

ExpectedConditions

Avoid Thread.sleep()

19. Why Thread.sleep() is bad?

  • Static wait
  • Slows execution
  • Wastes time
  • Makes scripts unstable

20. Explain POM.

Answer

Page Object Model separates

  • Locators
  • Methods
  • Test Scripts

Benefits

✔ Reusable

✔ Easy Maintenance

✔ Less Code

✔ Better Readability

CYPRESS INTERVIEW QUESTIONS

21. Why Cypress is faster?

Answer

Because it runs

Inside Browser

instead of communicating through WebDriver.

22. What is Cypress Architecture?

Test

↓

Cypress

↓

Browser

↓

DOM

23. What is Cypress Command Queue?

Answer

Every command is queued first.

Then executed sequentially.

Example

cy.visit()

cy.get()

cy.click()

24. Why Cypress doesn't need Explicit Wait?

Answer

It automatically retries until

Element appears

OR

Timeout occurs.

25. What is cy.contains()?

Searches text on page.

Example

cy.contains("Login").click()

26. Difference between should() and then()

should()

Retries automatically

Used for Assertions

then()

No retry

Used for manipulation

27. Difference between invoke() and its()?

invoke()

Calls function

invoke('text')

its()

Gets property

its('length')

28. How to Upload File?

cy.get('input')

.selectFile('image.png')

29. How to Stub API?

cy.intercept()

Used for

Mock Response

Modify Response

Verify Request

30. How to Capture Screenshot?

cy.screenshot()

31. How to Handle Alert?

cy.on('window:alert',()=>{})

32. Can Cypress handle Multiple Tabs?

Interview Answer

No

Cypress supports single tab only.

Alternative

Remove target="_blank"

33. Can Cypress automate Excel?

Yes

Using plugins like

xlsx

exceljs

34. What are Fixtures?

Static Test Data

Stored inside

fixtures folder

Mostly JSON files.

35. What is Cypress Dashboard?

Cloud platform

Stores

Reports

Videos

Screenshots

Execution History

PLAYWRIGHT INTERVIEW QUESTIONS

36. Why Playwright is becoming popular?

Answer

Supports

✔ Chromium

✔ Firefox

✔ Safari

✔ Mobile

✔ Multiple Tabs

✔ Fast

✔ Auto Wait

37. Difference between Playwright and Selenium?

SeleniumPlaywright
Needs DriverNo Driver
SlowerFaster
Manual WaitAuto Wait
Limited MobileFull Mobile Support

38. Difference between Cypress and Playwright?

CypressPlaywright
Only JSMultiple Languages
No Multi-tabSupports Multi-tab
Chrome-focusedChromium Firefox Safari

39. What is Browser Context?

Answer

Incognito Browser

Independent Session

Useful for

Parallel Users

40. What is Page Object in Playwright?

Same concept as Selenium

Separates

Locators

Methods

Tests

41. What is Codegen?

Command

npx playwright codegen

Automatically generates scripts.

42. How to take Screenshot?

await page.screenshot()

43. How to Record Video?

Configure in

playwright.config.ts

44. How to Upload File?

setInputFiles()

45. How to Download File?

page.waitForEvent('download')

46. What is Auto Wait?

Playwright automatically waits for

✔ Visible

✔ Stable

✔ Clickable

✔ Enabled

47. How do you perform API testing in Playwright?

const request = await playwright.request.newContext();
const response = await request.get("https://api.example.com/users");
expect(response.status()).toBe(200);

48. How do you run Playwright tests in parallel?

In playwright.config.ts:

workers: 4

FRAMEWORK QUESTIONS

49. Explain Hybrid Framework.

Combination of

✔ POM

✔ Data Driven

✔ Utility Classes

✔ Reporting

✔ Logger

✔ Base Class

50. What folders exist in your framework?

src/test/java

Pages

Tests

Utilities

Reports

TestData

Config

Drivers

Listeners

51. What is Base Class?

Contains

Driver initialization

Browser launch

Configuration

Common methods

52. What is Utility Class?

Contains reusable methods

Screenshot

Excel

Date

Random Number

Waits

53. What reporting tools have you used?

  • Extent Report
  • Allure Report
  • TestNG Report
  • HTML Report

54. How do you capture screenshots on failure?

Using

TestNG Listener

or

Playwright Hooks

55. What is Jenkins?

Automation Server

Runs tests automatically

Creates reports

Schedules execution

56. Explain CI/CD.

Code Commit

↓

Build

↓

Deploy

↓

Automation Testing

↓

Report

↓

Release

57. Which version control tool do you use?

Git

GitHub

Bitbucket

GitLab

58. How do you execute tests from Jenkins?

  • Pull latest code
  • Build project
  • Execute Maven command (mvn test)
  • Publish reports
  • Send email notifications

59. How do you maintain automation scripts?

  • Use POM
  • Reusable methods
  • Stable locators
  • Code reviews
  • Refactor regularly

60. What are automation best practices?

  • Follow coding standards
  • Avoid duplicate code
  • Use explicit waits
  • Keep test data separate
  • Generate reports
  • Use version control
  • Execute through CI/CD
  • Review flaky tests regularly

Testing Profile Q&A

 Scenario 1: Handling Conflicts Within the Team Q: One of your QA team members is in constant disagreement with a developer, leading to dela...