























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































































Question 1. Which of the following best describes the primary purpose of the Automation Pyramid in test automation strategy? A) To prioritize unit tests over UI tests B) To replace all manual testing activities C) To ensure equal distribution of test types D) To focus exclusively on performance testing Answer: A Explanation: The Automation Pyramid recommends a larger base of fast, low-level unit tests, a middle layer of integration/API tests, and a thin top layer of UI tests, thereby prioritizing unit tests for efficiency. Question 2. In the Test Automation Life Cycle (TALC), which phase directly follows “Tool selection and environment setup”? A) Requirement analysis for automation B) Design and development of test scripts C) Execution and maintenance of the test suite D) Reporting and defect logging Answer: B Explanation: After selecting tools and configuring the environment, the next logical step is to design and develop the automated test scripts. Question 3. Which framework type separates test logic from UI locators by using classes that represent pages? A) Linear framework B) Data-Driven framework C) Keyword-Driven framework D) Page Object Model (POM)
Answer: D Explanation: POM encapsulates page elements and actions in page classes, decoupling test logic from locators. Question 4. When using php-webdriver, which command creates a new remote session for Chrome? A) RemoteWebDriver::create('http://localhost:4444/wd/hub', DesiredCapabilities::chrome()); B) ChromeDriver::start(); C) WebDriver::newSession('chrome'); D) SeleniumServer::launchChrome(); Answer: A Explanation: RemoteWebDriver::create with DesiredCapabilities::chrome() initiates a Chrome session via Selenium Grid or Standalone server. Question 5. Which Composer command adds the php-webdriver library to a project? A) composer require php-webdriver/webdriver B) composer install php-webdriver/webdriver C) composer update php-webdriver/webdriver D) composer get php-webdriver/webdriver Answer: A Explanation: composer require installs a package and updates composer.json; the correct package name is php-webdriver/webdriver. Question 6. In Selenium Server terminology, what role does a “Node” play? A) Stores test reports
Question 9. Which XPath function would you use to locate an element whose class attribute contains the word “active”? A) starts-with(@class, 'active') B) contains(@class, 'active') C) ends-with(@class, 'active') D) matches(@class, 'active') Answer: B Explanation: contains() checks for a substring within the attribute value, suitable for partial class matches. Question 10. In php-webdriver, how do you retrieve the text of a WebElement stored in $element? A) $element->getText(); B) $element->text(); C) $element->value(); D) $element->innerHTML(); Answer: A Explanation: getText() returns the visible text of the element. Question 11. Which command selects the option with visible text “Canada” from a `` element using php-webdriver? A) $select->selectByVisibleText('Canada'); B) $select->choose('Canada'); C) $select->clickOption('Canada'); D) $select->setValue('Canada'); Answer: A
Explanation: selectByVisibleText() is the standard method to choose an option by its displayed text. Question 12. To handle a JavaScript alert that appears after clicking a button, which sequence is correct? A) $driver->switchTo()->alert()->accept(); B) $driver->alert()->accept(); C) $driver->switchToAlert()->accept(); D) $driver->handleAlert()->accept(); Answer: A Explanation: The proper chain is switchTo()->alert()->accept() to focus on the alert and accept it. Question 13. What is the effect of setting an implicit wait of 10 seconds in php-webdriver? A) Each element lookup will poll for up to 10 seconds before throwing NoSuchElementException B) The test will pause for exactly 10 seconds before every command C) The browser will wait 10 seconds after page load D) It disables all explicit waits Answer: A Explanation: Implicit wait tells the driver to keep trying to locate elements for the specified timeout before failing. Question 14. Which ExpectedCondition is used to wait until an element is clickable? A) elementToBeClickable(By::id('submit'))
Question 17. Which PHPUnit lifecycle hook is executed before each test method? A) setUpBeforeClass() B) tearDown() C) setUp() D) onNotSuccessfulTest() Answer: C Explanation: setUp() runs before every test method, allowing initialization of objects such as WebDriver. Question 18. Which assertion would you use to verify that a checkbox element $chk is selected? A) $this->assertTrue($chk->isSelected()); B) $this->assertEquals(true, $chk->isEnabled()); C) $this->assertContains('checked', $chk->getAttribute('class')); D) $this->assertNotNull($chk->getValue()); Answer: A Explanation: isSelected() returns a boolean indicating the checked state; assertTrue validates it. Question 19. In a data-driven test using PHPUnit, how many times will the test method run if the data provider returns three data sets? A) Once B) Two times C) Three times
D) Four times Answer: C Explanation: PHPUnit executes the test once per data set supplied by the provider. Question 20. Which design pattern is most closely associated with the “Keyword-Driven” framework? A) Factory B) Strategy C) Command D) Observer Answer: C Explanation: Keyword-Driven frameworks map test steps (keywords) to command objects that execute actions, reflecting the Command pattern. Question 21. When configuring ChromeDriver for headless execution, which argument must be added? A) --disable-gpu B) --headless C) --no-sandbox D) --incognito Answer: B Explanation: The --headless flag runs Chrome without a UI, suitable for CI environments. Question 22. What is the primary benefit of using Selenium Grid in test automation?
Explanation: DoD in Scrum often mandates that automated regression tests are part of the increment’s delivery. Question 25. Which PHPUnit annotation ensures that a test method runs after a dependent test has succeeded? A) @depends B) @after C) @required D) @priority Answer: A Explanation: @depends makes the test depend on the successful execution of another test method. Question 26. Which of the following statements about implicit and explicit waits is TRUE? A) Implicit waits can be set per element, while explicit waits are global. B) Implicit waits are ignored when an explicit wait is used for the same element. C) Implicit waits are generally discouraged because they can cause unpredictable timing. D) Explicit waits cannot be combined with ExpectedConditions. Answer: C Explanation: Implicit waits affect all element lookups and may lead to hidden delays; explicit waits give finer control. Question 27. How can you capture a screenshot of the current browser window using php-webdriver? A) $driver->takeScreenshot('/path/to/file.png');
B) $driver->captureScreen('/path/to/file.png'); C) $driver->saveScreenshot('/path/to/file.png'); D) $driver->getScreenshotAsFile('/path/to/file.png'); Answer: A Explanation: takeScreenshot() is the method provided by php-webdriver to save a PNG image of the viewport. Question 28. Which PHP interface must a custom PHPUnit assertion class implement to be usable as a constraint? A) PHPUnit\Framework\Constraint\Constraint B) PHPUnit\Framework\Assertable C) PHPUnit\Framework\Constraint\ConstraintInterface D) PHPUnit\Framework\CustomAssertion Answer: C Explanation: Custom constraints implement ConstraintInterface, allowing them to be used with assertThat. Question 29. In a hybrid framework, which component typically handles test data externalization? A) Test scripts B) Configuration files (e.g., XML/JSON) C) Page objects D) Browser drivers Answer: B Explanation: Hybrid frameworks combine modular code with external data sources like XML, JSON, or Excel for test data.
Answer: A Explanation: dragAndDrop() directly handles the source and target elements, followed by perform(). Question 33. Which of the following PHP extensions is required for Selenium WebDriver to interact with the Chrome DevTools Protocol? A) curl B) mbstring C) sockets D) none; php-webdriver communicates via HTTP JSON Answer: D Explanation: php-webdriver uses HTTP JSON to talk to ChromeDriver; no special extension is needed for DevTools. Question 34. In a Continuous Integration pipeline, which Jenkins plugin is most commonly used to publish PHPUnit XML reports? A) HTML Publisher Plugin B) JUnit Plugin C) PHPUnit Reporter Plugin D) TestNG Results Plugin Answer: B Explanation: The JUnit Plugin can parse generic JUnit-style XML, which PHPUnit generates. Question 35. Which command line option enables headless mode for GeckoDriver (Firefox) in php-webdriver? A) --headless
B) -headless C) --disable-gui D) -no-gui Answer: A Explanation: Firefox accepts the --headless flag to run without a visible UI. Question 36. If a test needs to run on multiple browsers using the same script, which design approach is recommended? A) Hard-code the browser name inside the test B) Use a configuration file to specify DesiredCapabilities per execution C) Write separate test classes for each browser D) Duplicate the test suite for each browser type Answer: B Explanation: Externalizing browser configuration allows the same script to be reused across environments. Question 37. Which of the following best defines “flaky test” in Selenium automation? A) A test that fails intermittently due to timing or environment issues B) A test that always passes regardless of application state C) A test that never reaches the assertion stage D) A test that contains syntax errors Answer: A Explanation: Flaky tests exhibit non-deterministic outcomes, often caused by synchronization problems.
Answer: B Explanation: POM encapsulates locators within page classes, keeping them private to the page object. Question 41. Which of the following statements about Selenium’s JSON Wire Protocol is FALSE? A) It is the underlying communication format for Selenium 3 and earlier B) It has been replaced by the W3C WebDriver protocol in Selenium 4 C) It uses HTTP requests with JSON payloads D) It supports parallel execution across multiple browsers natively Answer: D Explanation: Parallel execution is a feature of Selenium Grid, not inherent to the JSON Wire Protocol. Question 42. To verify that a web element is no longer present in the DOM, which ExpectedCondition would you use? A) invisibilityOfElementLocated(By::id('loader')) B) presenceOfElementLocated(By::id('loader')) C) stalenessOf($element) D) elementToBeClickable(By::id('loader')) Answer: C Explanation: stalenessOf returns true when the element reference is no longer attached to the DOM. Question 43. Which of the following is the most appropriate way to pass a username and password to a Selenium test running on a remote Selenium Grid? A) Encode them in the URL query string
B) Use DesiredCapabilities with “username” and “password” keys C) Set them as environment variables on the node D) Include them in the test script’s configuration file Answer: B Explanation: DesiredCapabilities can carry custom metadata such as credentials for remote services. Question 44. In php-webdriver, how do you close only the current browser window while keeping the WebDriver session alive? A) $driver->close(); B) $driver->quit(); C) $driver->window()->close(); D) $driver->navigate()->close(); Answer: A Explanation: close() shuts the active window; quit() ends the entire session. Question 45. Which PHPUnit method would you use to assert that an array contains a specific key? A) $this->assertArrayHasKey('email', $data); B) $this->assertContains('email', $data); C) $this->assertTrue(in_array('email', array_keys($data))); D) $this->assertEquals(true, isset($data['email'])); Answer: A Explanation: assertArrayHasKey directly checks for the presence of a key in an array.
Explanation: Headless browsers consume less CPU/memory and do not require a graphical environment, ideal for CI agents. Question 49. Which of the following Composer scripts would you add to run PHPUnit tests with the command composer test? A) "scripts": { "test": "phpunit" } B) "scripts": { "test": "./vendor/bin/phpunit" } C) "scripts": { "test": "php vendor/bin/phpunit" } D) All of the above are acceptable Answer: D Explanation: All listed script definitions correctly invoke PHPUnit through Composer. Question 50. What does the @depends annotation do when the dependent test fails? A) Skips the dependent test and marks it as risky B) Still runs the dependent test but ignores the failure C) Marks the dependent test as passed automatically D) Causes the entire test suite to abort Answer: A Explanation: If a depended-on test fails, PHPUnit marks the dependent test as skipped. Question 51. Which method retrieves the page source of the current window in php-webdriver? A) $driver->getPageSource(); B) $driver->source();
C) $driver->getSource(); D) $driver->page()->source(); Answer: A Explanation: getPageSource() returns the HTML source of the active page. Question 52. When using Selenium Grid, what is the role of the Hub? A) Executes test scripts directly on browsers B) Manages node registration and routes test requests to appropriate nodes C) Generates test reports for all nodes D) Provides a UI for editing test cases Answer: B Explanation: The Hub acts as a central point that receives test requests and distributes them to registered nodes. Question 53. Which of the following best describes a “Keyword-Driven” test case? A) A test case defined entirely in code without external data B) A test case where each step is represented by a keyword that maps to a reusable function C) A test case that runs only on a specific browser D) A test case that uses only CSS selectors for locating elements Answer: B Explanation: Keyword-Driven testing uses high-level action words (keywords) linked to underlying code modules.