Test Automation Scripting Questions
Writing the actual code inside a single automated test script: control flow, reusable helper functions, single-script parameterization (for example @pytest.mark.parametrize-style data tables), and translating an existing manual test case into an automated one. Covers script-level debugging (diagnosing and fixing a failing or flaky SINGLE script or test method: stale-element/timing exceptions, test-order dependencies, shared-state bugs between loop iterations) and improving the robustness of individual scripts (applying explicit waits, retry logic, and stable locators as part of fixing one script, assertions versus soft assertions). Scoped to the code inside one script or test method, using any browser/API automation tool. Excludes: designing or restructuring the shared framework that many scripts run on (layering, Page Object Model design, reporting hooks, base classes, CI/config wiring, choosing between automation tools, cross-framework migration planning, governance of shared test code), which belongs to test automation framework architecture. Excludes general-purpose Java or Python programming exercises not specific to authoring or maintaining a test script (data structures, OOP, algorithm/coding-round problems), which belong to programming fundamentals for test automation. Excludes locator-strategy and wait-strategy comparison AS A DEDICATED SUBJECT (comparing id/CSS/XPath, implicit-vs-explicit-wait theory, self-healing locators, cross-suite synchronization), which belongs to UI element locators and test synchronization. Excludes test-data management and provisioning STRATEGY at environment or multi-test scale (external data stores, compliance/privacy, parallel-CI isolation), which belongs to data-driven testing. Excludes suite-wide flaky-test detection, quarantine systems, and retry-vs-fix-root-cause policy, which belong to flaky test management and test reliability; this topic keeps only root-causing and fixing ONE script's own flaky failure. Excludes CI/pipeline test-selection and gating policy (smoke-vs-regression tagging, quality gates, suite-runtime-reduction planning), which belongs to pipeline testing and quality gates. Excludes test-level/pyramid conceptual placement, which belongs to test levels and the test pyramid. Excludes API-testing strategy (schema/contract validation, auth-flow testing as its own discipline), which belongs to API and contract testing; this topic keeps only the act of writing one API test script's code. Excludes accessibility-testing integration.
Analyze the following failing test output and explain the most likely root cause, the immediate triage steps you would take, and the next steps to prevent recurrence. Pay attention to HTTP status, response body and the CI/environment metadata provided.
FAIL: test_submit_order (tests.test_checkout.TestCheckout)
Traceback (most recent call last):
File "/workspace/tests/test_checkout.py", line 58, in test_submit_order
assert response.status_code == 200
AssertionError: 500 != 200
Response body: {
"error": "NullReferenceException",
"stack": "at OrderService.SubmitOrder() ..."
}
CI agent: linux-builder-12, db: staging-2026-02-10, commit: abc123
Define a test fixture (setup/teardown) in the context of automated tests. Provide examples of resources commonly prepared and cleaned up by fixtures (e.g., database connections, browser instances, mock servers). Explain when to use method-level (per-test), class-level, or suite-level fixtures and the trade-offs of each choice.
In Java, write a Selenium example using Actions to perform drag-and-drop from a source element to a target element. Then explain why Actions.dragAndDrop sometimes fails for HTML5 drag-and-drop implementations and provide a JavaScript fallback approach that simulates HTML5 drag events via executeScript.
Explain strategies to interact with single-select dropdowns and custom dropdown widgets. Cover using the Selenium Select helper for HTML select elements, selecting by visible text/value/index, and how to handle custom dropdowns implemented with divs and ARIA roles.
You have an async Python function that sometimes raises TimeoutError when a downstream client is slow: async def fetch_with_retry(client, retries=3): for i in range(retries): try: return await client.fetch() except TimeoutError: pass raise TimeoutError. Write a pytest async unit test that uses monkeypatch or a fake client to assert the function retries at least twice before failing, and describe how you'd test backoff policies.
Unlock Full Question Bank
Get access to all 33 Test Automation Scripting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.