use this
[code:193tuoj0]
public static boolean isElementPresent(String xpathExpression){
List<WebElement> allElements ;
try{
allElements = driver.findElements(By.xpath(xpathExpression));
}catch(Exception e){
e.printstacktrace();
}
if (allElements.size()==0)
return false;
else
return true;
}
[/code:193tuoj0]
Now,when I ran the above given code , again a NullPointer exception is throwing....
kindly go through the screenshot..
I am using:
mozilla: 50.1.0
Eclipse: Luna 4.4.0
selenium: 3.0.1
you're creating new instance of webdriver in main().
to fix it replace this code.
[code:2orsg3rz]
System.setProperty("webdriver.gecko.driver","D:\\geckodriver\\geckodriver_32bit\\geckodriver.exe");
driver=new FirefoxDriver();
driver.manage().window().maximize();[/code:2orsg3rz]