




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This exam guide delivers comprehensive preparation in Selenium automation using Python, covering framework setup, scripting, test execution, debugging, and CI/CD workflows. The guide emphasizes hands-on testing competence and exam-aligned scenarios.
Typology: Exams
1 / 105
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which of the following best defines test automation? A) Executing test cases manually without tools B) Using scripts or tools to run tests automatically C) Designing test cases only for functional testing D) Performing exploratory testing without documentation Answer: B Explanation: Test automation involves using software tools or scripts to execute test cases automatically, reducing manual effort and increasing repeatability. Question 2. In the ROI analysis for automation, which factor most directly impacts the decision to automate a test case? A) The skill level of the tester B) The frequency of test execution C) The color scheme of the application UI D) The programming language used for development Answer: B Explanation: High-frequency test cases yield greater ROI when automated because the time saved per execution accumulates quickly. Question 3. Which phase of the Test Automation Life Cycle (TALC) involves selecting the appropriate automation tool? A) Requirement analysis B) Tool selection criteria C) Execution and maintenance D) Test plan development Answer: B
Explanation: Tool selection criteria is a dedicated phase where factors such as technology support, licensing, and integration are evaluated. Question 4. Which automation framework type emphasizes reusability by separating test data from test scripts? A) Linear framework B) Modular framework C) Data-Driven framework D) Keyword-Driven framework Answer: C Explanation: Data-Driven frameworks store inputs in external files (e.g., CSV, Excel) and drive the same script with multiple data sets. Question 5. In Python, which statement correctly creates a dictionary? A) my_dict = { "name": "Alice", "age": 30 } B) my_dict = [ "name": "Alice", "age": 30 ] C) my_dict = ( "name": "Alice", "age": 30 ) D) my_dict = "name":"Alice", "age":30 Answer: A Explanation: Curly braces {} with key-value pairs create a dictionary in Python. Question 6. What is the output of the following Python code?
x = [1, 2, 3] y = x y.append(4) ## Tester using Python Certification Exam Guide Explanation: Inheritance enables a child class to inherit attributes and methods from its parent. **Question 9.** Which block of code correctly handles a possible `ZeroDivisionError` exception? A) ```python try: result = a / b except ZeroDivisionError: print("Cannot divide by zero")B)
if b == 0: raise ZeroDivisionErrorC)
try: result = a / b finally: print("Done")D)
## Tester using Python Certification Exam Guide except ZeroDivisionError: result = 0Answer: A Explanation: The try/except construct catches the specific ZeroDivisionError and handles it gracefully. Question 10. Which library would you import to work with Excel files in Python for data-driven testing? A) csv B) json C) openpyxl D) xml.etree Answer: C Explanation: openpyxl provides read/write capabilities for .xlsx Excel workbooks. Question 11. Which command installs the Selenium library using pip? A) pip install selenium B) pip selenium install C) python -m selenium install D) pip get selenium Answer: A Explanation: pip install selenium downloads and installs the Selenium package from PyPI. Question 12. After installing ChromeDriver, which line correctly initiates a Chrome browser session in Python?
Question 15. Which command will close only the current browser window while keeping the WebDriver session alive? A) driver.quit() B) driver.close() C) driver.end() D) driver.exit() Answer: B Explanation: driver.close() closes the active window; driver.quit() ends the entire session. Question 16. Which locator strategy is generally the fastest and most reliable? A) XPath B) CSS Selector C) ID D) Link Text Answer: C Explanation: Locating by id leverages the DOM’s native indexing, making it the quickest and most stable. Question 17. Which XPath expression selects an element with the exact text “Login”? A) //button[text()='Login'] B) //button[contains(text(),'Login')] C) //button[@value='Login'] D) //button[@id='Login'] Answer: A Explanation: text()='Login' matches the node’s exact text content.
Question 18. How would you locate a button element using a CSS selector that has both classes btn and primary? A) button.btn.primary B) button#btn.primary C) .btn#primary D) #btn .primary Answer: A Explanation: In CSS, chaining class names without spaces selects an element that possesses both classes. Question 19. Which Selenium method clears the existing text from an input field? A) element.erase() B) element.clear() C) element.delete() D) element.remove() Answer: B Explanation: clear() removes any pre-filled value from a text box. Question 20. To select an option with visible text “Canada” from a `` element, which code is correct? A)
Select(element).choose_by_visible_text("Canada")B)
A) driver.switch_to.frame("frame1") B) driver.switch_to.window("frame1") C) driver.switch_to.alert("frame1") D) driver.switch_to.parent_frame("frame1") Answer: A Explanation: switch_to.frame() accepts name, id, index, or WebElement to focus on a specific iframe. Question 23. Which ActionChains method performs a mouse hover over an element? A) move_to_element() B) hover() C) click_and_hold() D) drag_and_drop() Answer: A Explanation: move_to_element(element).perform() moves the mouse cursor over the target element, simulating a hover. Question 24. What is the default polling interval for Selenium’s WebDriverWait? A) 0.1 seconds B) 0.5 seconds C) 1 second D) 2 seconds Answer: C Explanation: WebDriverWait polls the DOM every 500 milliseconds by default, but the effective interval is 0.5 s; however, the timeout parameter is expressed in seconds, and the internal default poll is 0.5 s. Since the question asks for the
“default polling interval,” the correct answer is 0.5 seconds, which corresponds to option B. Corrected Answer: B Explanation: Selenium’s WebDriverWait checks the condition every 500 ms (0.5 seconds) unless a custom poll frequency is set. Question 25. Which of the following is an example of a Fluent Wait? A) driver.implicitly_wait(10) B) WebDriverWait(driver, 15).until(EC.title_contains("Home")) C) wait = FluentWait(driver).with_timeout(20).polling_every(2).ignore_all([NoSuchElementExc eption]) D) time.sleep(5) Answer: C Explanation: Fluent Wait allows specifying timeout, polling frequency, and ignored exceptions, providing fine-grained control. Question 26. In PyTest, which decorator is used to declare a fixture that runs before each test function? A) @pytest.fixture(scope="module") B) @pytest.fixture(scope="function") C) @pytest.setup D) @pytest.before Answer: B Explanation: The default scope is “function,” but explicitly setting scope="function" indicates the fixture runs for each test.
def user(request): return request.param
D) Both A and C Answer: D Explanation: Both `@pytest.mark.parametrize` and a fixture with `params` achieve data-driven execution. **Question 29.** Which command generates an HTML report using pytest-html? A) `pytest --html=report.html` B) `pytest -report html` C) `pytest --generate-html` D) `pytest -html report.html` Answer: A Explanation: The `--html` option from the `pytest-html` plugin creates the specified HTML file. **Question 30.** In the unittest (PyUnit) framework, which method is automatically called before each test method? A) `setUpClass()` B) `tearDownClass()` C) `setUp()` D) `tearDown()` Answer: C Explanation: `setUp()` runs before every test method, providing test-specific initialization. ## Tester using Python Certification Exam Guide **Question 31.** Which Python module provides a flexible logging system for automation scripts? A) `log` B) `logging` C) `trace` D) `debugger` Answer: B Explanation: The built-in `logging` module supports different log levels, handlers, and formatting. **Question 32.** In Git, what command creates a new branch named `feature/login` and switches to it? A) `git branch feature/login` B) `git checkout -b feature/login` C) `git switch feature/login` D) `git merge feature/login` Answer: B Explanation: `git checkout -b ` creates and checks out the new branch in one step. **Question 33.** Which Jenkins feature allows you to trigger Selenium tests automatically after each code commit? A) Post-build actions B) Build Triggers → Poll SCM C) Build Triggers → GitHub hook trigger for GITScm polling D) All of the above Answer: D ## Tester using Python Certification Exam Guide import csv with open('data.csv', 'r') as f: reader = csv.reader(f)B)
import csv reader = csv.read('data.csv')C)
import pandas as pd df = pd.read_csv('data.csv')D) Both A and C Answer: D Explanation: Both the standard csv reader and pandas read_csv can load CSV data. Question 37. Which Selenium command scrolls the page until a specific element is visible? A) driver.scroll_into_view(element) B) driver.execute_script("arguments[0].scrollIntoView();", element) C) element.scrollTo() D) driver.scrollTo(element) Answer: B
Explanation: Executing JavaScript scrollIntoView() via execute_script brings the element into the viewport. Question 38. What is the primary purpose of the __name__ == "__main__" guard in Python test scripts? A) To define a class name B) To ensure code runs only when the script is executed directly, not when imported C) To declare global variables D) To start a Selenium session automatically Answer: B Explanation: The guard prevents code from running during imports, enabling reusable modules. Question 39. Which of the following is a best practice when handling dynamic element IDs in Selenium? A) Use absolute XPath that includes the dynamic ID B) Use a CSS selector that relies on stable attributes like class or data-test-id C) Hard-code the ID values in the script D) Use Thread.sleep() to wait for the ID to appear Answer: B Explanation: Stable attributes make locators resilient to ID changes; absolute XPaths are brittle. Question 40. Which Selenium method retrieves the current page title? A) driver.getTitle() B) driver.title C) driver.get_page_title()
B) driver.find_element(By.PARTIAL_LINK_TEXT, "Hom") C) driver.find_element(By.ID, "Home") D) Both A and B are valid Answer: C Explanation: By.ID locates by element ID, not link text; the other two are correct link-text strategies. Question 44. In a hybrid automation framework, which component typically manages test data, test execution, and reporting? A) Only the test scripts B) A combination of data-driven and keyword-driven modules with a central driver class C) Only the reporting module D) None of the above Answer: B Explanation: Hybrid frameworks blend multiple patterns (data-driven, keyword-driven) and often include a central driver for orchestration. Question 45. Which Python built-in function can be used to pause execution for a fixed time, though it is discouraged for synchronization? A) time.wait() B) sleep() from time module C) pause() from os module D) delay() from sys module Answer: B Explanation: time.sleep(seconds) halts execution but is not recommended for dynamic waits in Selenium.
Question 46. Which of the following statements about implicitly_wait() is true? A) It applies only to the next find operation B) It sets a global timeout for locating elements throughout the WebDriver session C) It overrides explicit waits D) It replaces the need for any other synchronization technique Answer: B Explanation: implicitly_wait() defines a default polling period for all element searches. Question 47. What does the Select class in Selenium require as an argument? A) A WebElement that represents a tag B) The driver instance C) The index of the option to select D) The visible text of the option Answer: A Explanation: `Select(element)` wraps the WebElement to provide selection methods. Question 48. Which command captures a screenshot of the current browser window and saves it as error.png? A) driver.save_screenshot("error.png") B) driver.take_screenshot("error.png") C) driver.get_screenshot_as_file("error.png") D) Both A and C Answer: D