package com.google.search;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class GoogleSearch {
public static void main(String[] args) throws InterruptedException {
String broserName = "IE";
WebDriver driver=null;
String driver = "J:\\Softwares\\drivers\\";
if(broserName.equalsIgnoreCase("ie")){
System.setProperty("webdriver.ie.driver", driver + "IEDriverServer.exe");
driver = new InternetExplorerDriver();
}else if(broserName.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", driver + "chromedriver.exe");
driver = new ChromeDriver();
}else if(broserName.equalsIgnoreCase("ff")){
System.setProperty("webdriver.gecko.driver", driver + "geckodriver.exe");
driver = new FirefoxDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/");
System.out.println(driver.getTitle());
WebElement searchText = driver.findElement(By.id("lst-ib"));
searchText.click();
searchText.clear();
searchText.sendKeys("Selenium WebDriver");
driver.findElement(By.name("btnG")).click();
Thread.sleep(3000);
System.out.println(driver.getTitle());
if(driver.getTitle().equalsIgnoreCase("Selenium WebDriver - Google Search")){
System.out.println("Test is Passed");
}else{
System.out.println("Test is failed");
}
}
}
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class GoogleSearch {
public static void main(String[] args) throws InterruptedException {
String broserName = "IE";
WebDriver driver=null;
String driver = "J:\\Softwares\\drivers\\";
if(broserName.equalsIgnoreCase("ie")){
System.setProperty("webdriver.ie.driver", driver + "IEDriverServer.exe");
driver = new InternetExplorerDriver();
}else if(broserName.equalsIgnoreCase("chrome")){
System.setProperty("webdriver.chrome.driver", driver + "chromedriver.exe");
driver = new ChromeDriver();
}else if(broserName.equalsIgnoreCase("ff")){
System.setProperty("webdriver.gecko.driver", driver + "geckodriver.exe");
driver = new FirefoxDriver();
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/");
System.out.println(driver.getTitle());
WebElement searchText = driver.findElement(By.id("lst-ib"));
searchText.click();
searchText.clear();
searchText.sendKeys("Selenium WebDriver");
driver.findElement(By.name("btnG")).click();
Thread.sleep(3000);
System.out.println(driver.getTitle());
if(driver.getTitle().equalsIgnoreCase("Selenium WebDriver - Google Search")){
System.out.println("Test is Passed");
}else{
System.out.println("Test is failed");
}
}
}
No comments:
Post a Comment