Certified Professional Selenium Tester (CPST) — Questions and Answers
Question 1: What does the @DataProvider annotation in TestNG return?
- String[]
- List<Object>
- Object[][] (Correct answer)
- Map<String, Object>
Correct answer: Object[][]
A @DataProvider method must return a two-dimensional Object array, where each inner array is one set of parameters for a test iteration.
Question 2: Which CSS selector matches an element that has BOTH the class 'btn' AND the class 'primary'?
- .btn .primary
- #btn.primary
- .btn, .primary
- .btn.primary (Correct answer)
Correct answer: .btn.primary
Chaining class selectors without a space (.btn.primary) matches elements that have both classes simultaneously.
Question 3: In a Selenium Grid 4 fully distributed architecture, which component can be scaled independently to increase session throughput?
- The Session Map, since it is the performance bottleneck
- The Router, since it handles all incoming HTTP requests
- The Event Bus, since all components communicate through it
- The Node, since more nodes directly increase available browser slots (Correct answer)
Correct answer: The Node, since more nodes directly increase available browser slots
Scaling Nodes horizontally increases the total number of concurrent browser sessions the Grid can handle, directly improving test throughput.
Question 4: In Selenium WebDriver, which interface method can be used to intercept and modify network requests to simulate API failures during testing?
- driver.executeScript()
- driver.manage().addCookie()
- driver.navigate().to()
- DevTools CDP network interception (Correct answer)
Correct answer: DevTools CDP network interception
Chrome DevTools Protocol (CDP) network interception allows Selenium tests to intercept, block, or modify HTTP requests to simulate API failures.
Question 5: Which algorithm would you use to find the shortest test execution path through a Selenium test dependency graph?
- Depth First Search
- Binary Search
- Dijkstra's Algorithm (Correct answer)
- Breadth First Search
Correct answer: Dijkstra's Algorithm
Dijkstra's Algorithm finds the shortest weighted path between nodes, suitable for optimizing test execution order with costs.
Question 6: How do you read a value from a text input field using Selenium WebDriver?
- element.getText()
- element.getInput()
- element.getAttribute("value") (Correct answer)
- element.getValue()
Correct answer: element.getAttribute("value")
getAttribute("value") retrieves the current value of a form input element, as getText() returns the visible text between tags.
Question 7: What does driver.findElements() return when no elements match the given locator?
- null
- Throws NoSuchElementException
- An empty List<WebElement> (Correct answer)
- A WebElement with no properties
Correct answer: An empty List<WebElement>
findElements() always returns a List<WebElement> — an empty list when nothing matches, never null or an exception.
Question 8: What is the purpose of using 'driver.manage().timeouts().pageLoadTimeout()' in Selenium?
- Configures the implicit wait for all elements
- Sets maximum time to wait for a page to fully load before throwing an exception (Correct answer)
- Sets delay between keystrokes in sendKeys()
- Sets maximum time to locate an element
Correct answer: Sets maximum time to wait for a page to fully load before throwing an exception
pageLoadTimeout() defines how long WebDriver waits for a page load to complete before throwing a TimeoutException.
Question 9: Which Selenium Grid 4 feature allows browser Nodes to be managed inside Docker containers with automatic creation and removal?
- Grid Relay Nodes
- Grid Node Pooling
- Dynamic Grid with Docker (Correct answer)
- Selenium Standalone Server clustering
Correct answer: Dynamic Grid with Docker
Selenium Grid 4's Dynamic Grid feature uses Docker to spin up browser containers on demand for each session and removes them when the session ends.
Question 10: In a Selenium test framework, what is the primary benefit of creating an 'API client helper class' for common API operations?
- It centralizes API call logic for reuse and easier maintenance (Correct answer)
- It automatically generates test data
- It replaces the need for a Page Object Model
- It speeds up browser rendering
Correct answer: It centralizes API call logic for reuse and easier maintenance
An API client helper class centralizes repeated API call logic so changes to the API require updates in only one place rather than across all tests.
Question 11: What happens if you call driver.findElement() and the element does not exist in the DOM?
- Returns an empty WebElement
- Returns null
- Throws NoSuchElementException (Correct answer)
- Throws ElementNotFoundException
Correct answer: Throws NoSuchElementException
findElement() throws NoSuchElementException immediately (or after implicit wait timeout) if no matching element is found.
Question 12: In Selenium API integration, what is the purpose of an 'API gateway' in the test architecture?
- A Selenium plugin for API testing
- A server that acts as an entry point managing routing, authentication, and rate limiting for APIs (Correct answer)
- A database layer for storing API responses
- A UI component that displays API documentation
Correct answer: A server that acts as an entry point managing routing, authentication, and rate limiting for APIs
An API gateway is a server that handles cross-cutting concerns like authentication, routing, and rate limiting for multiple backend APIs.
Question 13: What is the benefit of parallel test execution in Selenium?
- It reduces test run time by executing multiple tests simultaneously (Correct answer)
- It limits testing to one environment
- It decreases test accuracy
- It increases test execution time
Correct answer: It reduces test run time by executing multiple tests simultaneously
Parallel test execution involves running multiple test cases concurrently rather than sequentially. The key benefit of this approach in Selenium is a significant reduction in the overall test run time. By leveraging multiple browser instances or machines (often with Selenium Grid), tests can be completed much faster, leading to quicker feedback and improved efficiency in the development pipeline.
Question 14: What is the primary goal of quality assurance in Selenium Testing Certification?
- Completing tasks as quickly as possible
- Finding someone to blame for errors
- Ensuring consistent standards and continuous improvement (Correct answer)
- Reducing staff numbers
Correct answer: Ensuring consistent standards and continuous improvement
Quality assurance focuses on maintaining consistent standards and identifying opportunities for continuous improvement in processes and outcomes.
Question 15: Which Selenium Grid deployment mode is most appropriate for a small team running fewer than 50 concurrent tests?
- Distributed mode with separate Hub, Router, Distributor, and Session Map processes
- Docker Swarm with dynamic node provisioning
- Standalone mode running all Grid components in a single JVM process (Correct answer)
- Kubernetes-orchestrated Grid with auto-scaling node pools
Correct answer: Standalone mode running all Grid components in a single JVM process
Standalone mode bundles all Grid components into one process, making setup simple and sufficient for small-scale parallel execution needs.
Question 16: Which security measure is essential for protecting Selenium Testing Certification digital systems?
- Implementing multi-factor authentication (Correct answer)
- Sharing login credentials
- Using simple passwords
- Disabling firewalls
Correct answer: Implementing multi-factor authentication
Multi-factor authentication adds extra layers of security beyond passwords, significantly reducing unauthorized access risk.
Question 17: What does StaleElementReferenceException indicate in a Selenium test?
- The element was found but is not interactable
- The element reference is no longer valid because the DOM was updated (Correct answer)
- The element's text content is empty
- The locator strategy returned multiple elements
Correct answer: The element reference is no longer valid because the DOM was updated
StaleElementReferenceException occurs when the DOM refreshes after an element is located, making the stored reference obsolete.
Question 18: A Selenium test needs to validate that the login page enforces HTTPS. What is the correct assertion?
- Verify the padlock icon is visible in the page DOM
- Check that the submit button is enabled only on secure connections
- Assert the form action attribute contains 'secure'
- Assert driver.getCurrentUrl() starts with 'https://' (Correct answer)
Correct answer: Assert driver.getCurrentUrl() starts with 'https://'
Checking the current URL prefix with getCurrentUrl() is the direct, reliable way to assert that the browser is on an HTTPS connection.
Question 19: What is system integration in Selenium Testing Certification technology?
- Using only one software application
- Removing outdated technology
- Running systems independently
- Connecting different systems to work together seamlessly (Correct answer)
Correct answer: Connecting different systems to work together seamlessly
System integration connects multiple software applications or platforms so they can share data and work together efficiently.
Question 20: In a Selenium framework, what is a key design consideration when implementing screenshot capture on test failure?
- Screenshots should only be captured for tests running in headless mode
- Screenshots should be captured before the WebDriver session closes so the browser is still available (Correct answer)
- Screenshots must be taken using a third-party screen capture library, not WebDriver
- Screenshots need to be captured in a separate thread to avoid blocking the test
Correct answer: Screenshots should be captured before the WebDriver session closes so the browser is still available
Failure screenshots must be taken before WebDriver.quit() is called, typically in an @AfterMethod or listener's onTestFailure hook while the session is still active.
Question 21: What is the role of the Content-Security-Policy (CSP) header, and how would a Selenium test verify it is present?
- CSP restricts resource origins to prevent XSS; capture response headers via a proxy or Chrome DevTools Protocol and assert the CSP header exists (Correct answer)
- CSP controls cookie expiry; read it from driver.manage().getCookies()
- CSP encrypts form submissions; assert all forms use POST
- CSP limits page rendering speed; assert page load time is under a threshold
Correct answer: CSP restricts resource origins to prevent XSS; capture response headers via a proxy or Chrome DevTools Protocol and assert the CSP header exists
CSP headers must be inspected at the HTTP response level using a proxy or CDP since WebDriver doesn't expose response headers natively.
Question 22: Which Selenium WebDriver method allows you to capture a screenshot of the current browser state for debugging purposes?
- driver.saveScreenshot()
- driver.captureScreen()
- ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE) (Correct answer)
- driver.screenshot().save()
Correct answer: ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE)
The TakesScreenshot interface provides getScreenshotAs() to capture the current browser state as a file, byte array, or base64 string.
Question 23: In Selenium Grid 4, how do you register a node to a hub?
- selenium-node connect --hub http://hub:4444
- java -jar selenium.jar node --hub http://hub:4444 (Correct answer)
- grid-node --register http://hub:4444
- java -jar selenium.jar register --hub http://hub:4444
Correct answer: java -jar selenium.jar node --hub http://hub:4444
In Grid 4, you start a node with 'java -jar selenium.jar node --hub <hub-url>' to register it with the hub.
Question 24: In Selenium Grid, when a Node registers with the Hub (Grid 3) or Router (Grid 4), what information does it send?
- Its capabilities including browser type, version, and OS platform (Correct answer)
- The current CPU and memory utilization metrics only
- List of test scripts available for execution
- Authentication credentials for secure communication
Correct answer: Its capabilities including browser type, version, and OS platform
Nodes advertise their capabilities (browser name, version, OS) to the Hub/Router so it can match incoming session requests to appropriate nodes.
Question 25: Which component in Selenium Grid 4 is responsible for accepting incoming WebDriver session requests from test clients?
- Node
- Session Map
- Distributor
- Router (Correct answer)
Correct answer: Router
The Router is the entry point of Grid 4, forwarding new session requests to the Distributor and routing existing session commands to the correct Node.
Question 26: What is the purpose of using Abstract Factory or Factory Method patterns in a Selenium cross-browser framework?
- To generate test data for each supported browser type
- To create the correct WebDriver implementation (ChromeDriver, FirefoxDriver, etc.) based on a runtime parameter (Correct answer)
- To parallelize tests automatically across multiple browser types
- To validate that browser-specific CSS renders correctly
Correct answer: To create the correct WebDriver implementation (ChromeDriver, FirefoxDriver, etc.) based on a runtime parameter
Factory patterns decouple browser creation logic from test code, returning the appropriate WebDriver subclass based on a configuration parameter without if-else chains in tests.
Question 27: In a hybrid test framework combining Selenium and API tests, what pattern uses API calls to create preconditions and Selenium to verify the UI outcome?
- Keyword-Driven Testing
- API-First UI Testing (Correct answer)
- Page Object Model
- Data-Driven Testing
Correct answer: API-First UI Testing
API-First UI Testing uses API calls to set up state quickly and then uses Selenium to verify that the UI correctly reflects that state.
Question 28: What is the architectural benefit of using a Base Page class in a Page Object Model framework?
- It centralizes common WebDriver interactions and wait logic for all page objects to inherit (Correct answer)
- It manages browser instantiation and teardown lifecycle
- It stores test data and configuration properties
- It removes the need for explicit waits across all tests
Correct answer: It centralizes common WebDriver interactions and wait logic for all page objects to inherit
A Base Page class provides shared methods like element clicking, typing, and waiting that all page objects inherit, eliminating code duplication.
Question 29: In cloud-based parallel Selenium testing, what is the role of a 'session queue'?
- Queues DOM events for replay
- Manages user login sessions across tests
- Holds pending WebDriver session requests until a node becomes available (Correct answer)
- Stores browser screenshots for later review
Correct answer: Holds pending WebDriver session requests until a node becomes available
The session queue buffers incoming new-session requests so they are not dropped when all nodes are busy, ensuring orderly dispatch.
Question 30: Which approach best supports quality outcomes in Security & Authentication for Selenium Testing Certification?
- Systematic application of evidence-based methods (Correct answer)
- Rushing through tasks
- Avoiding quality checks
- Relying solely on intuition
Correct answer: Systematic application of evidence-based methods
Evidence-based methods provide a reliable foundation for achieving consistent, high-quality outcomes.
Question 31: What is the correct way to handle a browser alert using Selenium WebDriver?
- driver.getAlert().accept()
- driver.switchTo().alert().accept() (Correct answer)
- driver.alert().dismiss()
- driver.handleAlert().accept()
Correct answer: driver.switchTo().alert().accept()
driver.switchTo().alert() switches context to the alert, then accept() or dismiss() handles it.
Question 32: Which CSS selector selects only <p> elements that are DIRECT children of a <div>?
- div > p (Correct answer)
- div ~ p
- div p
- div + p
Correct answer: div > p
The > combinator selects only direct children, so div > p matches <p> elements immediately inside a <div>, not nested descendants.
Question 33: In a Jenkins declarative pipeline, which stage configuration runs Selenium tests only when merging to the main branch?
- when { branch 'main' } (Correct answer)
- condition { branch == 'main' }
- if (env.BRANCH_NAME == 'main')
- only_on: main
Correct answer: when { branch 'main' }
The `when { branch 'main' }` directive in declarative pipelines conditionally executes a stage based on the current branch name.
Question 34: Which DesiredCapabilities or option allows Selenium tests to run in headless Chrome?
- ChromeOptions.setHeadless(true)
- options.addArguments("--headless=new") (Correct answer)
- DesiredCapabilities.headless()
- ChromeOptions.setMode("headless")
Correct answer: options.addArguments("--headless=new")
Adding '--headless=new' argument to ChromeOptions runs Chrome without a visible browser window.
Question 35: Which TestNG feature enables Selenium tests to be distributed across multiple machines in a CI environment?
- DataProvider with parallel execution
- TestNG Suite XML with thread-count and RemoteWebDriver (Correct answer)
- TestNG's parallel='tests' with remote Grid
- @Test(invocationCount=N)
Correct answer: TestNG Suite XML with thread-count and RemoteWebDriver
A TestNG Suite XML configured with thread-count combined with RemoteWebDriver pointing to a Selenium Grid distributes test execution across nodes.
Question 36: Which Selenium feature allows you to simulate keyboard shortcuts such as Ctrl+A to select all text in an input field?
- element.keyCombo(Keys.CONTROL, "a")
- element.sendKeys(Keys.chord(Keys.CONTROL, "a")) (Correct answer)
- element.pressKeys(Keys.CONTROL + "a")
- Actions.keyboardShortcut(element, "ctrl+a")
Correct answer: element.sendKeys(Keys.chord(Keys.CONTROL, "a"))
Keys.chord() combines multiple key inputs into a single string that sendKeys() can use to simulate key combinations.
Question 37: A cloud Selenium test suite needs to run against a staging site accessible only inside a VPC. Which approach best enables this?
- Deploy the Selenium Grid nodes inside the same VPC as the staging site (Correct answer)
- Use only local WebDriver instances
- Disable VPC firewall rules entirely
- Use a public Selenium SaaS grid without any tunneling
Correct answer: Deploy the Selenium Grid nodes inside the same VPC as the staging site
Deploying Grid nodes inside the VPC gives them direct network access to internal staging URLs without exposing them to the internet.
Question 38: Which framework helps manage and execute Selenium test scripts?
- Mocha
- Jasmine
- JUnit
- TestNG (Correct answer)
Correct answer: TestNG
TestNG is a powerful testing framework for Java that is widely used with Selenium for managing and executing test scripts. It provides advanced features like test configuration, parallel test execution, data-driven testing, and flexible reporting. TestNG simplifies the organization and execution of complex test suites, making it a preferred choice for robust and scalable Selenium automation projects.
Question 39: Which Java library is commonly used alongside Selenium to make REST API calls within test automation frameworks?
- RestAssured (Correct answer)
- Hamcrest
- Mockito
- JUnit
Correct answer: RestAssured
RestAssured is a popular Java library specifically designed for testing and validating REST APIs in automation frameworks.
Question 40: Which assertion approach is most appropriate when a Selenium test validates that an API response contains a specific nested JSON field?
- Use JSONPath expressions to extract and assert the specific field value (Correct answer)
- Assert the entire response string matches exactly
- Convert the response to XML before asserting
- Assert only the HTTP status code
Correct answer: Use JSONPath expressions to extract and assert the specific field value
JSONPath expressions allow precise navigation and extraction of specific fields within nested JSON structures for targeted assertions.
Question 41: A company wants to run Selenium tests across 50 browser/OS combinations simultaneously in the cloud. Which strategy best achieves this?
- Run all 50 combinations sequentially on a single cloud VM
- Use a cross-browser cloud testing service or a large Selenium Grid with diverse nodes and parallel test execution (Correct answer)
- Use Selenium IDE's record-and-playback feature on one machine
- Limit testing to a single browser and OS to reduce complexity
Correct answer: Use a cross-browser cloud testing service or a large Selenium Grid with diverse nodes and parallel test execution
Cloud services or a scaled-out Grid with parallel execution are the only practical way to cover 50 combinations in a reasonable time.
Question 42: When an API response contains paginated data, how should a Selenium test framework handle retrieving all records?
- Increase the timeout value
- Use a single API call with a very large page size parameter
- Switch to a UI-based approach for paginated data
- Implement a loop that calls the API repeatedly until no next-page token is returned (Correct answer)
Correct answer: Implement a loop that calls the API repeatedly until no next-page token is returned
Handling pagination requires iterating through pages using continuation tokens or page numbers until the API indicates no more data remains.
Question 43: When using Selenium with CI/CD pipelines (e.g., Jenkins), what is the most common reason to use headless browser mode?
- CI servers typically lack a display server (GUI), so headless allows tests to run without one (Correct answer)
- Headless mode skips JavaScript execution for speed
- Headless mode runs faster than headed mode always
- Jenkins requires headless mode for security reasons
Correct answer: CI servers typically lack a display server (GUI), so headless allows tests to run without one
CI/CD build agents often run on servers without a GUI display, making headless mode essential for browser-based tests.
Question 44: A Selenium test needs to verify that a newly created user record exists in the database. Which SQL clause is most appropriate to check for a specific email value?
- WHERE (Correct answer)
- GROUP BY
- HAVING
- ORDER BY
Correct answer: WHERE
The WHERE clause filters rows based on a condition, making it ideal for locating a specific record by a column value.
Question 45: When debugging a flaky test, which Selenium strategy helps identify whether element visibility is causing intermittent failures?
- Switching to ID-based locators only
- Using ExpectedConditions.visibilityOfElementLocated() with explicit waits (Correct answer)
- Increasing the implicit wait globally
- Adding Thread.sleep() calls
Correct answer: Using ExpectedConditions.visibilityOfElementLocated() with explicit waits
ExpectedConditions.visibilityOfElementLocated() with explicit waits precisely waits for element visibility, eliminating timing-related flakiness.
Question 46: In Selenium Testing Certification, what is a Key Performance Indicator (KPI)?
- A mandatory training requirement
- A financial penalty for poor performance
- A measurable value that demonstrates effectiveness (Correct answer)
- A compliance checklist
Correct answer: A measurable value that demonstrates effectiveness
KPIs are quantifiable measurements that demonstrate how effectively objectives are being achieved.
Question 47: What is the purpose of a feasibility study in Selenium Testing Certification project planning?
- To assign team roles
- To start the project immediately
- To determine if a project is viable and worth pursuing (Correct answer)
- To create a marketing plan
Correct answer: To determine if a project is viable and worth pursuing
A feasibility study evaluates whether a project is technically, financially, and operationally viable before committing resources.
Question 48: Which Selenium command is used to retrieve the current URL of the browser?
- driver.currentUrl()
- driver.getURL()
- driver.fetchUrl()
- driver.getCurrentUrl() (Correct answer)
Correct answer: driver.getCurrentUrl()
driver.getCurrentUrl() returns the URL of the page currently loaded in the browser.
Question 49: What is the correct way to handle multiple checkboxes and select only those that are not already checked?
- Only findElement() works for checkboxes
- Use Select class to toggle checkboxes
- Use driver.checkAll() then uncheck manually
- Iterate driver.findElements(), check isSelected(), click if false (Correct answer)
Correct answer: Iterate driver.findElements(), check isSelected(), click if false
Find all checkbox elements with findElements(), loop through them, and call click() only on those where isSelected() returns false.
Question 50: What is the benefit of using a Selenium WebDriver wrapper or utility class in a framework architecture?
- It enables running Selenium tests without a browser driver binary
- It bypasses WebDriver's built-in security restrictions
- It allows direct manipulation of the browser's internal JavaScript engine
- It centralizes common actions like safe clicks and waits, making tests more readable and reducing duplicated wait logic (Correct answer)
Correct answer: It centralizes common actions like safe clicks and waits, making tests more readable and reducing duplicated wait logic
A WebDriver wrapper consolidates retry logic, custom explicit waits, and common interactions into one place, so test and page object code stays clean and DRY.
Certified Professional Selenium Tester (CPST)
The CPST certification validates expertise in Selenium automation testing including WebDriver, test design, scripting, grid configuration, API integration, and cloud-based testing solutions. It is designed for QA engineers and automation testers.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds