PrepIQ Certified Selenium Automation Tester using Python Ultimate Exam, Exams of Technology

Covers Python-based Selenium automation, test framework development, web testing strategies, reporting, and automation optimization.

Typology: Exams

2025/2026

Available from 06/13/2026

shilpi-jain-2
shilpi-jain-2 🇮🇳

1

(1)

25K documents

1 / 47

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PrepIQ Certified Selenium
Automation Tester using Python
Ultimate Exam
**Question 1.** Which Selenium WebDriver method is used to navigate to a URL?
A) driver.open()
B) driver.get()
C) driver.navigate()
D) driver.load()
Answer: B
Explanation: `driver.get(url)` loads a web page in the browser pointed to by the
WebDriver instance.
**Question 2.** In Selenium with Python, which locator strategy is the fastest and
most reliable for locating elements?
A) By.XPATH
B) By.CSS_SELECTOR
C) By.NAME
D) By.LINK_TEXT
Answer: B
Explanation: CSS selectors are processed directly by the browser’s rendering
engine, making them quicker than XPath and less prone to DOM changes.
**Question 3.** What does the `find_element(By.ID, "username")` command
return if the element is not present?
A) None
B) An empty WebElement object
C) Raises `NoSuchElementException`
D) Returns a list with zero elements
Answer: C
Explanation: Selenium raises `NoSuchElementException` when the requested
element cannot be found.
**Question 4.** Which of the following commands will retrieve the text of a
WebElement `elem`?
A) elem.getText()
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f

Partial preview of the text

Download PrepIQ Certified Selenium Automation Tester using Python Ultimate Exam and more Exams Technology in PDF only on Docsity!

Automation Tester using Python

Ultimate Exam

Question 1. Which Selenium WebDriver method is used to navigate to a URL? A) driver.open() B) driver.get() C) driver.navigate() D) driver.load() Answer: B Explanation: driver.get(url) loads a web page in the browser pointed to by the WebDriver instance. Question 2. In Selenium with Python, which locator strategy is the fastest and most reliable for locating elements? A) By.XPATH B) By.CSS_SELECTOR C) By.NAME D) By.LINK_TEXT Answer: B Explanation: CSS selectors are processed directly by the browser’s rendering engine, making them quicker than XPath and less prone to DOM changes. Question 3. What does the find_element(By.ID, "username") command return if the element is not present? A) None B) An empty WebElement object C) Raises NoSuchElementException D) Returns a list with zero elements Answer: C Explanation: Selenium raises NoSuchElementException when the requested element cannot be found. Question 4. Which of the following commands will retrieve the text of a WebElement elem? A) elem.getText()

Automation Tester using Python

Ultimate Exam

B) elem.text() C) elem.text D) elem.get_attribute("innerText") Answer: C Explanation: In Python, the text property of a WebElement returns the visible text of the element. Question 5. Which Selenium class is used to handle multiple browser windows or tabs? A) WindowHandler B) SwitchTo C) WindowSwitcher D) TargetLocator Answer: D Explanation: driver.switch_to returns a TargetLocator object that provides methods like window() and frame() for switching contexts. Question 6. How can you switch to an iframe with the name attribute payment-frame? A) driver.switch_to.frame("payment-frame") B) driver.switch_to.iframe("payment-frame") C) driver.switch_to.window("payment-frame") D) driver.switch_to.frame_by_name("payment-frame") Answer: A Explanation: switch_to.frame() accepts the frame’s name, ID, index, or WebElement. Question 7. Which Selenium WebDriver method is used to accept a JavaScript alert? A) driver.alert.accept() B) driver.switch_to.alert.accept() C) driver.handle_alert.accept()

Automation Tester using Python

Ultimate Exam

Explanation: get_screenshot_as_file writes the screenshot directly to the given filename. Question 11. Which of the following is the correct way to execute a JavaScript snippet that returns the page title? A) driver.execute_script("return document.title;") B) driver.run_js("return document.title;") C) driver.execute_javascript("return document.title;") D) driver.js("return document.title;") Answer: A Explanation: execute_script runs JavaScript in the context of the current page; return passes the value back to Python. Question 12. In the Page Object Model (POM), where should the locators for a login page be defined? A) Directly inside the test case B) Inside a separate utility class C) As class attributes in the LoginPage class D) In a global constants file only Answer: C Explanation: POM encapsulates the page’s elements and actions in a class; locators are typically class attributes. Question 13. Which Python decorator is commonly used to mark a method as a test case when using the unittest framework? A) @test B) @pytest.mark.test C) @unittest.testcase D) No decorator; methods must start with test_ Answer: D Explanation: In unittest, any method whose name starts with test_ is automatically recognized as a test case.

Automation Tester using Python

Ultimate Exam

Question 14. When using pytest, which fixture provides a fresh WebDriver instance for each test function? A) @fixture(driver) B) @pytest.fixture(scope="function") C) @pytest.driver D) @pytest.fixture(scope="class") Answer: B Explanation: Defining a fixture with scope="function" ensures a new WebDriver is created for every test function that uses it. Question 15. Which command will close only the current browser window, leaving others open? A) driver.quit() B) driver.close() C) driver.exit() D) driver.shutdown() Answer: B Explanation: driver.close() closes the active window; driver.quit() ends the entire session. Question 16. How do you set Chrome to run in headless mode using Selenium in Python? A) ChromeOptions().add_argument("--headless") B) ChromeOptions().set_headless(True) C) ChromeOptions().headless = True D) ChromeOptions().add_headless() Answer: A Explanation: Adding the --headless argument to ChromeOptions starts Chrome without a UI. Question 17. Which of the following is NOT a valid way to locate an element using XPath? A) //button[text()="Submit"]

Automation Tester using Python

Ultimate Exam

Answer: C Explanation: The hub receives test requests and forwards them to appropriate nodes based on capabilities. Question 21. Which Desired Capability is used to specify the browser version in Selenium Grid? A) browser_version B) version C) browserVersion D) selenium_version Answer: B Explanation: The version capability denotes the specific browser version a node must support. Question 22. How can you retrieve all cookies from the current session? A) driver.get_all_cookies() B) driver.cookies() C) driver.get_cookies() D) driver.retrieve_cookies() Answer: C Explanation: driver.get_cookies() returns a list of dictionaries representing each cookie. Question 23. Which Python library is commonly used for reading Excel files in data-driven Selenium tests? A) csv B) openpyxl C) json D) pandas (read_excel) Answer: B Explanation: openpyxl reads and writes .xlsx files and is frequently used for data-driven testing.

Automation Tester using Python

Ultimate Exam

Question 24. What is the primary advantage of using the Page Factory pattern in Selenium? A) Reduces the number of test files B) Provides lazy loading of WebElements C) Eliminates the need for locators D) Enables parallel execution automatically Answer: B Explanation: Page Factory initializes WebElements only when they are accessed, improving performance and readability. Question 25. Which of the following statements about ActionChains is TRUE? A) It can only perform mouse actions, not keyboard actions B) Actions are executed immediately after each method call C) The chain must be finalized with perform() to execute D) It cannot be used with headless browsers Answer: C Explanation: ActionChains builds a queue of actions; perform() sends them to the browser. Question 26. How would you simulate pressing the ENTER key on an input element search_box? A) search_box.send_keys(Keys.ENTER) B) search_box.type(Keys.ENTER) C) search_box.press_key(Keys.ENTER) D) search_box.send_keys("\n") Answer: A Explanation: Selenium’s Keys class provides special keys; send_keys(Keys.ENTER) mimics the Enter key. Question 27. Which Python assertion is most appropriate for verifying that a list items contains a specific element item?

Automation Tester using Python

Ultimate Exam

D) Adjusts the size of the Selenium server window Answer: A Explanation: set_window_size directly changes the browser’s outer dimensions. Question 31. Which Selenium command can be used to scroll an element into view? A) driver.scroll_to(element) B) driver.execute_script("arguments[0].scrollIntoView();", element) C) element.scroll_into_view() D) driver.scroll(element) Answer: B Explanation: Executing the JavaScript scrollIntoView() method via execute_script brings the element into the viewport. Question 32. When automating a Single Page Application (SPA) built with React, which waiting strategy is most reliable? A) Fixed time.sleep(5) after each navigation B) Implicit wait of 10 seconds C) Explicit wait for a specific DOM element that appears after the API call D) No wait; SPAs load instantly Answer: C Explanation: SPAs load content dynamically; waiting for a concrete element that signals completion is the most robust method. Question 33. Which Python module provides the unittest.TestCase class? A) pytest B) nose C) unittest D) testtools Answer: C Explanation: The built-in unittest module defines TestCase for creating test classes.

