selenium CucumberException:运行测试时未能示例化类SteDefinitions

iszxjhcz  于 2022-11-10  发布在  其他
关注(0)|答案(3)|浏览(130)

请帮帮忙。我认为在初始化页面时有一个错误

public class AuthStepDefinitions {

private final AuthPage authPage = new AuthPage();

@When("^user on Auth Page$")
public void onAuthPage() {
    AuthPage.getStartPage();
}

等。

public class AuthPage extends TestBase {

private String loginPassrod = "test@test.test";

@FindBy(id = "USER_LOGIN")
private WebElement loginInput;

@FindBy(id = "USER_PASSWORD")
private WebElement userPassword;

@FindBy(className = "btn")
private WebElement btnEntrance;

@FindBy(css = "table.dataTable")
private WebElement table;

@FindBy(css = "a.button-new")
private WebElement create;

@FindBy(className = "sidebar-profile")
private WebElement profile;

public AuthPage() {
    PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
}

等。

public abstract class TestBase {

/**
 * Default timeout for waiting
 */
private static final int ELEMENT_TIMEOUT_SECONDS = 20;

protected static WebDriver driver;
JavascriptExecutor js = (JavascriptExecutor) driver;

public void setup() {
    System.setProperty("webdriver.chrome.driver", BaseProperties.driverDir );
    driver = new ChromeDriver();
    driver.manage().window().maximize();
}

protected static void onMainPage() {
    driver.get("хxx");
}

等。
我认为这里有一些问题

private final AuthPage authPage = new AuthPage();
    PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
}

这里有一些可能会有帮助的信息
error
下面是整个堆栈跟踪

"C:\Program Files\Java\jdk-12.0.1\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\lib\idea_rt.jar=63014:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.3\plugins\junit\lib\junit5-rt.jar;C:\Users\Mark100F\IdeaProjects\TestNetGo\target\test-classes;C:\Users\Mark100F\.m2\repository\junit\junit\4.13-beta-3\junit-4.13-beta-3.jar;C:\Users\Mark100F\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-java\4.0.0-alpha-1\selenium-java-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\4.0.0-alpha-1\selenium-chrome-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\4.0.0-alpha-1\selenium-remote-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-api\4.0.0-alpha-1\selenium-api-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\net\bytebuddy\byte-buddy\1.9.12\byte-buddy-1.9.12.jar;C:\Users\Mark100F\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\Mark100F\.m2\repository\com\google\guava\guava\27.1-jre\guava-27.1-jre.jar;C:\Users\Mark100F\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\Mark100F\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\Mark100F\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Mark100F\.m2\repository\org\checkerframework\checker-qual\2.5.2\checker-qual-2.5.2.jar;C:\Users\Mark100F\.m2\repository\com\google\errorprone\error_prone_annotations\2.2.0\error_prone_annotations-2.2.0.jar;C:\Users\Mark100F\.m2\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;C:\Users\Mark100F\.m2\repository\org\codehaus\mojo\animal-sniffer-annotations\1.17\animal-sniffer-annotations-1.17.jar;C:\Users\Mark100F\.m2\repository\com\squareup\okhttp3\okhttp\3.14.0\okhttp-3.14.0.jar;C:\Users\Mark100F\.m2\repository\com\squareup\okio\okio\1.17.2\okio-1.17.2.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\4.0.0-alpha-1\selenium-edge-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-firefox-xpi-driver\4.0.0-alpha-1\selenium-firefox-xpi-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\4.0.0-alpha-1\selenium-firefox-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\4.0.0-alpha-1\selenium-ie-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\4.0.0-alpha-1\selenium-opera-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\4.0.0-alpha-1\selenium-safari-driver-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\org\seleniumhq\selenium\selenium-support\4.0.0-alpha-1\selenium-support-4.0.0-alpha-1.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\htmlelements\htmlelements-all\1.15\htmlelements-all-1.15.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\htmlelements\htmlelements-java\1.15\htmlelements-java-1.15.jar;C:\Users\Mark100F\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\Mark100F\.m2\repository\com\googlecode\lambdaj\lambdaj\2.3.3\lambdaj-2.3.3.jar;C:\Users\Mark100F\.m2\repository\org\objenesis\objenesis\1.2\objenesis-1.2.jar;C:\Users\Mark100F\.m2\repository\cglib\cglib-nodep\2.2\cglib-nodep-2.2.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-java\1.2.5\cucumber-java-1.2.5.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-core\1.2.5\cucumber-core-1.2.5.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-html\0.2.3\cucumber-html-0.2.3.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-jvm-deps\1.0.5\cucumber-jvm-deps-1.0.5.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-junit\1.2.5\cucumber-junit-1.2.5.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-cucumber-jvm-adaptor\1.6.2\allure-cucumber-jvm-adaptor-1.6.2.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-java-aspects\1.5.2\allure-java-aspects-1.5.2.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-java-adaptor-api\1.5.2\allure-java-adaptor-api-1.5.2.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-java-annotations\1.5.2\allure-java-annotations-1.5.2.jar;C:\Users\Mark100F\.m2\repository\org\apache\tika\tika-core\1.7\tika-core-1.7.jar;C:\Users\Mark100F\.m2\repository\org\aspectj\aspectjrt\1.8.3\aspectjrt-1.8.3.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-commons\1.5.2\allure-commons-1.5.2.jar;C:\Users\Mark100F\.m2\repository\ru\yandex\qatools\allure\allure-model\1.5.2\allure-model-1.5.2.jar;C:\Users\Mark100F\.m2\repository\org\jvnet\jaxb2_commons\jaxb2-basics-runtime\0.9.3\jaxb2-basics-runtime-0.9.3.jar;C:\Users\Mark100F\.m2\repository\ru\qatools\commons\properties\2.0.RC5\properties-2.0.RC5.jar;C:\Users\Mark100F\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\Mark100F\.m2\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;C:\Users\Mark100F\.m2\repository\info\cukes\gherkin\2.12.2\gherkin-2.12.2.jar;C:\Users\Mark100F\.m2\repository\commons-logging\commons-logging-api\1.1\commons-logging-api-1.1.jar;C:\Users\Mark100F\.m2\repository\info\cukes\cucumber-testng\1.2.5\cucumber-testng-1.2.5.jar;C:\Users\Mark100F\.m2\repository\org\testng\testng\6.9.9\testng-6.9.9.jar;C:\Users\Mark100F\.m2\repository\com\beust\jcommander\1.48\jcommander-1.48.jar;C:\Users\Mark100F\.m2\repository\org\apache\ant\ant\1.7.0\ant-1.7.0.jar;C:\Users\Mark100F\.m2\repository\org\apache\ant\ant-launcher\1.7.0\ant-launcher-1.7.0.jar;C:\Users\Mark100F\.m2\repository\org\yaml\snakeyaml\1.15\snakeyaml-1.15.jar;C:\Users\Mark100F\.m2\repository\org\beanshell\bsh\2.0b4\bsh-2.0b4.jar;C:\Users\Mark100F\.m2\repository\javax\xml\bind\jaxb-api\2.2.11\jaxb-api-2.2.11.jar;C:\Users\Mark100F\.m2\repository\com\sun\xml\bind\jaxb-core\2.2.11\jaxb-core-2.2.11.jar;C:\Users\Mark100F\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.11\jaxb-impl-2.2.11.jar;C:\Users\Mark100F\.m2\repository\javax\activation\activation\1.1.1\activation-1.1.1.jar;C:\Users\Mark100F\.m2\repository\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;C:\Users\Mark100F\.m2\repository\org\slf4j\slf4j-log4j12\1.7.5\slf4j-log4j12-1.7.5.jar;C:\Users\Mark100F\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 runners.firstTestRunner

cucumber.runtime.CucumberException: Failed to instantiate class stepDefinitions.AuthStepDefinitions

    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:47)
    at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:33)
    at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
    at cucumber.runtime.Runtime.runStep(Runtime.java:300)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:41)
    ... 33 more
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/WrapsElement
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:58)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:54)
    at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:53)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:110)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:102)
    at pages.AuthPage.<init>(AuthPage.java:33)
    at stepDefinitions.AuthStepDefinitions.<init>(AuthStepDefinitions.java:10)
    ... 39 more
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.internal.WrapsElement
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 55 more

Test ignored.

Test ignored.

Test ignored.

Failed scenarios:
authPage.feature:7 # Scenario: LogIn om Auth Page

1 Scenarios (1 failed)
4 Steps (1 failed, 3 skipped)
0m0,407s

cucumber.runtime.CucumberException: Failed to instantiate class stepDefinitions.AuthStepDefinitions
    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:47)
    at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:33)
    at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
    at cucumber.runtime.Runtime.runStep(Runtime.java:300)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:41)
    ... 33 more
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/WrapsElement
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:58)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:54)
    at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:53)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:110)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:102)
    at pages.AuthPage.<init>(AuthPage.java:33)
    at stepDefinitions.AuthStepDefinitions.<init>(AuthStepDefinitions.java:10)
    ... 39 more
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.internal.WrapsElement
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 55 more

cucumber.runtime.CucumberException: Failed to instantiate class stepDefinitions.AuthStepDefinitions

    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:47)
    at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:33)
    at cucumber.runtime.java.JavaStepDefinition.execute(JavaStepDefinition.java:38)
    at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)
    at cucumber.runtime.Runtime.runStep(Runtime.java:300)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:330)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:78)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:328)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:65)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:305)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:412)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:41)
    ... 33 more
Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/WrapsElement
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:58)
    at ru.yandex.qatools.htmlelements.utils.HtmlElementUtils.isTypifiedElement(HtmlElementUtils.java:54)
    at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:53)
    at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:110)
    at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:102)
    at pages.AuthPage.<init>(AuthPage.java:33)
    at stepDefinitions.AuthStepDefinitions.<init>(AuthStepDefinitions.java:10)
    ... 39 more
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.internal.WrapsElement
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 55 more

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by cucumber.deps.com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/Mark100F/.m2/repository/info/cukes/cucumber-jvm-deps/1.0.5/cucumber-jvm-deps-1.0.5.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of cucumber.deps.com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Process finished with exit code -1
9nvpjoqh

9nvpjoqh1#

对我来说帮助下一步:

public AuthPage() {
        super.setup();
        PageFactory.initElements(driver, this);
    }

已更新Pom.xml中的依赖项,并删除了不必要的依赖项。
仍然可能对https://www.toolsqa.com/selenium-cucumber-framework/page-object-design-pattern-with-selenium-pagefactory-in-cucumber/有所帮助

s4chpxco

s4chpxco2#

在示例化过程中, cucumber 不能初始化Selify类。因此,我建议您删除此类初始化。
它也解决了我的问题。
您需要替换以下行:私有字符串loginPassrod=“test@test.test”;&写为:私有字符串loginPassrod;&根据您的需要在任何方法中初始化该字符串。

ozxc1zmp

ozxc1zmp3#

调用PageFactory initElements方法时,您的驱动程序未初始化。如下所示更新AuthPage构造器可能会解决您的问题。

public AuthPage() {
    super.setup();
    TestBase.onMainPage();
    PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(TestBase.driver)), this);
}

相关问题