webDriver.get("https://www.imooc.com/user/setprofile");这行代码报空指针

来源:2-8 Radio元素操作

樊先生666

2023-02-23

public class SeleniumAction {

WebDriver webDriver;
public void SetWebDriver(WebDriver webDriver){
    this.webDriver = webDriver;
}
@Test
public void InitDriver(){
    SeleniumOne seleniumOne =new SeleniumOne();
    seleniumOne.initDriver();//这是登陆已经实现了
    SeleniumAction seleniumAction = new SeleniumAction();
    seleniumAction.SetWebDriver(webDriver);
    seleniumAction.Radio();
}
public void Radio(){
    webDriver.get("https://www.imooc.com/user/setprofile");
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    webDriver.findElement(By.className("js-edit-info")).click();
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    webDriver.close();
}

}

写回答

1回答

Mushishi

2023-02-24


//img.mukewang.com/szimg/63f829f3094f51c808640790.jpg你这个实例化在哪里?或者哪里赋值,你下面test里面用都没

0
0

Java Web自动化测试 Selenium基础到企业实际应用

转型Java自动化测试,企业用什么,你就学什么。

752 学习 · 446 问题

查看课程