I am currently using Eclipse Mars along with JDK 1.8. Below is the code I have written:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class test1 {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D://chromedriver.exe");
WebDriver d1=new ChromeDriver();
WebElement e1;
d1.get("https://www.google.co.in/");
The following line executes without any issues:
e1=d1.findElement(By.id("lst-ib"));
However, when I try to search using css or xpath, nothing is returned.
e1=d1.findElement(By.cssSelector("input[class='gsfi'][name='q'][id='lst-ib']"));
or
e1=d1.findElement(By.xpath("input[@class='gsfi'][@name='q'][@id='lst-ib']"));