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.
Explain how to set browser capabilities and options for Chrome and Firefox in Selenium WebDriver. Include how to enable headless mode, set a custom download directory, disable extensions, configure proxies, and explain the difference between legacy DesiredCapabilities and the modern Options/BrowserOptions APIs.
Write a pytest test in Python using Selenium WebDriver that automates a login flow on 'https://example.com/login'. The test must: open the URL, wait for input fields with ids 'username' and 'password', enter credentials 'testuser'/'P@ssw0rd', click the submit button with id 'login-btn', and assert the resulting page title contains 'Dashboard'. Use explicit waits and include a concise setup/teardown or fixture. Assume chromedriver is on PATH.
Describe how to manage browser windows and tabs with Selenium WebDriver: how to open a new tab or window, how to get and switch between window handles, how to close a tab and restore focus, and common pitfalls such as stale handles or unexpected focus changes. Include what to do when a new window is opened asynchronously by the page.
Read this simple Python unittest snippet and explain, step-by-step, what the test does, what the setUp method provides, and what happens in the framework when the assertion fails. Identify which parts are fixture, action, and verification.
import unittest
class TestLogin(unittest.TestCase):
def setUp(self):
self.user = {'username': 'alice', 'password': 'pass'}
def test_login_status(self):
status = login(self.user)
self.assertEqual(status, 200)
A UI test intermittently fails with only an 'element not found' assertion message, and you suspect a client-side JavaScript error or a failed background network call is the real cause. Describe how you would capture browser console output and network activity during the test run, and how you would attach that evidence to your CI failure reports so a teammate can triage the failure without re-running it locally. Which log types are most useful, and why?
Unlock Full Question Bank
Get access to all 32 Test Automation Scripting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.