Intermediate Selenium test (Intermediate)
30 questions · 35 minutes · Free
Page objects, TestNG and JUnit runners, data-driven and cross-browser tests.
Take the Intermediate Selenium test
What it covers
- Page Object Model
- TestNG and JUnit with Selenium
- Data-driven Selenium tests
- Cross-browser testing
- Selenium frames and windows
Interview format
- Questions: 30 questions — 18 multiple choice, 9 multi-answer, 3 predict-the-output
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: Testing & QA
- Price: Free
Earn a certificate
The Intermediate Selenium test is one of the 8 tests of the QA Automation Engineer learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Intermediate Selenium test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
According to the Page Object Model principles described in the study notes, what should the `login` method in the `LoginPage` class do?
- The login method should not use explicit waits
- The login method should return a DashboardPage instance
- The login method should not use the PageFactory
- The login method should be static
Answer: B. The login method should return a DashboardPage instance
In the Page Object Model, methods that navigate between pages should return the next page object to support fluent and readable test flows. The `login` method in the `LoginPage` class should return a `DashboardPage` instance to maintain this pattern, which ensures that tests can chain methods together without directly interacting with locators or the WebDriver.
How can you implement a custom test rule in JUnit to apply pre- and post-test actions in a realistic project scenario?
- Create a custom rule by implementing the TestWatcher interface and overriding the testStarted() and testFinished() methods.
- Implement a custom rule using the @Rule annotation and define a method with the same name as the rule.
- Extend the TestListener interface and override the beforeTest() and afterTest() methods.
- Create a custom rule by extending TestRule and override apply() to define pre- and post-test actions.
Answer: D. Create a custom rule by extending TestRule and override apply() to define pre- and post-test actions.
In JUnit, custom test rules are implemented by extending the TestRule interface and overriding the apply() method to define pre- and post-test actions. This allows developers to encapsulate common setup and teardown logic, such as logging or resource management, and apply it to multiple tests. Other options are incorrect because they do not align with JUnit's rule implementation mechanism.
What does the getWindowHandles() method in Selenium return?
- getWindowHandles() returns a Set<String> containing all open window handles
- getWindowHandles() returns a single String representing the current window handle
- getWindowHandles() returns a Map<String, String> containing window handles and their titles
- getWindowHandles() returns a List<String> containing all open window handles
Answer: A. getWindowHandles() returns a Set<String> containing all open window handles
In Selenium, when you call getWindowHandles(), it returns a Set<String> that contains all the window handles currently open in the browser session. This allows you to iterate through all open windows and switch between them using the handle. The other options are incorrect because they do not accurately describe the behavior of getWindowHandles() in Selenium.
What is the correct method to manage multiple browser windows in Selenium when a new window is opened?
- Use switchTo().window() without any parameters to automatically switch to the new window.
- Use getWindowHandles() to get all window handles and switch to the desired window using switchTo().window(handle).
- Use getHandles() to retrieve all window handles and directly switch to the new window using switchTo().window().
- Use getWindowHandle() to get the handle of the current window and switch to another window using switchTo().window(handle).
Answer: B. Use getWindowHandles() to get all window handles and switch to the desired window using switchTo().window(handle).
When managing multiple browser windows in Selenium, it is essential to use getWindowHandles() to retrieve all window handles and then switch to the desired window by passing the specific handle to switchTo().window(handle). This ensures the correct window is active for further interactions. Other options may lead to errors or incorrect handling of windows.
Which of the following annotations is used in JUnit 5 to exclude a test from execution?
- The @Exclude annotation is used to exclude a test from execution.
- The @Disabled annotation is used to exclude a test from execution.
- The @Ignore annotation is used to exclude a test from execution.
- The @NotRun annotation is used to exclude a test from execution.
Answer: B. The @Disabled annotation is used to exclude a test from execution.
In JUnit 5, the @Disabled annotation is used to exclude a test method or class from being executed. This is a common way to temporarily disable tests that are not ready, failing, or not applicable. Other options are not valid for test exclusion in JUnit.
Frequently asked questions
- How many questions are in the Intermediate Selenium test?
- 30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
- What does the Intermediate Selenium test cover?
- Page Object Model, TestNG and JUnit with Selenium, Data-driven Selenium tests, Cross-browser testing, Selenium frames and windows.
- Is the Intermediate Selenium test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Intermediate Selenium test?
- Intermediate, in Testing & QA.