Automation Tester using Python

Ultimate Exam

Question 34. How can you configure ChromeDriver to ignore SSL certificate errors? A) ChromeOptions().add_argument("--ignore-certificate-errors") B) ChromeOptions().set_capability("acceptInsecureCerts", True) C) Both A and B are valid D) Neither; Chrome cannot ignore SSL errors via Selenium Answer: C Explanation: Both adding the command-line argument and setting the acceptInsecureCerts capability work. Question 35. Which of the following statements about driver.execute_cdp_cmd() is TRUE? A) It is used only with FirefoxDriver B) It allows execution of Chrome DevTools Protocol commands C) It replaces execute_script for all JavaScript execution D) It cannot be used in headless mode Answer: B Explanation: execute_cdp_cmd sends commands to Chrome’s DevTools Protocol, enabling features like network throttling. Question 36. In Selenium, what is the purpose of the StaleElementReferenceException? A) The element is hidden from view B) The element no longer exists in the DOM C) The element is disabled D) The element is behind an overlay Answer: B Explanation: This exception occurs when a previously located element becomes detached due to page refresh or DOM changes. Question 37. Which Selenium method can be used to retrieve the current page’s URL?

Automation Tester using Python

Ultimate Exam

D) Soft assertions are not possible in Python Answer: C Explanation: pytest-check (or similar) allows checks that record failures without aborting the test. Question 41. When using webdriver-manager to manage driver binaries, which command installs the latest ChromeDriver? A) webdriver_manager.chrome import ChromeDriverManager; ChromeDriverManager().install() B) ChromeDriverManager.download_latest() C) webdriver_manager.install_chrome() D) ChromeDriverManager().setup() Answer: A Explanation: Importing ChromeDriverManager and calling .install() retrieves and sets up the appropriate binary. Question 42. Which of the following is a valid way to wait for a page to load completely using Selenium? A) driver.wait_for_page_load() B) WebDriverWait(driver, 30).until(lambda d: d.execute_script("return document.readyState") == "complete") C) driver.page_load_timeout = 30 D) time.sleep(30) Answer: B Explanation: Polling document.readyState via JavaScript ensures the page has fully loaded. Question 43. In Selenium, how can you capture a screenshot of a specific WebElement logo? A) logo.screenshot("logo.png") B) driver.get_screenshot_as_file("logo.png") C) driver.screenshot_element(logo, "logo.png") D) logo.take_screenshot("logo.png")

Automation Tester using Python

Ultimate Exam

Answer: A Explanation: The screenshot method on a WebElement captures only that element’s image. Question 44. Which of the following statements about headless mode is FALSE? A) It disables the browser UI but still renders pages B) It cannot execute JavaScript C) It is useful for CI pipelines D) Screenshots can still be taken in headless mode Answer: B Explanation: Headless browsers fully support JavaScript execution; they simply run without a visible UI. Question 45. Which Selenium command is used to switch to a browser window with a known title "Dashboard"? A) driver.switch_to.window("Dashboard") B) driver.switch_to.window_by_title("Dashboard") C) for handle in driver.window_handles: driver.switch_to.window(handle); if driver.title == "Dashboard": break D) driver.switch_to.title("Dashboard") Answer: C Explanation: Selenium does not provide a direct title-based switch; you iterate over handles and compare driver.title. Question 46. What is the purpose of the --remote-debugging-port Chrome option when used with Selenium? A) Enables remote Selenium Grid connections B) Allows debugging Chrome via Chrome DevTools while tests run C) Forces Chrome to run in incognito mode D) Disables all extensions automatically Answer: B

Automation Tester using Python

Ultimate Exam

