import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; public class ChromeExample { public static void main(String[] args) { //Setting system properties of ChromeDriver System.setProperty("webdriver.chrome.driver", "C://Selenium-java browserstack//chromedriver_win32//chromedriver.exe"); //Creating an object of ChromeDriver WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); //Deleting all the cookies driver.manage().deleteAllCookies(); //Specifiying pageLoadTimeout and Implicit wait driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);//(these two lines) driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);//(if i commandline this lines, it throws exception) //launching the specified URL driver.get("https://www.google.com/"); //Locating the elements using name locator for the text box driver.findElement(By.name("q")).sendKeys("YouTube"); //name locator for google search button WebElement searchIcon = driver.findElement(By.name("btnK")); searchIcon.click(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)