Unit 4: Selenium Validation and Grid - Practice Quiz
1 What is the primary purpose of Maven in a Selenium testing project?
2 Which file is primarily used to configure a Maven project?
3
In which section of pom.xml are Selenium and TestNG libraries normally declared?
<dependencies>
<properties>
<repositories>
<developers>
4 What is TestNG mainly used for in a Selenium project?
5 Where can a tester find official details about TestNG classes and methods?
6 Which file is commonly used to define TestNG suites and test groups?
7 Which TestNG annotation identifies a method as a test method?
@DataProvider
@BeforeTest
@Test
@AfterMethod
8 Which TestNG annotation runs a method before each test method?
@AfterMethod
@BeforeMethod
@BeforeSuite
@AfterClass
9
Which type of TestNG assertion allows execution to continue after an assertion failure until assertAll() is called?
10 What should a basic Selenium test case normally contain?
11 Which TestNG method checks whether an actual value equals an expected value?
Assert.fail()
Assert.assertFalse()
Assert.assertEquals()
Assert.assertNull()
12 Which TestNG assertion verifies that a condition is true?
Assert.assertEquals()
Assert.assertNull()
Assert.assertNotSame()
Assert.assertTrue()
13 What is the main purpose of Selenium Grid?
14 In Selenium Grid, which component receives new WebDriver session requests?
15 Which Selenium Grid component runs browser sessions?
16 Which command starts Selenium Grid in standalone mode using a Selenium Server JAR?
java -jar selenium-server.jar standalone
java -jar selenium-server.jar compile
mvn selenium-server.jar standalone
testng selenium-server.jar execute
17 Which Selenium class is commonly used to connect a test script to a remote Grid?
Select
RemoteWebDriver
By
WebElement
18 What must a Selenium test do after completing browser actions to close the entire WebDriver session?
driver.get()
driver.quit()
driver.findElement()
driver.navigate()
19 What does cross-browser testing verify?
20 Which Selenium Grid endpoint is commonly used to check the Grid's current status?
/execute
/report
/browser
/status
21 A team wants every developer and CI server to use the same Selenium and TestNG library versions. Which Maven feature most directly supports this requirement?
pom.xml
testng.xml
22
A Maven project stores TestNG tests under src/test/java. Which plugin normally discovers and runs those tests during the test phase?
23
The build reports that org.openqa.selenium.WebDriver cannot be found while compiling test classes. Selenium is absent from pom.xml. What is the appropriate correction?
24 A login test must run with five username-password combinations without duplicating the test method. Which TestNG feature is most suitable?
@BeforeSuite method
@Listeners declaration
@AfterClass method
@DataProvider method
25 A TestNG listener needs to capture a screenshot only when a test fails. Which callback and result check should it use?
onTestFailure(ITestResult result)
onTestSuccess(ITestResult result)
onStart(ITestContext context)
onTestStart(ITestResult result)
26 A TestNG suite should run test classes concurrently while methods within each class remain grouped in that class's execution. Which suite configuration is appropriate?
parallel="tests" without test elements
parallel="methods" with a thread count
parallel="instances" without factories
parallel="classes" with a thread count
27
A test uses SoftAssert to verify the page title, user name, and account balance. What must be called after the checks so that collected failures affect the test result?
verifyAll()
close()
flush()
assertAll()
28 A browser must be created before every test method and closed after every test method, even if a test fails. Which annotation pair best matches this lifecycle?
@BeforeMethod and @AfterMethod
@BeforeTest and @AfterTest
@BeforeClass and @AfterClass
@BeforeSuite and @AfterSuite
29 A checkout test sometimes fails because it clicks the Pay button before the button becomes enabled. Which change best improves the test case?
30
A successful login redirects users to URLs such as /dashboard?session=abc123. Which assertion is most robust for confirming the destination?
/dashboard
/dashboard
abc123
31
A local test currently creates ChromeDriver directly. To send the same test to Selenium Grid, which WebDriver implementation should normally replace it?
EventFiringDecorator with a local service
RemoteWebDriver with Grid URL and options
WebDriverWait with Grid URL and timeout
ChromeDriverService with TestNG context
32 Several session requests arrive when every matching Grid node is busy. Which Grid component holds the requests until capacity becomes available?
33 After a session is created, Grid must determine which node owns that session when later commands arrive. Which component maintains this mapping?
34 Which Selenium Grid component matches a requested browser capability with an available node slot?
35 A developer needs a complete Grid on one machine for a small test suite with minimal setup. Which startup mode is most appropriate?
selenium-server standalone
selenium-server sessions
selenium-server node
selenium-server hub
36
A test method receives browser as a TestNG parameter and must create matching Grid capabilities. What is the best script design?
RemoteWebDriver
37
A TestNG test submitOrder depends on login, and login fails. With the dependency configured through dependsOnMethods, what is the expected result for submitOrder?
38 Parallel Chrome and Firefox tests occasionally send commands to each other's browser sessions because they share a static WebDriver field. Which change best addresses the problem?
ThreadLocal
39 A monitoring service must check whether Selenium Grid is ready to accept sessions without opening a browser. Which endpoint should it query?
GET /session
POST /status
GET /status
POST /session
40 A Grid node has eight CPU cores, but browser memory usage requires limiting it to two concurrent sessions. Which node setting should be customized?
connection-limit-per-session = 2
max-sessions = 2
register-period = 2
session-timeout = 2
41
A Maven Selenium project contains src/main/java, src/test/java, and src/test/resources. A TestNG suite XML file must be available only during test execution and must not be packaged in the production JAR. Where should it be placed?
src/main/resources/testng.xml
src/test/resources/testng.xml
src/test/java/testng.xml
src/main/java/testng.xml
42
A project directly declares Selenium version 4.18.1. Another direct dependency transitively brings Selenium version 4.15.0. Both versions occur at the same dependency depth. Which Maven rule normally determines the selected version?
43
A TestNG suite works through an IDE but mvn test reports that no tests were executed. The classes are named CheckoutFlow.java, and Surefire has no custom includes or suite XML configuration. What is the most direct explanation?
Suite
src/test/java
44
A TestNG test method uses @DataProvider(parallel = true) and receives 40 data rows. The test stores its WebDriver in one shared instance field. Failures show sessions navigating to pages intended for other rows. Which design best addresses the root cause?
synchronized and retain one driver
45
A TestNG test must pass when an IllegalArgumentException is thrown only if its message starts with Invalid account:. Which annotation usage expresses both requirements through the TestNG API?
@Test(dependsOnMethods = "Invalid account:.*", expectedExceptions = RuntimeException.class)
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Invalid account:.*")
@Test(expectedExceptions = Exception.class, description = "Invalid account:.*")
@Test(alwaysRun = true, expectedExceptionsMessageRegExp = "Invalid account:.*")
46
A testng.xml suite is configured with parallel="methods" and thread-count="4". It contains one test class whose methods share a mutable instance field. Which statement is correct?
47
A superclass defines @BeforeClass openBase() and @AfterClass closeBase(). Its subclass defines @BeforeClass openChild() and @AfterClass closeChild(). Assuming all configuration methods succeed, which order does TestNG use?
openChild, openBase, tests, closeBase, closeChild
openBase, openChild, tests, closeChild, closeBase
openBase, openChild, tests, closeBase, closeChild
openChild, openBase, tests, closeChild, closeBase
48
A test uses a TestNG SoftAssert, performs five checks, and then returns without calling assertAll(). Two checks failed. What result should be expected?
assertAll() after the method returns
49 A checkout test fails intermittently because it clicks a button immediately after an overlay disappears visually, while the element is still not clickable. Which test design most directly models the required state?
50
A page displays currency as $1,234.50, while the service returns the numeric value 1234.5. Which assertion strategy is most robust?
1234
51
A RemoteWebDriver request specifies browserName=chrome and platformName=LINUX. The Grid has idle Chrome nodes, but all advertise platformName=WINDOWS. What should happen under normal capability matching?
52 In a fully distributed Selenium Grid, a new WebDriver session request reaches the Router. Which interaction correctly describes how a matching execution slot is obtained?
53 After a session is created, Grid must route later commands containing that session ID to the Node hosting it. Which component maintains the session-to-Node URI mapping?
54 A distributed Grid Node starts successfully but never appears as available in the Distributor. Browser drivers are installed correctly. The Node and Distributor were configured with different Event Bus publish and subscribe addresses. What is the most likely cause?
55 A test must run against a remote Grid and request Chrome without depending on the local machine's ChromeDriver executable. Which construction is appropriate?
new WebDriver(gridUrl, DesiredCapabilities.chrome())
new RemoteWebDriver(gridUrl, new ChromeOptions())
new ChromeOptions().setBinary(gridUrl.toString())
new ChromeDriver(gridUrl, new ChromeOptions())
56
A TestNG @BeforeMethod creates a remote driver, but session creation occasionally throws an exception. The @AfterMethod calls driver.quit() without checking whether assignment succeeded, obscuring the original failure with a NullPointerException. Which teardown is most appropriate?
@AfterSuite and unconditionally quit the shared driver once
@AfterMethod(alwaysRun = true) and quit only when the driver is non-null
57
A parallel TestNG suite creates Chrome and Firefox sessions from a shared mutable MutableCapabilities object. Each thread changes browserName immediately before session creation. What is the best correction?
browserName after the remote session has been created
driver.quit() for each invocation
58 A monitoring process needs a lightweight JSON response indicating whether Selenium Grid is ready to accept sessions. Which endpoint is intended for this purpose?
GET /session
DELETE /se/grid
GET /status
POST /graphql
59 An operations dashboard needs selected Grid data such as node details and session information without repeatedly scraping the Grid UI. Which Selenium Grid endpoint is designed for structured, field-specific queries?
POST /graphql
PUT /status
POST /session
GET /wd/hub
60
A Node has 16 CPU cores, so its general max-sessions is configured as 16. However, a resource-intensive browser stereotype must never run more than two concurrent sessions. Which configuration approach directly enforces that browser-specific limit?
max-sessions = 2
thread-count="2" on every client suite
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →