Unit 4: Selenium Validation and Grid - Practice Quiz

CSE377 — Web Automation Testing 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the primary purpose of Maven in a Selenium testing project?

Introduction to Maven project Easy
A. Managing dependencies and builds
B. Recording browser actions
C. Designing web page layouts
D. Hosting application databases

2 Which file is primarily used to configure a Maven project?

Maven Project configuration Easy
A. package.json
B. pom.xml
C. testng.xml
D. settings.json

3 In which section of pom.xml are Selenium and TestNG libraries normally declared?

Maven Project configuration Easy
A. <developers>
B. <repositories>
C. <properties>
D. <dependencies>

4 What is TestNG mainly used for in a Selenium project?

Introduction to TestNG Easy
A. Managing browser installations
B. Creating HTML page styles
C. Organizing and executing tests
D. Designing relational databases

5 Where can a tester find official details about TestNG classes and methods?

TestNG API Documentation Easy
A. TestNG API documentation
B. Browser history window
C. Selenium screenshot folder
D. Maven target directory

6 Which file is commonly used to define TestNG suites and test groups?

TestNG configuration Easy
A. grid.toml
B. index.html
C. testng.xml
D. pom.xml

7 Which TestNG annotation identifies a method as a test method?

Types of assertions and annotations Easy
A. @AfterMethod
B. @DataProvider
C. @BeforeTest
D. @Test

8 Which TestNG annotation runs a method before each test method?

Types of assertions and annotations Easy
A. @BeforeMethod
B. @AfterMethod
C. @AfterClass
D. @BeforeSuite

9 Which type of TestNG assertion allows execution to continue after an assertion failure until assertAll() is called?

Types of assertions and annotations Easy
A. Hard assertion
B. Static assertion
C. Soft assertion
D. Boolean assertion

10 What should a basic Selenium test case normally contain?

Test Case Creation Easy
A. Styles, images, and hyperlinks
B. Setup, actions, and verification
C. Tables, queries, and indexes
D. Packages, servers, and domains

11 Which TestNG method checks whether an actual value equals an expected value?

Implementing assertions Easy
A. Assert.assertNull()
B. Assert.assertFalse()
C. Assert.assertEquals()
D. Assert.fail()

12 Which TestNG assertion verifies that a condition is true?

Implementing assertions Easy
A. Assert.assertTrue()
B. Assert.assertEquals()
C. Assert.assertNotSame()
D. Assert.assertNull()

13 What is the main purpose of Selenium Grid?

Selenium Grid Easy
A. Running tests on multiple environments
B. Installing dependencies from Maven
C. Creating test reports in HTML
D. Locating elements on web pages

14 In Selenium Grid, which component receives new WebDriver session requests?

Grid Architecture Easy
A. Router
B. Node
C. Event Bus
D. Session Map

15 Which Selenium Grid component runs browser sessions?

Grid Components Easy
A. Distributor
B. Node
C. Router
D. Session Map

16 Which command starts Selenium Grid in standalone mode using a Selenium Server JAR?

Grid Configuration Easy
A. java -jar selenium-server.jar standalone
B. testng selenium-server.jar execute
C. java -jar selenium-server.jar compile
D. mvn selenium-server.jar standalone

17 Which Selenium class is commonly used to connect a test script to a remote Grid?

Create Test Script Easy
A. WebElement
B. RemoteWebDriver
C. By
D. Select

18 What must a Selenium test do after completing browser actions to close the entire WebDriver session?

Test Execution Easy
A. Call driver.get()
B. Call driver.findElement()
C. Call driver.quit()
D. Call driver.navigate()

19 What does cross-browser testing verify?

Cross Browser Testing Easy
A. Storage across different databases
B. Access across different user accounts
C. Compilation across different languages
D. Behavior across different browsers

20 Which Selenium Grid endpoint is commonly used to check the Grid's current status?

Endpoints Easy
A. /report
B. /execute
C. /browser
D. /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?

Introduction to Maven project Medium
A. Declaring dependencies in pom.xml
B. Storing JAR files in the source folder
C. Defining packages in testng.xml
D. Adding libraries through browser settings

22 A Maven project stores TestNG tests under src/test/java. Which plugin normally discovers and runs those tests during the test phase?

Maven Project configuration Medium
A. Maven Resources Plugin
B. Maven Surefire Plugin
C. Maven Compiler Plugin
D. Maven Clean Plugin

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?

