package selenium;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Googlesearchpage {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://google.com");
System.out.println(driver.getCurrentUrl());
System.out.println(driver.getTitle());
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(5000));
Thread.sleep(5 * 1000);
WebElement searchBox = driver.findElement(By.name("q"));
WebElement searchButton = driver.findElement(By.name("btnK"));
searchBox.sendKeys("suriyaparithy");
searchButton.click();
System.out.println(driver.getTitle());
System.out.println(driver.getCurrentUrl());
System.out.println(searchBox.getAttribute("value"));
searchButton.getText();
searchBox = driver.findElement(By.name("q"));
searchBox.getAttribute("value");
}
}
No comments:
Post a Comment