This test opens https://www.example.com, checks if the page title contains 'Example', prints the result, and closes the browser.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class OpenUrlTest {
public static void main(String[] args) {
// Set path to chromedriver executable if needed
// System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
// Open the URL
driver.get("https://www.example.com");
// Check page title contains 'Example'
String title = driver.getTitle();
if (title.contains("Example")) {
System.out.println("Test Passed: Page loaded with title: " + title);
} else {
System.out.println("Test Failed: Unexpected page title: " + title);
}
// Close the browser
driver.quit();
}
}