Month: July 2020

java.lang.NullPointerException in Selenium

For example, in selenium webdriver. public static WebDriver driver;             try {             driver.get(“http://www.gmail.com”);             System.setProperty(“webdriver.chrome.driver”,”c:\chromedriver.exe”);             driver=new ChromeDriver();             driver.findElement(By.xpath(“xpathemail”)).sendKeys(“username”);             driver.findElement(By.xpath(“xpathpass”)).sendKeys(“password”);             driver.quit();              } catch (Exception e) {            System.out.println(“The exception is” + e.printStackTrace()); } From the code example, we can see that the driver is calling the geturl, before …

java.lang.NullPointerException in Selenium Read More »

NoSuchElement exception, selenium webdriver is showing an exception as element not found in the web page.

When a web driver is not able to find the required web element in the web page, then the script will through an exception called no such element exception. In order, to run the script and catch the exception, we need to use try and catch blocks for the code. Example: Webelement submitbutton = diver.findelement(By.xpath(“xpathbuttonsubmit”)); …

NoSuchElement exception, selenium webdriver is showing an exception as element not found in the web page. Read More »