这是我的代码
package ecommerce;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Classwithmultiplemethods {
public static WebDriver driver;
public static void browser(){
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "D:\\Selenium\\selenium-java-3.141.59\\libs\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.com/");
driver.manage().window().maximize();
driver.get("http://newtours.demoaut.com/");
}
public static void clicklinks() {
System.out.println("new tours");
driver.findElement(By.linkText("REGISTER")).click();
/*driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.linkText("తెలుగు")).click();
driver.findElement(By.linkText("English")).click();
driver.findElement(By.linkText("हिन्दी")).click();
driver.findElement(By.linkText("English")).click();*/
}
public static void teardown() {
driver.quit();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
browser();
clicklinks();
teardown();
}
}
引发此错误,请帮助我解决
线程“主”中的异常java.lang.NullPointerException 在ecommerce.Classwithmultiplemethods.clicklinks(Classwithmultiplemethods.java:25) 在ecommerce.Classwithmultiplemethods.main(Classwithmultiplemethods.java:41)