在selenium代码中获取java NullPointerException

问题描述 投票:0回答:1

我陷入了selenium代码中,我在junit的帮助下运行代码时开发了page_object模型的框架,我无法运行selenium测试,它抛出java NullpointerException异常错误。(https://i.stack.imgur.com/90C22.png) (https://i.stack.imgur.com/o46cT.png) (https://i.stack.imgur.com/j9Pqn.png)

java selenium-webdriver junit frameworks
1个回答
0
投票

您应该在问题内部发布代码片段,但在问题之外;在第 27 行的

BaseClass.java
中,您应该尝试将该行更改为:

driver = new ChromeDriver();

不要在前面使用

WebDriver
,否则你会在内存中创建一个新对象,而不是引用第18行的
driver

© www.soinside.com 2019 - 2024. All rights reserved.