Site-wide search
Search everything
One search across 1207 interview questions, scenario lab problems and cheat sheet sections.
Difference between implicit wait, explicit wait and fluent wait?
Implicit wait is a global polling timeout on element lookup; explicit wait waits for a specific condition on a specific element; fluent wait is an explicit wait with a custom polling interval and ignored exceptions.
How do you handle StaleElementReferenceException?
Re-locate the element after the DOM re-renders — cache the locator (By), not the WebElement — and wrap risky interactions in a retry helper.
How do you handle multiple windows and tabs?
Store the parent handle, iterate getWindowHandles(), switch by title/URL, act, close, then switch back to the parent.
Explain Selenium Grid and how you run tests in parallel on it.
Grid is a hub/node (or router-distributor in Grid 4) setup that routes RemoteWebDriver sessions to matching nodes; parallelism comes from TestNG threads plus enough node slots.
Difference between HashMap, LinkedHashMap and TreeMap?
HashMap = no order, O(1) average; LinkedHashMap = insertion (or access) order; TreeMap = sorted by key, O(log n), backed by a red-black tree.
How do you find duplicate characters in a String using Java 8 Streams?
Stream the chars, group by identity with counting, filter entries with count > 1.
Abstract class vs interface — which do you use in your framework and why?
Abstract class for shared state + partial implementation (BasePage, BaseTest); interface for capability contracts (Reportable, DataProvider strategy).
How do you validate a nested JSON response in REST Assured?
Use JSONPath expressions in body() matchers, or deserialize into a POJO and assert on typed fields.
How do you chain API requests (use a response value in the next request)?
extract() the value from the first response and pass it into the next request.
What is the difference between PUT and PATCH? When do you test each?
PUT replaces the whole resource and is idempotent; PATCH applies a partial update. Both should be idempotent-safe, but PATCH bodies are diffs.
How do you rerun only failed tests in TestNG?
Run testng-failed.xml from target/surefire-reports, or attach an IRetryAnalyzer with a bounded retry count.
DataProvider vs @Parameters — when do you use each?
@Parameters injects static values from testng.xml (browser, env); @DataProvider supplies dynamic, multi-row test data from code, Excel, JSON or DB.
Walk me through the architecture of the framework you built.
Layered Maven project: tests → page/API layer → core (driver factory, config, utils, data) → reporting/CI, with ThreadLocal drivers and env-driven configuration.
How do you manage test data across environments?
Externalise data by environment, generate volatile data at runtime via API, and never depend on manually created records.
Describe your Jenkins pipeline for the automation suite.
Declarative pipeline: checkout → build → parallel test stages (smoke/api/ui) → publish reports → notify, parameterised by browser and environment.
Difference between git merge and git rebase in an automation repo?
Merge preserves history with a merge commit; rebase replays your commits on top of the target for a linear history. Rebase local branches, merge shared ones.
Write a query to find the second highest salary.
Use DENSE_RANK() in a subquery, or the classic MAX with a nested exclusion.
Why would you migrate from Selenium to Playwright?
Auto-waiting, browser contexts for cheap isolation, built-in tracing/network interception, and much faster parallel execution — but Selenium wins on legacy browser support and ecosystem.
How do you measure the ROI of automation to leadership?
Manual regression hours saved per release, defect escape rate, feedback-loop time, and automation stability — expressed in money and release velocity.
How do you handle flaky tests at scale?
Quarantine, measure, root-cause by category, and fix the framework — never blanket-retry.
How do you build a test strategy for a new product?
Risk-based scope, a test pyramid with clear ownership, environment and data strategy, entry/exit criteria, tooling and metrics — documented on one page.
How do you design test cases for a login page?
Cover positive flows, negative credentials, boundary and format validation, security (lockout, SQL/XSS payloads, masked password), session behaviour, accessibility and cross-browser rendering.
Severity vs priority — explain with an example.
Severity is technical impact on the system; priority is business urgency of the fix. They are set by different people and can differ in any combination.
Explain async/await, promises and the event loop for test code.
JavaScript is single threaded with an event loop; promises queue microtasks, and async/await is syntax over promises. In test code every browser interaction returns a promise, so a missing await produces false passes.
How do Playwright fixtures, projects and auto-waiting change framework design?
Fixtures replace base classes for setup, projects replace testng.xml for browser/environment matrices, and web-first assertions with auto-waiting remove most explicit wait code.
How do you build a reusable Postman collection for regression?
Environments for config, collection variables for chained IDs, pre-request scripts for auth tokens, pm.test assertions with schema validation, then run it in CI with Newman.
How do you run your test suite in Docker and on cloud grids?
Containerise the suite, use selenium-docker or Selenium Grid via docker-compose for local parallelism, and switch to a cloud grid (BrowserStack/LambdaTest/Sauce) by changing only the RemoteWebDriver URL and capabilities.
How does mobile test strategy differ from web?
Device and OS fragmentation, native vs hybrid contexts, gestures, permissions, interrupts (calls, network loss), battery and background/foreground lifecycle — plus real devices for anything sensor or performance related.
Explain the Appium architecture and how you make locators stable.
Appium is a client/server implementing W3C WebDriver; the server delegates to platform drivers (UiAutomator2 on Android, XCUITest on iOS). Stable locators come from accessibility ids set by developers, not XPath.
How do you build and interpret a JMeter load test?
Model realistic user journeys with thread groups and pacing, parameterise data with CSV Data Set, correlate dynamic tokens, then read 90th/95th percentile latency, throughput and error rate — never the average.
Describe a Jenkins pipeline for an automation suite.
Declarative Jenkinsfile: checkout, build, parallel smoke/API stages on agents, publish JUnit and Allure reports, gate the deploy on results, and notify Slack with a report link.
Walk me through the phases of the Software Testing Life Cycle (STLC).
STLC covers requirement analysis, test planning, test case design, environment setup, test execution, and closure/reporting.
What test design techniques do you use to reduce test cases while keeping coverage high?
Equivalence partitioning, boundary value analysis, decision tables, and state transition testing let you cover behavior with fewer, high-value cases.
Explain the defect life cycle and the states a bug moves through.
A defect moves New → Assigned → Open/In Progress → Fixed → Retest → Verified → Closed, with Reopened and Deferred/Rejected as branch states.
How do you differentiate severity and priority when triaging a defect?
Severity measures technical impact on the system; priority measures business urgency to fix it. They're independent and can combine in any way.
How do you apply risk-based testing when you don't have time to test everything?
Rank features by probability of failure and business impact, then allocate testing effort and depth proportionally to that risk score.
What does 'shift-left' testing mean in practice, and how have you implemented it?
Shift-left means involving QA earlier in the SDLC — reviewing requirements and designs, writing tests alongside development, and catching defects before code is even written.
Explain the JavaScript event loop and how it affects asynchronous test code.
The event loop lets a single-threaded JS runtime handle async operations by pushing callbacks onto a queue that runs only after the call stack is empty, with microtasks (promises) draining before macrotasks (setTimeout).
Compare Promises with async/await — when would you choose one over the other in test automation?
Async/await is syntactic sugar over Promises that reads like synchronous code; Promises' .then chaining is still useful for running independent async operations in parallel with Promise.all.
What is a closure and where have you used one in a test automation framework?
A closure is a function that retains access to its enclosing scope's variables even after that outer function has returned, commonly used to create private state like counters or configured helper functions.
How does 'this' behave differently in regular functions vs arrow functions, and why does it matter in test hooks?
Regular functions get 'this' determined by how they're called (dynamic binding), while arrow functions inherit 'this' lexically from their enclosing scope at definition time.
Which array methods do you rely on most for shaping test data, and how do map/filter/reduce differ?
map transforms each element into a new array of the same length, filter keeps only elements matching a predicate, and reduce folds the array into a single accumulated value.
How do you properly handle and assert errors in asynchronous test code?
Wrap awaited calls in try/catch to assert on thrown errors, or use your test framework's rejection matcher like expect(promise).rejects.toThrow() instead of manually catching.
What's the difference between == and ===, and where has loose equality caused a subtle test bug?
== performs type coercion before comparing while === compares both type and value without coercion, so === is almost always the safer choice in assertions.
When would you use an interface versus a type alias in a test framework codebase?
Interfaces are best for object shapes that might be extended or merged (like page object or config contracts), while type aliases are more flexible for unions, tuples, and mapped types.
How do you use generics to build a reusable page object or API client class?
Generics let a single class or function work with multiple types safely, so an API client can return a strongly-typed response for whatever endpoint's shape you pass in.
Give examples of utility types you've used in an automation framework, like Partial, Pick, or Omit.
Partial<T> makes all fields optional for building partial test fixtures, Pick<T, K> extracts a subset of fields for a lightweight DTO, and Omit<T, K> removes fields you don't want exposed, like excluding a password from a response type.
What does strictNullChecks do, and why is it valuable in test automation code?
strictNullChecks makes null and undefined distinct types that must be explicitly handled, preventing runtime 'cannot read property of undefined' errors from locator/element lookups that silently return nothing.
How do you type an API client so response validation failures are caught at compile time, not just at runtime?
Define explicit interfaces for request/response payloads and pair them with a runtime schema validator like Zod, then infer the TypeScript type directly from that schema so compile-time types and runtime validation never drift apart.
Explain the difference between INNER JOIN, LEFT JOIN, and how you'd use them to validate test data relationships.
INNER JOIN returns only rows with matches in both tables, while LEFT JOIN returns all rows from the left table plus matched data from the right, with NULLs where no match exists — the latter is essential for finding orphaned records.
How do GROUP BY and HAVING differ, and when do you need HAVING instead of WHERE?
WHERE filters individual rows before grouping happens, while HAVING filters aggregated groups after GROUP BY has computed them, so you use HAVING when your condition depends on an aggregate like COUNT or SUM.
How would you use a window function to validate ordering or detect gaps in sequential test data?
Window functions like ROW_NUMBER(), RANK(), and LAG()/LEAD() let you compute values across a set of rows related to the current row without collapsing them into groups, which is ideal for detecting sequence gaps or comparing a row to the previous one.
How do indexes affect query performance, and what's a scenario where a missing index caused a test to time out?
An index creates a sorted lookup structure (typically a B-tree) so the database can find matching rows without scanning the entire table, turning an O(n) full table scan into a much faster O(log n) lookup.
How do you verify database state after an API call in an automated test, and what pitfalls do you watch for?
Query the relevant table(s) directly after the API call using a unique identifier from the response, and guard against race conditions by polling with a timeout rather than asserting immediately, since some writes are asynchronous.
What's your approach to writing a query that finds duplicate records that shouldn't exist, and how do you decide which duplicate to keep when cleaning up?
Group by the fields that should be unique, filter with HAVING COUNT(*) > 1 to find duplicates, then use ROW_NUMBER() partitioned by those fields to identify which rows to keep (usually the earliest or most complete) versus delete.
Explain pytest fixtures and the difference between function, class, module, and session scope.
Fixtures are reusable setup/teardown functions injected into tests via dependency injection, and scope controls how often the fixture is created — function scope runs fresh per test, while session scope runs once for the entire test run.
How do you use the requests library to build API tests, including handling sessions and auth?
requests.Session() persists cookies, headers, and connection pooling across multiple calls, which is essential for API tests that need to authenticate once and reuse that auth state, rather than re-authenticating every request.
How do list and dict comprehensions improve readability when processing test data or API responses?
Comprehensions let you build a new list or dict from an iterable in a single readable expression, replacing multi-line for-loops with append/update calls, while also often running faster due to CPython optimizations.
What are the key differences between unittest and pytest, and why might a team migrate from one to the other?
unittest is Python's built-in xUnit-style framework requiring class-based tests and self.assertX methods, while pytest allows plain functions with a simple assert statement, richer fixtures, and a much larger plugin ecosystem.
How do you use pytest.mark.parametrize to avoid duplicating near-identical test cases?
parametrize lets you run the same test function multiple times with different input/expected-output pairs supplied as a decorator, replacing several copy-pasted test functions with one data-driven test.
How would you structure a Page Object Model in Python for a Selenium/Playwright test suite?
Each page gets its own class encapsulating its locators and interaction methods (like login() or search()), so tests call high-level business actions instead of manipulating locators directly, isolating UI changes to one place.
How do you choose between ArrayList, LinkedList, HashMap and HashSet in test code?
ArrayList for ordered, index-accessed data, HashMap for key lookups such as test data by id, HashSet for uniqueness checks, LinkedList almost never in test frameworks.
How does HashMap work internally, and why must hashCode and equals agree?
HashMap stores entries in buckets chosen by hashCode; equals resolves collisions inside a bucket. If two equal objects return different hash codes they land in different buckets and lookups silently fail.
Interface vs abstract class — how does that decision show up in a test framework?
Abstract classes share state and common behaviour (BasePage, BaseTest); interfaces declare capability contracts (Reportable, DriverProvider) and allow multiple inheritance of type.
How do you make WebDriver thread-safe for parallel execution?
Keep the driver in a ThreadLocal inside a DriverManager, create it in a @BeforeMethod and always remove() it in @AfterMethod to avoid leaking between threads.
What are Selenium 4 relative locators and when would you actually use them?
RelativeLocator (with, above, below, toLeftOf, toRightOf, near) finds an element by its visual position relative to a known one — useful for label-value pairs and grid cells with no stable attributes.
How do you handle multiple windows or tabs?
Capture the current handle, trigger the popup, wait for the handle count to grow, switch by diffing the handle set, then switch back to the original handle.
How do you work with iframes, and what breaks when you forget to switch back?
switchTo().frame() by WebElement (most robust), interact, then switchTo().defaultContent(); until you switch back every locator resolves inside the frame and throws NoSuchElementException.
When do you need the Actions class instead of plain click and sendKeys?
For composite input: hover menus, drag and drop, right/double click, keyboard modifiers, and click-and-hold sliders — anything the W3C actions API models as a sequence.
Explain the Selenium 4 architecture and what changed from Selenium 3.
Selenium 4 speaks W3C WebDriver directly to the browser driver — the JSON Wire Protocol and its translation layer are gone — and Grid was rebuilt as Router, Distributor, Session Map, Queue and Node.
In what order do TestNG annotations execute?
@BeforeSuite → @BeforeTest → @BeforeClass → @BeforeMethod → @Test → @AfterMethod → @AfterClass → @AfterTest → @AfterSuite, with @BeforeGroups/@AfterGroups around grouped tests.
How do you run data-driven tests with @DataProvider, and when do you use an external file?
@DataProvider returns Object[][] (or an Iterator) that TestNG feeds into the test method once per row; move data to Excel/CSV/JSON when non-engineers own it or the set is large.
How do you configure parallel execution in TestNG?
Set parallel (methods, classes, tests or instances) plus thread-count in testng.xml, and make every shared resource thread-safe — driver in ThreadLocal, no static state, unique test data per thread.
What are the Maven lifecycle phases that matter for a test project?
validate → compile → test-compile → test → package → verify → install → deploy; running a later phase runs every earlier phase in that lifecycle.
How do dependency scopes work, and which scope should test libraries use?
compile is the default and leaks to consumers, provided is supplied at runtime by the container, runtime is not needed to compile, and test is only on the test classpath — Selenium, TestNG and REST Assured all belong in test scope.
Merge vs rebase — what do you use on an automation repository?
Rebase your own feature branch onto main to keep a linear history, merge (with a PR) into main; never rebase a branch other people have already pulled.
A commit broke the suite — how do you find and undo it?
git bisect to binary-search the first bad commit, then git revert it on main; use reset only on local, unpushed history.
How does Playwright auto-waiting differ from Selenium waits?
Playwright checks actionability (attached, visible, stable, enabled, receives events) before every action and retries until the timeout, so explicit waits are rarely needed.
Which locators do you prefer in Playwright and why?
Role-based and label-based locators first (getByRole, getByLabel), then getByTestId; raw CSS/XPath last because they couple tests to markup.
How do you reuse authentication instead of logging in per test?
Log in once in a setup project, save the session with storageState, and load that state in the config so each test starts signed in.
Showing the first 80 of 1207 results — refine your keywords to narrow it down.