Cannot refer to an instance field pageTitle while explicitly invoking a cons

当下面这样时在第7行会提示:Cannot refer to an instance field pageTitle while explicitly invoking a cons


 1 public class LoginPage extends PageBase{
 2 //    private WebDriver driver;
 3 //    private final static 
 4     String pageTitle = "登录 - BugFree";
 5     
 6     public LoginPage( WebDriver driver){
 7         super(driver, pageTitle);  //显示调用父类的构造函数,而且必须是第一行调用 
 8         URL="http://192.168.1.151:8080/bugfree/index.php/site/login";
 9     
10     }

--解决方法:在第4行变明前加上“ static”就不会报错了。

 
原文地址:https://www.cnblogs.com/sschen/p/3631263.html