package BhanuSir;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class GoogleSearch {
public static void main(String[] args) {
System.out.println("Enter the word which u want to search in Google: ");
Scanner in = new Scanner(System.in);
String srchWord = in.nextLine();
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/");
driver.findElement(By.name("q")).sendKeys(srchWord);
//get the test suggested by google from the dropdown.
List<WebElement> sugg = driver.findElements(By.xpath("//table[@class='gssb_m']/tbody/tr"));
for(WebElement ele: sugg){
System.out.println(ele.getText());
}
driver.close();
}
}
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class GoogleSearch {
public static void main(String[] args) {
System.out.println("Enter the word which u want to search in Google: ");
Scanner in = new Scanner(System.in);
String srchWord = in.nextLine();
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/");
driver.findElement(By.name("q")).sendKeys(srchWord);
//get the test suggested by google from the dropdown.
List<WebElement> sugg = driver.findElements(By.xpath("//table[@class='gssb_m']/tbody/tr"));
for(WebElement ele: sugg){
System.out.println(ele.getText());
}
driver.close();
}
}
No comments:
Post a Comment