Maven Project configuration Medium
A. Register Selenium in the Grid router
B. Add Selenium as a Maven dependency
C. Add Selenium as a TestNG group
D. Declare Selenium in the suite listeners

24 A login test must run with five username-password combinations without duplicating the test method. Which TestNG feature is most suitable?

Introduction to TestNG Medium
A. An @AfterClass method
B. A @BeforeSuite method
C. An @Listeners declaration
D. A @DataProvider method

25 A TestNG listener needs to capture a screenshot only when a test fails. Which callback and result check should it use?

TestNG API Documentation Medium
A. onTestStart(ITestResult result)
B. onStart(ITestContext context)
C. onTestSuccess(ITestResult result)
D. onTestFailure(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?

TestNG configuration Medium
A. parallel="instances" without factories
B. parallel="methods" with a thread count
C. parallel="tests" without test elements
D. 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?

Types of assertions and annotations Medium
A. assertAll()
B. flush()
C. close()
D. verifyAll()

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?

Types of assertions and annotations Medium
A. @BeforeTest and @AfterTest
B. @BeforeClass and @AfterClass
C. @BeforeSuite and @AfterSuite
D. @BeforeMethod and @AfterMethod

29 A checkout test sometimes fails because it clicks the Pay button before the button becomes enabled. Which change best improves the test case?

Test Case Creation Medium
A. Increase the browser window dimensions
B. Retry the complete suite after each failure
C. Add a fixed delay before every test step
D. Wait explicitly until the button is clickable

30 A successful login redirects users to URLs such as /dashboard?session=abc123. Which assertion is most robust for confirming the destination?

Implementing assertions Medium
A. Assert that the browser title equals the URL
B. Assert that the URL equals only /dashboard
C. Assert that the URL contains /dashboard
D. Assert that the page source contains abc123

31 A local test currently creates ChromeDriver directly. To send the same test to Selenium Grid, which WebDriver implementation should normally replace it?

Selenium Grid Medium
A. ChromeDriverService with TestNG context
B. EventFiringDecorator with a local service
C. RemoteWebDriver with Grid URL and options
D. WebDriverWait with Grid URL and timeout

32 Several session requests arrive when every matching Grid node is busy. Which Grid component holds the requests until capacity becomes available?

Grid Architecture Medium
A. Router
B. Event Bus
C. Session Map
D. New Session Queue

33 After a session is created, Grid must determine which node owns that session when later commands arrive. Which component maintains this mapping?

Grid Components Medium
A. Event Bus
B. Session Map
C. Distributor
D. New Session Queue

34 Which Selenium Grid component matches a requested browser capability with an available node slot?

Grid Components Medium
A. Event Bus
B. Router
C. Distributor
D. Session Map

35 A developer needs a complete Grid on one machine for a small test suite with minimal setup. Which startup mode is most appropriate?

Grid Configuration Medium
A. selenium-server sessions
B. selenium-server hub
C. selenium-server standalone
D. selenium-server node

36 A test method receives browser as a TestNG parameter and must create matching Grid capabilities. What is the best script design?

Create Test Script Medium
A. Build browser-specific options and pass them to RemoteWebDriver
B. Set the browser name after the remote session starts
C. Build a local driver and pass it to the Grid Router
D. Create every browser driver and select one after launch

37 A TestNG test submitOrder depends on login, and login fails. With the dependency configured through dependsOnMethods, what is the expected result for submitOrder?

Test Execution Medium
A. It is skipped because its dependency failed
B. It runs twice to confirm the dependency failure
C. It runs normally using the existing browser
D. It passes automatically without being executed

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?

Cross Browser Testing Medium
A. Reduce every explicit wait timeout
B. Synchronize only the assertion methods
C. Store both drivers in one static array
D. Store each driver in a ThreadLocal

39 A monitoring service must check whether Selenium Grid is ready to accept sessions without opening a browser. Which endpoint should it query?

Endpoints Medium
A. GET /status
B. GET /session
C. POST /status
D. 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?

Customizing a Node Medium
A. session-timeout = 2
B. max-sessions = 2
C. connection-limit-per-session = 2
D. register-period = 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?

Introduction to Maven project Hard
A. src/main/java/testng.xml
B. src/test/resources/testng.xml
C. src/main/resources/testng.xml
D. src/test/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?

Maven Project configuration Hard
A. The transitive dependency always wins
B. The dependency with the largest artifact wins
C. The dependency declared first in the POM wins
D. The dependency with the newest version wins

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?

Maven Project configuration Hard
A. Maven cannot execute tests located under src/test/java
B. Surefire's default filename patterns do not match the classes
C. Surefire executes only classes declared as Java modules
D. TestNG requires every class name to end with Suite

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?

Introduction to TestNG Hard
A. Create a driver per invocation and isolate it by thread or test context
B. Increase the implicit wait so navigation operations cannot overlap
C. Mark the data provider method as synchronized and retain one driver
D. Set the test method priority to ensure deterministic invocation order

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?

TestNG API Documentation Hard
A. @Test(dependsOnMethods = "Invalid account:.*", expectedExceptions = RuntimeException.class)
B. @Test(alwaysRun = true, expectedExceptionsMessageRegExp = "Invalid account:.*")
C. @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Invalid account:.*")
D. @Test(expectedExceptions = Exception.class, description = "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?

TestNG configuration Hard
A. Methods may run concurrently on the same class instance
B. Methods remain sequential unless a data provider is also parallel
C. TestNG automatically clones the class instance for every method
D. The thread count is ignored when only one class is present

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?

Types of assertions and annotations Hard
A. openBase, openChild, tests, closeBase, closeChild
B. openBase, openChild, tests, closeChild, closeBase
C. openChild, openBase, tests, closeChild, closeBase
D. openChild, openBase, tests, closeBase, closeChild

48 A test uses a TestNG SoftAssert, performs five checks, and then returns without calling assertAll(). Two checks failed. What result should be expected?

Types of assertions and annotations Hard
A. TestNG automatically invokes assertAll() after the method returns
B. The test may be reported as passed despite the recorded failures
C. The test is skipped because soft assertions require a listener
D. The first failed check immediately terminates the test method

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?

Test Case Creation Hard
A. Add a fixed delay equal to the average overlay duration
B. Increase the page-load timeout before every navigation
C. Retry the entire test whenever the click throws an exception
D. Wait explicitly until the button is clickable

50 A page displays currency as $1,234.50, while the service returns the numeric value 1234.5. Which assertion strategy is most robust?

Implementing assertions Hard
A. Compare both values as raw strings after trimming whitespace
B. Convert both values to binary floating point and compare exactly
C. Check only that the displayed string contains the digits 1234
D. Parse both values as decimals and compare numeric equality

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?

Selenium Grid Hard
A. The client automatically starts a local Linux browser
B. The Router assigns the request to any idle Chrome node
C. The request remains queued until a matching slot becomes available
D. The Distributor silently removes the platform requirement

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?

Grid Architecture Hard
A. The Event Bus creates the browser process and registers it directly with the Router
B. The request enters the New Session Queue, and the Distributor assigns a matching Node slot
C. The Node broadcasts the request to every Distributor and chooses the quickest response
D. The Session Map selects a browser binary and allocates a local driver process

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?

Grid Components Hard
A. Event Bus
B. New Session Queue
C. Distributor
D. Session Map

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?

Grid Configuration Hard
A. The Node cannot participate in Grid registration events
B. The Router must be restarted after every Node process starts
C. The Distributor requires browser drivers on its own machine
D. The Node must expose the same HTTP port as the Distributor

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?

Create Test Script Hard
A. new WebDriver(gridUrl, DesiredCapabilities.chrome())
B. new RemoteWebDriver(gridUrl, new ChromeOptions())
C. new ChromeDriver(gridUrl, new ChromeOptions())
D. new ChromeOptions().setBinary(gridUrl.toString())

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?

Test Execution Hard
A. Catch every setup exception and mark the test as passed
B. Remove teardown and rely on Grid to delete sessions immediately
C. Use @AfterSuite and unconditionally quit the shared driver once
D. Use @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?

Cross Browser Testing Hard
A. Set browserName after the remote session has been created
B. Reuse one browser session and clear cookies between browser cases
C. Synchronize only the call to driver.quit() for each invocation
D. Create independent immutable-in-practice options 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?

Endpoints Hard
A. DELETE /se/grid
B. POST /graphql
C. GET /session
D. GET /status

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?

Endpoints Hard
A. PUT /status
B. POST /session
C. POST /graphql
D. 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?

Customizing a Node Hard
A. Set the Distributor's total session limit to two for the entire Grid
B. Set the Router's thread pool size to two for all HTTP commands
C. Configure TestNG with thread-count="2" on every client suite
D. Define a driver configuration for the stereotype with max-sessions = 2