黄瓜“后”钩对我不起作用。 我有用于初始化驱动程序的BaseClass。
public class BaseClass {
public WebDriver driver ;
protected BaseClass () {
InitialiseParameter();
InitialiseDriver();
}
我们有另一个类,它是PageBase,它被具有逐步定义代码的其他类扩展。
public abstract class PageBase {
public WebDriver driver = null;
public PageBase(WebDriver driver) {
this.driver = driver;
}
我们将PageBase类扩展为流:
public class Search_TransmissionLines extends PageBase{
public Search_TransmissionLines(WebDriver driver) {
super(driver);
}
PhotoGallary photogallary =new PhotoGallary(driver);
Utilities util = new Utilities(driver);
该代码对于功能部件文件运行良好,所有步骤均已成功执行,但是执行@After
挂钩时会失败。我已经为此创建了钩子类
public class Hooks extends PageBase{
public Hooks(WebDriver driver) {
super(driver);
}
@After
public void CloseBrowser() {
BaseClass.isBrowserOpened = false;
driver.quit();
}
} 它显示以下错误: 错误:
org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: com.qsi.arcgisservice.Hooks has unsatisfied dependency 'interface org.openqa.selenium.WebDriver' for constructor 'public com.qsi.arcgisservice.Hooks(org.openqa.selenium.WebDriver)' from org.picocontainer.DefaultPicoContainer@2cfbeac4:14<|
at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:191)
at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110)
at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:331)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
我正在使用Java和Cucumber v4,并通过JUnit测试执行它。
不确定是什么坏事,有人可以帮我这个忙吗...所以如果有其他替代方法也对我有用。 谢谢