
















































































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 phase of the Software Testing Life Cycle (STLC) is responsible for preparing the test environment and test data? A) Test Planning B) Test Design C) Test Execution D) Test Environment Setup Answer: D Explanation: Test Environment Setup involves configuring hardware, software, and test data required for test execution. Question 2. In the context of automation, which scenario is least suitable for using Selenium WebDriver? A) Verifying UI layout across browsers B) Testing API response payloads C) Automating regression test suites for web applications D) Performing cross‑browser functional testing Answer: B Explanation: Selenium interacts with browsers and cannot directly test APIs; tools like RestAssured are preferred for API testing. Question 3. What is the primary role of a Software Development Engineer in Test (SDET)? A) Writing manual test cases only B) Designing test frameworks and writing automated code C) Managing project budgets D) Conducting performance testing exclusively Answer: B
Explanation: SDETs blend development skills with testing expertise to create robust automation frameworks. Question 4. Which Selenium component was deprecated after Selenium 3 and removed in Selenium 4? A) Selenium IDE B) Selenium RC C) Selenium Grid D) Selenium WebDriver Answer: B Explanation: Selenium Remote Control (RC) was replaced by WebDriver and is no longer maintained after Selenium 3. Question 5. The W3C WebDriver protocol became the default in Selenium 4. What advantage does this bring? A) Faster execution because it removes JSON parsing B) Better cross‑browser compatibility and standardization C) Enables testing of mobile apps without Appium D) Allows execution without browser drivers Answer: B Explanation: W3C compliance standardizes commands across browsers, reducing vendor‑specific quirks. Question 6. Which Maven dependency is required to use Selenium WebDriver in a Java project? A) org.testng:testng B) org.seleniumhq.selenium:selenium-java
B) .btn, .primary C) btn.primary D) .btn-primary Answer: A Explanation: A dot before each class without a space selects elements containing both classes. Question 10. When dealing with dynamic IDs that change on each page load, which locator strategy is most robust? A) By.id() B) By.name() C) By.xpath() using contains() on a stable attribute D) By.className() Answer: C Explanation: Using XPath with contains() on a stable part of an attribute avoids reliance on volatile IDs. Question 11. What does the WebDriver method driver.quit() do? A) Closes the current browser tab only B) Terminates the WebDriver session and closes all associated windows C) Clears all cookies but keeps the browser open D) Refreshes the current page Answer: B Explanation: quit() ends the session and shuts down every browser instance started by the driver. Question 12. Which WebElement method returns the value of the “placeholder” attribute?
A) getText() B) getAttribute("placeholder") C) getCssValue("placeholder") D) getTagName() Answer: B Explanation: getAttribute() fetches any HTML attribute value, including custom ones like placeholder. Question 13. The Selenium Select class is used for which type of HTML element? A) <input type="text"> B) <select> dropdowns C) <button> elements D) <iframe> elements Answer: B Explanation: Select provides methods to interact with <select> and its <option> children. Question 14. Which of the following is true about Implicit Waits? A) They are applied to a specific element only B) They override Explicit Waits C) They are set once and apply globally for the driver instance D) They pause execution for a fixed time regardless of element state Answer: C Explanation: Implicit Wait sets a global timeout for element searches throughout the driver’s lifetime.
Explanation: ignoring() configures the Fluent Wait to suppress specified exceptions during polling. Question 18. Which Actions class method performs a right‑click on a given WebElement? A) doubleClick() B) contextClick() C) clickAndHold() D) moveToElement() Answer: B Explanation: contextClick() triggers the browser’s context (right‑click) menu on the element. Question 19. How can you switch Selenium’s focus to an iframe identified by its index 2? A) driver.switchTo().frame("2") B) driver.switchTo().frame(2) C) driver.switchTo().frameByIndex(2) D) driver.switchTo().frame("//iframe[2]") Answer: B Explanation: frame(int index) switches to the iframe based on its zero‑based index. Question 20. Which WebDriver method returns a set of window handles for all open browser windows? A) getWindowHandles() B) getWindowHandle() C) getAllWindows() D) getCurrentWindow() Answer: A
Explanation: getWindowHandles() provides a Set of unique identifiers for each open window. Question 21. To accept a JavaScript alert, which Selenium command should be used? A) alert.dismiss() B) alert.getText() C) alert.accept() D) alert.sendKeys() Answer: C Explanation: accept() clicks the “OK” button on the alert. Question 22. Which JavaScript snippet executed via JavascriptExecutor scrolls the page down by 300 pixels? A) window.scrollBy(0,300); B) document.scrollTop = 300; C) window.scrollTo(0,300); D) document.body.scrollIntoView(); Answer: A Explanation: window.scrollBy(x,y) scrolls relative to the current position; here it moves down 300 pixels. Question 23. When uploading a file using Selenium, which HTML attribute is typically interacted with? A) src B) href C) value of <input type="file"> D) action of <form>
D) There is no difference; they are synonyms Answer: B Explanation: Hard asserts abort the test on failure, while soft asserts collect failures and allow the test to proceed. Question 27. Which annotation in TestNG is used to provide data to a test method? A) @Parameters B) @Factory C) @DataProvider D) @BeforeDataProvider Answer: C Explanation: @DataProvider supplies a matrix of data sets to a test method. Question 28. In the Page Object Model (POM), where should the logic for locating elements reside? A) Test classes B) Utility classes C) Page classes as private WebElements D) Configuration files Answer: C Explanation: POM encapsulates element locators inside page classes, keeping tests clean. Question 29. Which Selenium annotation is used with Page Factory to initialize elements? A) @FindAll B) @FindBy C) @CacheLookup
D) @InitElements Answer: B Explanation: @FindBy defines how Page Factory should locate a WebElement. **Question 30. The Fluent Interface design pattern in automation frameworks mainly enables: ** A) Parallel test execution B) Method chaining for readable test steps C) Automatic screenshot capture D) Integration with CI tools Answer: B Explanation: Fluent interfaces return the object itself, allowing chained method calls. Question 31. Which type of test automation framework combines data‑driven and keyword‑driven approaches? A) Linear framework B) Hybrid framework C) Modular framework D) Scriptless framework Answer: B Explanation: Hybrid frameworks leverage both data and keyword concepts for flexibility. Question 32. In BDD with Cucumber, which file contains the step definitions? A) *.feature file B) pom.xml C) *.java file annotated with @Given/@When/@Then
C) Hybrid app D) Progressive Web App (PWA) Answer: C Explanation: Hybrid apps combine native wrappers with embedded web views. Question 36. Which Appium driver is used to automate iOS applications? A) AndroidDriver B) IOSDriver C) MobileDriver D) WindowsDriver Answer: B Explanation: IOSDriver implements the WebDriver protocol for iOS devices. Question 37. In Appium Desired Capabilities, which key specifies the automation engine for Android? A) platformName B) deviceName C) automationName D) appPackage Answer: C Explanation: automationName can be set to “UiAutomator2”, “Espresso”, etc., defining the engine. Question 38. Which tool can inspect UI elements of an Android application for Appium automation? A) Xcode Instruments
B) Appium Desktop Inspector C) Selenium IDE D) Postman Answer: B Explanation: Appium Desktop provides a UI hierarchy viewer for Android and iOS. Question 39. Which locator strategy is recommended for iOS native apps in Appium? A) XPath B) Accessibility ID C) Class name D) UIAutomator Answer: B Explanation: Accessibility ID maps to the accessibilityIdentifier property, offering stability. Question 40. To switch context from native to a web view in a hybrid app, which Appium command is used? A) driver.context("WEBVIEW") B) driver.switchTo().frame() C) driver.setContext("WEBVIEW") D) driver.switchContext("WEBVIEW") Answer: D Explanation: switchContext() changes the driver’s context between NATIVE_APP and WEBVIEW. Question 41. Which TouchAction method performs a long press for 2 seconds on an element?
Question 44. What is the main benefit of running Selenium tests on a Selenium Grid? A) Reduces test code size B) Enables parallel execution across multiple browsers and machines C) Provides built‑in reporting D) Eliminates the need for WebDriver binaries Answer: B Explanation: Grid distributes tests to different nodes, allowing concurrent cross‑browser runs. Question 45. In Selenium Grid 4, which component is responsible for routing incoming WebDriver sessions to appropriate nodes? A) Hub B) Router C) Distributor D) Session Map Answer: B Explanation: The Router receives session requests and forwards them to the Distributor. Question 46. Which cloud service allows Selenium tests to run on a wide range of browsers without local infrastructure? A) Jenkins B) Sauce Labs C) Maven D) GitHub Answer: B Explanation: Sauce Labs provides SaaS browsers for remote execution.
Question 47. When integrating Selenium tests with Jenkins, which plugin is commonly used to publish HTML reports? A) JUnit Plugin B) HTML Publisher Plugin C) Maven Integration Plugin D) Git Plugin Answer: B Explanation: HTML Publisher publishes custom HTML result files generated by test frameworks. Question 48. Which CI tool uses a Jenkinsfile to define pipeline stages as code? A) Travis CI B) CircleCI C) GitHub Actions D) Jenkins (Declarative Pipeline) Answer: D Explanation: A Jenkinsfile contains a declarative or scripted pipeline for Jenkins. Question 49. Which exception is thrown when Selenium cannot locate an element using the given locator within the timeout? A) StaleElementReferenceException B) NoSuchElementException C) TimeoutException D) ElementNotInteractableException Answer: C
Explanation: addScreenCaptureFromPath() links an image file to the report entry. Question 53. Which Allure annotation marks a method as a test step for better reporting? A) @Step B) @Attachment C) @Feature D) @Story Answer: A Explanation: @Step annotates methods whose execution will appear as distinct steps in Allure. Question 54. What is the primary purpose of a “flaky test” metric? A) To measure code coverage B) To identify tests that pass/fail intermittently C) To calculate execution time D) To count the number of assertions per test Answer: B Explanation: Flaky tests are unstable and need investigation to improve reliability. Question 55. Which Selenium command captures a screenshot of the current browser window? A) driver.takeScreenshot() B) ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE) C) driver.captureScreen() D) driver.saveScreenshot() Answer: B
Explanation: Casting to TakesScreenshot and calling getScreenshotAs returns the image. Question 56. In Maven, which phase is responsible for compiling Java source files? A) test B) compile C) package D) install Answer: B Explanation: The compile phase translates source code into bytecode. Question 57. Which TestNG XML tag defines the order in which test classes are executed? A) <class> elements under <classes> determines execution order. Question 58. What is the function of the @BeforeSuite annotation in TestNG? A) Runs before each test method B) Runs once before all tests in the suite start C) Runs after the suite finishes D) Runs before each test class Answer: B Explanation: @BeforeSuite is executed a single time prior to any test in the suite.