






















































































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 certification exam preparation focuses on Selenium-based test automation using Java, including test design patterns, framework development, CI/CD integration, and result analysis. The guide emphasizes practical automation skills and exam-aligned exercises.
Typology: Exams
1 / 94
This page cannot be seen from the preview
Don't miss anything!























































































**Question 1. Which of the following is the primary reason to automate a test case? ** A) The test case is executed only once. B) The test case is highly repetitive and data-intensive. C) The test case validates UI aesthetics. D) The test case requires human judgment. Answer: B Explanation: Automation provides the greatest ROI for tests that are run many times with large data sets, reducing manual effort and error. Question 2. In the Test Automation Life Cycle, which phase comes immediately after selecting the automation tool? A) Test script execution B) Test plan design C) Test environment setup D) Test result analysis Answer: B Explanation: After tool selection, a detailed test plan (scope, objectives, resources) is created before any scripts are written. Question 3. Which framework combines the advantages of Keyword-Driven and Data-Driven approaches? A) Linear framework B) Hybrid framework C) Modular framework D) BDD framework
Answer: B Explanation: A hybrid framework integrates multiple design patterns, often merging keyword and data-driven techniques. Question 4. Which environment variable points to the folder containing the Java compiler (javac)? A) PATH B) CLASSPATH C) JAVA_HOME D) JDK_HOME Answer: C Explanation: JAVA_HOME should be set to the JDK installation directory; PATH includes the bin folder for command-line access. Question 5. Which of the following is a reference type in Java? A) int B) double C) boolean D) String Answer: D Explanation: String is a class (reference type), while the others are primitive data types. **Question 6. What will be the output of the following code?
int a = 5; ## Tester using Java Certification Exam ## Preparation D) Abstraction Answer: C Explanation: Polymorphism enables method overloading (compile-time) and overriding (run-time) with the same name. **Question 9. Which of the following statements about abstract classes is true?** A) An abstract class can be instantiated directly. B) All methods in an abstract class must be abstract. C) An abstract class can contain both abstract and concrete methods. D) Abstract classes cannot have constructors. Answer: C Explanation: Abstract classes may define abstract methods and also provide concrete implementations. **Question 10. Which access modifier provides the highest level of data hiding?** A) public B) protected C) default (package-private) D) private Answer: D Explanation: `private` restricts access to within the declaring class only. **Question 11. Which collection allows duplicate elements and maintains insertion order?** A) HashSet ## Tester using Java Certification Exam ## Preparation B) TreeSet C) ArrayList D) LinkedHashMap Answer: C Explanation: `ArrayList` permits duplicates and preserves the order elements are added. **Question 12. What is the time complexity of `HashMap.get(key)` in the average case?** A) O(1) B) O(log n) C) O(n) D) O(n log n) Answer: A Explanation: HashMap provides constant-time retrieval on average due to hashing. **Question 13. Which exception is thrown when Selenium cannot locate an element using the provided locator?** A) TimeoutException B) NoSuchElementException C) StaleElementReferenceException D) ElementNotVisibleException Answer: B Explanation: `NoSuchElementException` indicates the element was not found in the DOM at the time of the call. ## Tester using Java Certification Exam ## Preparation Explanation: `ChromeDriver` is the WebDriver implementation for Google Chrome. **Question 17. What does the `driver.getTitle()` method return?** A) The URL of the current page B) The source code of the page C) The title text of the current page D) The number of open windows Answer: C Explanation: `getTitle()` fetches the `` element content of the loaded page. **Question 18. Which Selenium command navigates the browser back to the previous page?** A) driver.forward(); B) driver.back(); C) driver.refresh(); D) driver.navigate().to(); Answer: B Explanation: `driver.back()` simulates the browser’s back button. **Question 19. Which locator strategy is generally the fastest and most reliable?** A) XPath B) CSS Selector C) id D) linkText Answer: C ## Tester using Java Certification Exam ## Preparation Explanation: Locating by `id` uses the browser’s native DOM lookup, making it the quickest. **Question 20. Which XPath expression selects an element whose `class` attribute contains the word `active`?** A) //\*[@class='active'] B) //\*[@class='*active*'] C) //\*[contains(@class,'active')] D) //\*[starts-with(@class,'active')] Answer: C Explanation: `contains()` checks for a substring within the attribute value. **Question 21. Which CSS selector correctly selects an element with both `class="btn"` and `type="submit"`?** A) btn[type='submit'] B) .btn[type='submit'] C) #btn[type='submit'] D) [class='btn'][type='submit'] Answer: B Explanation: `.btn` selects by class, and `[type='submit']` adds the attribute filter. **Question 22. What is the difference between `findElement` and `findElements`?** A) `findElement` returns a list, `findElements` returns a single element. B) `findElement` throws an exception if no match, `findElements` returns an empty list. C) Both return the first matching element. ## Tester using Java Certification Exam ## Preparation B) ListBox C) Options D) Select Answer: D Explanation: Selenium’s `Select` class provides methods like `isMultiple()` and `deselectAll()` for multi-select dropdowns. **Question 26. To retrieve the text from the third cell of the second row in an HTML table, which XPath would you use?** A) //table/tr[2]/td[3] B) //table//tr[2]/td[3] C) //table//tr[3]/td[2] D) //table/row[2]/cell[3] Answer: B Explanation: `//table//tr[2]/td[3]` navigates to the second `` (row) and third `` (cell). **Question 27. Which Selenium wait sets a timeout for locating all elements globally?** A) Implicit Wait B) Explicit Wait C) Fluent Wait D) Thread.sleep() Answer: A Explanation: Implicit wait applies to every element search, causing WebDriver to poll the DOM for the defined time. ## Tester using Java Certification Exam ## Preparation **Question 28. Which ExpectedCondition checks that an element is clickable?** A) visibilityOfElementLocated B) elementToBeClickable C) presenceOfElementLocated D) textToBePresentInElementLocated Answer: B Explanation: `elementToBeClickable` ensures the element is both visible and enabled. **Question 29. In a FluentWait, which method allows you to ignore specific exceptions during polling?** A) withTimeout() B) pollingEvery() C) ignoring() D) until() Answer: C Explanation: `ignoring(Class)` tells FluentWait to suppress listed exceptions while waiting. **Question 30. Why is `Thread.sleep()` discouraged in professional Selenium test suites?** A) It throws a checked exception. B) It pauses the entire JVM, slowing down execution and causing flaky tests. C) It only works on Windows OS. D) It cannot be used with TestNG. ## Tester using Java Certification Exam ## Preparation B) driver.getWindowHandles(); C) driver.getAllWindowHandles(); D) driver.getHandles(); Answer: B Explanation: `getWindowHandles()` provides a Set containing each window’s unique identifier. **Question 34. Which Actions class method performs a right-click on a target element?** A) doubleClick() B) contextClick() C) clickAndHold() D) moveToElement() Answer: B Explanation: `contextClick()` triggers the browser’s context (right-click) menu on the specified element. **Question 35. How can you scroll an element into view using JavaScriptExecutor?** A) ((JavascriptExecutor)driver).executeScript("window.scrollBy(0,200)"); B) ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView(true);", element); C) ((JavascriptExecutor)driver).executeScript("document.scrollTop=element.offsetTop" ); D) ((JavascriptExecutor)driver).executeScript("scrollTo(element)"); Answer: B ## Tester using Java Certification Exam ## Preparation Explanation: `scrollIntoView(true)` brings the element into the visible part of the browser window. **Question 36. Which class is used to simulate keyboard events at the OS level, such as handling native file upload dialogs?** A) Actions B) Robot C) Keyboard D) InputSimulator Answer: B Explanation: `java.awt.Robot` can generate native system input events, enabling interaction with OS dialogs. **Question 37. In TestNG, which annotation is executed **once before** any test methods in the suite?** A) @BeforeMethod B) @BeforeClass C) @BeforeTest D) @BeforeSuite Answer: D Explanation: `@BeforeSuite` runs a single time before the entire TestNG suite starts. **Question 38. Which TestNG assertion will continue test execution even if the condition fails?** A) Assert.assertTrue() B) Assert.assertEquals() ## Tester using Java Certification Exam ## Preparation **Question 41. Which TestNG listener interface can be used to generate a custom report after suite execution?** A) ITestListener B) ISuiteListener C) IInvokedMethodListener D) IAnnotationTransformer Answer: B Explanation: `ISuiteListener` provides callbacks `onStart` and `onFinish` for the entire suite, useful for custom reporting. **Question 42. In the Page Object Model, where should the WebElement definitions reside?** A) In the test class B) In a separate utility class C) Inside page classes representing each page D) In the TestNG XML file Answer: C Explanation: POM encapsulates page-specific locators and actions inside dedicated page classes. **Question 43. Which annotation is used with Selenium’s PageFactory to locate elements?** A) @FindAll B) @FindBy C) @CacheLookup D) @ElementLocator ## Tester using Java Certification Exam ## Preparation Answer: B Explanation: `@FindBy` specifies the locator strategy for a WebElement field. **Question 44. How does the `@CacheLookup` annotation affect a PageFactory element?** A) It refreshes the element on every call. B) It caches the element after the first lookup, improving performance. C) It disables lazy initialization. D) It forces a new driver instance. Answer: B Explanation: `@CacheLookup` stores the element reference after first discovery, reducing repeated DOM searches. **Question 45. Which Apache POI class is used to read data from an Excel `.xlsx` file?** A) HSSFWorkbook B) XSSFWorkbook C) WorkbookFactory D) ExcelReader Answer: B Explanation: `XSSFWorkbook` handles the Office Open XML format (`.xlsx`). `HSSFWorkbook` is for older `.xls`. **Question 46. In Log4j, which logging level has the highest severity?** A) DEBUG B) INFO ## Tester using Java Certification Exam ## Preparation **Question 49. Which Maven command cleans the target directory and then compiles the project?** A) mvn compile clean B) mvn clean compile C) mvn clean && mvn compile D) mvn package clean Answer: B Explanation: `mvn clean compile` first removes `target/` (clean) then compiles the source code. **Question 50. Which Git command records changes to the local repository without sending them to the remote?** A) git push B) git commit C) git pull D) git fetch Answer: B Explanation: `git commit` creates a new commit in the local repository; `push` transfers it to the remote. **Question 51. In Jenkins, which plugin provides native support for executing TestNG test suites?** A) Maven Integration Plugin B) TestNG Results Plugin C) JUnit Plugin D) Pipeline Plugin ## Tester using Java Certification Exam ## Preparation Answer: B Explanation: The TestNG Results Plugin parses TestNG XML reports and displays them in Jenkins. **Question 52. Which of the following statements about Selenium’s `driver.manage().timeouts().pageLoadTimeout()` is true?** A) It sets the timeout for locating elements. B) It defines the maximum time to wait for a page to load completely. C) It replaces the need for explicit waits. D) It only works with ChromeDriver. Answer: B Explanation: `pageLoadTimeout` controls how long WebDriver waits for the entire page load before throwing an exception. **Question 53. Which of these is NOT a valid way to instantiate a WebDriver for Chrome using WebDriverManager?** A) WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); B) WebDriverManager.getInstance(ChromeDriver.class).setup(); WebDriver driver = new ChromeDriver(); C) WebDriverManager.chromedriver().setup(); WebDriver driver = new FirefoxDriver(); D) WebDriverManager.chromedriver().setup(); ChromeOptions opt = new ChromeOptions(); WebDriver driver = new ChromeDriver(opt); Answer: C Explanation: Option C sets up ChromeDriver but creates a `FirefoxDriver`, which is inconsistent.