package softwareTesting;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Program3 {
public static void main(String[] args) {
// Set path to [Link] (update path according to your system)
[Link]("[Link]", "C:\\Users\\[Link]\\
Desktop\\chromedriver-win64\\[Link]");
// Launch Chrome browser
WebDriver driver = new ChromeDriver();
try {
// Step 1: Open Google
[Link]("[Link]
// Step 2: Locate the search box and enter keyword
WebElement searchBox = [Link]([Link]("q"));
[Link]("Software Testing");
[Link]([Link]); // press Enter
// Step 3: Wait a bit for results to load
[Link](10000); // better to use WebDriverWait in real projects
// Step 4: Click the first visible search result link
WebElement firstResult = [Link]([Link]("h3"));
[Link]();
// Step 5: Print the title of the opened page
[Link]("Opened page title: " + [Link]());
} catch (Exception e) {
[Link]();
} finally {
// Close the browser
[Link]();
}
}
}