java.lang.NullPointerException:无法调用"org. openqa. selenium. WebDriver. findElement(org. openqa. selenium. By)",因为"此.驱动程序"为空

mm5n2pyu  于 2023-02-04  发布在  Java
关注(0)|答案(1)|浏览(197)

我遇到了一个错误:

java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebDriver.findElement(org.openqa.selenium.By)" because "this.driver" is null

代码和错误屏幕截图:

我能知道为什么会出现此错误吗?
我正在尝试执行结果应该打印为true的脚本,但出现错误。

fbcarpbf

fbcarpbf1#

要使用By类,需要按如下所示导入By

import org.openqa.selenium.By;

相关问题