spring-wait给我driver=null

gajydyqb  于 2021-06-27  发布在  Java
关注(0)|答案(1)|浏览(292)

我想用流利的语言等等

@Component
@Scope(SCOPE_CUCUMBER_GLUE)
public class UserCreationPageImpl extends BaseBinariosPage implements UserCreationPage {
     Wait<WebDriver> wait = new FluentWait<WebDriver>( driver )
            .withTimeout(Duration.ofSeconds(30))
            .pollingEvery(Duration.ofSeconds(5))
            .ignoring(NoSuchElementException.class);

但当我调试时,我得到drive=null
这是我的地方,请告诉司机

@Page
public abstract class BaseBinariosPage {
    @Autowired
    protected WebDriver driver;
    @Autowired
    private QAStarterConfigProperties qaStarterConfigProperties;

    public BaseBinariosPage() {
    }

    @Init
    public void init() {
        this.driver.get(this.qaStarterConfigProperties.getAppUrl() + this.getPageEndPoint());
        PageFactory.initElements(this.driver, this);
    }

    protected abstract String getPageEndPoint();
}
vpfxa7rd

vpfxa7rd1#

当您声明一个变量时,默认情况下它将被赋值为空值。basebinariospage中没有创建驱动程序对象的构造函数,您希望它如何拥有驱动程序对象。
添加如下内容:

public BaseBinariosPage() {
  driver = new ChromeDriver()
}

相关问题