1 上面是谷歌浏览器和chromedriver版本
2下面是代码 , 浏览器打开后,网站不能正常打开,控制台报空指针异常
package PDWYPT;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SHUAXIN {
WebDriver driver;
//private WebDriver driver;
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
//初始化一个谷歌浏览器名称为 driver
WebDriver driver = new ChromeDriver();
//窗口最大化
driver.manage().window().maximize();
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void test() throws InterruptedException {
driver.get("https://XXXX/AXXX/fron22t/index.jsp");
for(int i=0;i<=200;i++){
driver.findElement(By.linkText("云设计")).click();
// for(int i=0;i<=200;i++){
driver.findElement(By.className("shang")).click();
driver.findElement(By.linkText("云设计")).click();
Thread.sleep(3000);
}
}