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.
Write a pytest-based Selenium test in Python that verifies an AJAX-loaded table contains a row with a specific value (e.g., 'Order #12345'). The test should use an explicit wait until the table has more than zero rows, then search table rows for the target value. Structure the test using a simple page object class for the table component.
Explain how to execute JavaScript in the browser context from Selenium WebDriver to perform actions not supported by native APIs (examples: scroll into view, read window.performance timings, change element attributes). Provide short example calls for both Python (execute_script) and Java (executeScript) and discuss return value handling and safety considerations.
A UI test passes on a developer machine but intermittently fails in CI with an 'element not found' error. Provide a step-by-step checklist to investigate this CI-only failure, listing what artifacts and environment differences you would inspect and two experiments you would run in CI to isolate the root cause.
Write a sample Selenium WebDriver test (in Python or JavaScript) using the Page Object Model for the login flow. Your submission should show: a page object with selectors and login method, a parameterized test that uses multiple credential sets, and how setup and teardown are handled. Keep code compact but realistic.
A critical end-to-end test fails nondeterministically during page load because a third-party analytics script sometimes blocks user-event listeners from firing. You cannot change production code. Describe how you would investigate, reproduce, and mitigate this issue so the test suite is reliable without modifying production code. Include short-term and long-term options.
Unlock Full Question Bank
Get access to all 11 Test Automation Scripting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.