1

I'm new to Selenium, so I'm just trying to make simple test. I'm getting an error when I try to put some code into this function. This is the error I'm getting:

exception in thread "main" java.lang.NullPointerException

public class Selenium {
private static WebDriver browser; // I get error when I put this line

public static void setup() {
    System.setProperty("webdriver.chrome.driver","webDriver/chromedriver904.exe");
    WebDriver browser = new ChromeDriver();
    browser.get("http://weburl");
}

And the error shows on line WebElement:

 public static void main(String[] args) {
    System.out.println("Selenium");
    setup();
    WebElement pavadinimas = browser.findElement(By.xpath("//*[@id=\"form\"]/form/input[2]"));
vitaliis
  • 4,082
  • 5
  • 18
  • 40
BLACKDICK
  • 59
  • 6

0 Answers0