Run tests on Selenium Grid with RemoteWebDriver
intermediate Selenium Grid Challenge 13 of 13
CheckoutTest launches Chrome on the machine running the tests. CI now provides a Selenium Grid 4 at http://localhost:4444, and tests must run there instead.
Requirements
- Replace
new ChromeDriver()with aRemoteWebDriverpointed athttp://localhost:4444. - Request Chrome by passing a
ChromeOptionsobject (add any arguments you need, such as headless mode). - Build the address with
URI.create("…").toURL()ornew URL("…"). - Call
driver.quit()in an@AfterMethod(withalwaysRun = true) or afinallyblock, so the Grid session is released even when the test fails.
Expected output
`setUp` builds `ChromeOptions` and creates `new RemoteWebDriver(URI.create("http://localhost:4444").toURL(), options)` (or `new URL("http://localhost:4444")`). No `ChromeDriver` is created locally, and `driver.quit()` runs in an `@AfterMethod(alwaysRun = true)` method (or a `finally` block), so the Grid session is released even when the test fails.
Checks (5)
- ○Does not start a local ChromeDriver
- ○Creates a RemoteWebDriver
- ○Requests Chrome with ChromeOptions
- ○Passes the Grid address as a URL
- ○Quits the driver in @AfterMethod or a finally block
Solution.javaValidated · not executed
Ctrl/⌘ + Enter to validate · your code is saved in this browser
Results
Validate your code against the checks.