Java 如何解决:cucumber.runtime.CucumberException:未能实例化类com.philips.rs.ui.stepdefs.LoginSteps
我正在开发一个页面对象模型框架,但我面临无法实例化类的异常 请检查我的方法 按照这种方法,我将面临无法实例化的异常,但这种异常不会在第一个场景中出现,从第二个场景开始,驱动器不会启动。请告诉我哪里出了问题 我在ScenarioCleanUp类中有@After,其中webDriver已关闭Java 如何解决:cucumber.runtime.CucumberException:未能实例化类com.philips.rs.ui.stepdefs.LoginSteps,java,exception,junit,constructor,cucumber,Java,Exception,Junit,Constructor,Cucumber,我正在开发一个页面对象模型框架,但我面临无法实例化类的异常 请检查我的方法 按照这种方法,我将面临无法实例化的异常,但这种异常不会在第一个场景中出现,从第二个场景开始,驱动器不会启动。请告诉我哪里出了问题 我在ScenarioCleanUp类中有@After,其中webDriver已关闭 public class ScenarioCleanUp { public static final Logger logger = Logger.getLogger(BrowserTest.cla
public class ScenarioCleanUp {
public static final Logger logger = Logger.getLogger(BrowserTest.class);
public WebDriver driver = UITestUtils.driver;
@After()
public void tearDown(Scenario scenario) throws Exception {
System.out.println("---------Closing the Sceanrio-----------------");
if (scenario.isFailed())
{
System.out.println("Came Inside Scenario Failed");
DateFormat df = new SimpleDateFormat("ddMMyyHHmmss");
Date dateobj = new Date();
logger.info("CurrentDate used for concating the sceenshot: " + df.format(dateobj));
logger.error("The Scenario is failed: " + scenario.getName());
scenario.write("Current Page URL is " + driver.getCurrentUrl());
String filename = scenario.getName();
filename = filename.replaceAll("\"", "");
filename = filename.replaceAll("\\s+", "_");
filename = filename + df.format(dateobj) + ".jpg";
new UITestUtils().takeSnapShot(driver,filename);
}
if(driver!= null)
{
System.out.println("Driver is not null");
driver.close();
}
}
}
这是因为UITestUtils构造函数仅在第一个场景中调用,并且在第二个场景中关闭浏览器。对于第二个或更多场景,将不调用此构造。有两种解决方案