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. Designing web page layouts
B. Recording browser actions
C. Hosting application databases
D. Managing dependencies and builds

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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. Soft assertion
C. Boolean assertion
D. Static assertion

10 What should a basic Selenium test case normally contain?

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

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

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

12 Which TestNG assertion verifies that a condition is true?

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

13 What is the main purpose of Selenium Grid?

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

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

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

15 Which Selenium Grid component runs browser sessions?

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

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. java -jar selenium-server.jar compile
C. mvn selenium-server.jar standalone
D. testng selenium-server.jar execute

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

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

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.quit()
C. Call driver.findElement()
D. Call driver.navigate()

19 What does cross-browser testing verify?

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

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

Endpoints Easy
A. /execute
B. /report
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. Adding libraries through browser settings
D. Defining packages in 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?

Maven Project configuration Medium
A. Maven Surefire Plugin
B. Maven Compiler Plugin
C. Maven Resources 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. Declare Selenium in the suite listeners
C. Add Selenium as a Maven dependency
D. Add Selenium as a TestNG group

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. A @BeforeSuite method
B. An @Listeners declaration
C. An @AfterClass method
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. onTestFailure(ITestResult result)
B. onTestSuccess(ITestResult result)
C. onStart(ITestContext context)
D. 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?

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

Types of assertions and annotations Medium
A. @BeforeMethod and @AfterMethod
B. @BeforeTest and @AfterTest
C. @BeforeClass and @AfterClass
D. @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?

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

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 URL contains /dashboard
B. Assert that the URL equals only /dashboard
C. Assert that the page source contains abc123
D. Assert that the browser title equals the URL

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. EventFiringDecorator with a local service
B. RemoteWebDriver with Grid URL and options
C. WebDriverWait with Grid URL and timeout
D. 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?

Grid Architecture Medium
A. Session Map
B. Event Bus
C. Router
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. Distributor
B. Session Map
C. New Session Queue
D. Event Bus

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

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

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 standalone
B. selenium-server sessions
C. selenium-server node
D. 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?

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

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 runs normally using the existing browser
B. It is skipped because its dependency failed
C. It runs twice to confirm the dependency failure
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. Store each driver in a ThreadLocal
B. Store both drivers in one static array
C. Reduce every explicit wait timeout
D. Synchronize only the assertion methods

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 /session
B. POST /status
C. GET /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. connection-limit-per-session = 2
B. max-sessions = 2
C. register-period = 2
D. 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?

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

Maven Project configuration Hard
A. The dependency with the largest artifact wins
B. The dependency with the newest version wins
C. The transitive dependency always wins
D. The dependency declared first in the POM 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. TestNG requires every class name to end with Suite
B. Surefire executes only classes declared as Java modules
C. Maven cannot execute tests located under src/test/java
D. Surefire's default filename patterns do not match the classes

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. Set the test method priority to ensure deterministic invocation order
B. Mark the data provider method as synchronized and retain one driver
C. Increase the implicit wait so navigation operations cannot overlap
D. Create a driver per invocation and isolate it by thread or test context

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(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Invalid account:.*")
C. @Test(expectedExceptions = Exception.class, description = "Invalid account:.*")
D. @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?

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

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. openChild, openBase, tests, closeBase, closeChild
B. openBase, openChild, tests, closeChild, closeBase
C. openBase, openChild, tests, closeBase, closeChild
D. 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?

Types of assertions and annotations Hard
A. The first failed check immediately terminates the test method
B. The test may be reported as passed despite the recorded failures
C. The test is skipped because soft assertions require a listener
D. TestNG automatically invokes 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?

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

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. Convert both values to binary floating point and compare exactly
B. Compare both values as raw strings after trimming whitespace
C. Parse both values as decimals and compare numeric equality
D. Check only that the displayed string contains the digits 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?

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

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 Node broadcasts the request to every Distributor and chooses the quickest response
B. The request enters the New Session Queue, and the Distributor assigns a matching Node slot
C. The Session Map selects a browser binary and allocates a local driver process
D. The Event Bus creates the browser process and registers it directly with the Router

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. Session Map
B. Event Bus
C. New Session Queue
D. Distributor

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 Router must be restarted after every Node process starts
B. The Node must expose the same HTTP port as the Distributor
C. The Node cannot participate in Grid registration events
D. The Distributor requires browser drivers on its own machine

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 ChromeOptions().setBinary(gridUrl.toString())
D. 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?

Test Execution Hard
A. Remove teardown and rely on Grid to delete sessions immediately
B. Use @AfterSuite and unconditionally quit the shared driver once
C. Catch every setup exception and mark the test as passed
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. Create independent immutable-in-practice options for each invocation
D. Synchronize only the call to 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?

Endpoints Hard
A. GET /session
B. DELETE /se/grid
C. GET /status
D. 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?

Endpoints Hard
A. POST /graphql
B. PUT /status
C. POST /session
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. Define a driver configuration for the stereotype with max-sessions = 2
B. Configure TestNG with thread-count="2" on every client suite
C. Set the Router's thread pool size to two for all HTTP commands
D. Set the Distributor's total session limit to two for the entire Grid