Question 50. Which Selenium method is used to clear the text of an input field before entering new data? A) element.erase() B) element.clear() C) element.empty() D) element.reset() Answer: B Explanation: clear() removes any existing value from the input element. Question 51. In Selenium, which exception is raised when an operation times out while waiting for a condition? A) TimeoutException B) WaitTimeoutException C) NoSuchElementException D) StaleElementReferenceException Answer: A Explanation: TimeoutException signals that an explicit wait exceeded its timeout without satisfying the condition. Question 52. Which of the following is a recommended way to store test data that needs to be shared across multiple test modules? A) Hard-code values in each test file B) Use a global Python variable in conftest.py C) Store data in a JSON/YAML file and load it in fixtures D) Write data to a temporary SQLite database at runtime Answer: C Explanation: Externalizing data in JSON/YAML promotes reusability and separation of concerns. Question 53. What does the driver.set_page_load_timeout(20) method accomplish? A) Limits the time Selenium waits for the page to fully load before throwing an error

Automation Tester using Python

Ultimate Exam

B) Sets the implicit wait for element location to 20 seconds C) Pauses the test for 20 seconds after each navigation D) Configures the script execution timeout to 20 seconds Answer: A Explanation: This method defines the maximum time Selenium will wait for the document.readyState to become complete. Question 54. Which of the following is the correct syntax to click a button using JavaScript when the normal click fails? A) driver.execute_script("arguments[0].click()", button) B) driver.execute_script("button.click()") C) driver.run_script("arguments[0].click()", button) D) driver.execute_javascript("arguments[0].click()", button) Answer: A Explanation: Passing the element as an argument (arguments[0]) ensures the script acts on the specific WebElement. Question 55. When using pytest-xdist for parallel test execution, which command runs tests across 4 processes? A) pytest -n 4 B) pytest --parallel= C) pytest -p 4 D) pytest --processes= Answer: A Explanation: The -n option specifies the number of worker processes. Question 56. Which of the following is NOT a built-in Selenium Expected Condition? A) presence_of_element_located B) element_to_be_clickable C) visibility_of_any_elements_located D) element_to_be_visible

Automation Tester using Python

Ultimate Exam

Question 60. Which of the following options correctly disables Chrome’s “Save Password” prompt? A) ChromeOptions().add_experimental_option("excludeSwitches", ["enable- automation"]) B) ChromeOptions().add_argument("--disable-save-password-bubble") C) ChromeOptions().add_experimental_option("prefs", {"credentials_enable_service": False, "profile.password_manager_enabled": False}) D) ChromeOptions().set_preference("savePasswordPrompt", False) Answer: C Explanation: Setting the credentials_enable_service and profile.password_manager_enabled preferences disables the prompt. Question 61. What is the effect of calling driver.maximize_window()? A) Sets the window size to 1920× B) Expands the window to fill the screen’s available resolution C) Changes the viewport to the maximum allowed by the OS D) Only works on Firefox, not Chrome Answer: B Explanation: maximize_window asks the browser to occupy the full screen area (excluding OS UI elements). Question 62. Which of the following statements about pytest fixtures is FALSE? A) Fixtures can have scopes such as function, class, module, session B) Fixtures can be parametrized to run multiple times with different data C) Fixtures must always return a value; they cannot yield D) Fixtures can be autouse, applying automatically to tests in their scope Answer: C Explanation: Fixtures can either return a value or use yield to provide teardown logic; returning is not mandatory.

Automation Tester using Python

Ultimate Exam

Question 63. Which Selenium method can be used to retrieve the HTML source of the current page? A) driver.page_source() B) driver.get_source() C) driver.page_source D) driver.source Answer: C Explanation: driver.page_source is a property that returns the DOM as a string. Question 64. In Selenium, which command is used to send a sequence of keystrokes that includes special keys like CTRL+A? A) element.send_keys(Keys.CONTROL, "a") B) element.send_keys(Keys.CONTROL + "a") C) element.send_keys(Keys.CONTROL, "a") D) element.send_keys(Keys.CONTROL, Keys.A) Answer: D Explanation: Combining Keys.CONTROL with Keys.A simulates the Ctrl+A shortcut. Question 65. Which of the following is a valid way to set a Firefox profile preference to disable the “pop-up blocker”? A) profile.set_preference("dom.disable_open_during_load", False) B) profile.set_preference("privacy.popups.disable", True) C) profile.set_preference("network.popups.allow", True) D) profile.set_preference("browser.popups.showPopup", False) Answer: A Explanation: The dom.disable_open_during_load preference controls automatic pop-up blocking. Question 66. What is the purpose of the --disable-gpu flag when launching Chrome in headless mode? A) It forces Chrome to use software rendering only