info:检测到的方言:w3c[utils][error][error]java.lang.nullpointerexception

oyxsuwqo  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(231)

我试图运行这个代码,但它不会运行。。。它只是显示了一个错误信息:detected dialect:w3c[utils][error][error]java.lang.nullpointerexception请帮助我提供您的有效建议我已经发布了我的runner类文件以及控制台错误代码以供您澄清
跑步者等级:

package tR;
    import java.io.IOException;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.annotations.AfterClass;
    import org.testng.annotations.BeforeClass;
    import org.testng.annotations.DataProvider;
    import org.testng.annotations.Test;
    import cucumber.api.testng.CucumberFeatureWrapper;
    import cucumber.api.testng.TestNGCucumberRunner;
    import io.cucumber.testng.CucumberOptions;
    @CucumberOptions(
    features = "Feature/result.feature",
    glue={"sD"})
    public class Tr {
        private TestNGCucumberRunner testNGCucumberRunner;
        public static WebDriver driver;
        public static void openBrowser() throws Exception {
            System.setProperty("webdriver.chrome.driver","E:\\xxxxxx\\xx\\chromedriver.exe");
            driver = new ChromeDriver();}
        @BeforeClass(alwaysRun = true)
        public void setUpClass() throws Exception {
           openBrowser();
           testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());}
        @Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
        public void feature(CucumberFeatureWrapper cucumberFeature) throws IOException{
        testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());}
        @DataProvider
        public Object[][] features() {
        return testNGCucumberRunner.provideFeatures();}
        @AfterClass(alwaysRun=true)
        public void tearDownClass() throws Exception {
        testNGCucumberRunner.finish();
        }}

慰问

org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[Utils] [ERROR] [Error] java.lang.NullPointerException
    at tR.Tr.features(Tr.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:77)
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:46)
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:146)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:820)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:762)
    at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60)
    at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39)
    at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771)
    at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.util.ArrayList.forEach(Unknown Source)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

FAILED CONFIGURATION: @BeforeClass setUpClass
java.lang.NoClassDefFoundError: io/cucumber/stepexpression/TypeRegistry
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.getConstructor(Unknown Source)
    at cucumber.runtime.Reflections.hasConstructor(Reflections.java:53)
    at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:29)
    at cucumber.runtime.Runtime.loadBackends(Runtime.java:99)
    at cucumber.runtime.Runtime.<init>(Runtime.java:66)
    at cucumber.api.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:42)
    at tR.Tr.setUpClass(Tr.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
    at java.util.ArrayList.forEach(Unknown Source)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: io.cucumber.stepexpression.TypeRegistry
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 36 more

FAILED CONFIGURATION: @AfterClass tearDownClass
java.lang.NullPointerException
    at tR.Tr.tearDownClass(Tr.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
    at org.testng.internal.TestMethodWorker.invokeAfterClassMethods(TestMethodWorker.java:217)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:130)
    at java.util.ArrayList.forEach(Unknown Source)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

SKIPPED: feature
         Runs Cucumber Feature
java.lang.RuntimeException: java.lang.NullPointerException
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:50)
    at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:146)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:820)
    at org.testng.internal.Parameters.handleParameters(Parameters.java:762)
    at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60)
    at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39)
    at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771)
    at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.util.ArrayList.forEach(Unknown Source)
    at org.testng.TestRunner.privateRun(TestRunner.java:770)
    at org.testng.TestRunner.run(TestRunner.java:591)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
    at org.testng.SuiteRunner.run(SuiteRunner.java:304)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
    at org.testng.TestNG.runSuites(TestNG.java:1032)
    at org.testng.TestNG.run(TestNG.java:1000)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.NullPointerException
    at tR.Tr.features(Tr.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:77)
    at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:46)
    ... 25 more
3yhwsihp

3yhwsihp1#

第一条信息:检测到的方言:w3c只是关于chrome正在使用的方言(w3c或oss)的信息。尝试使用更新的selenium和testng依赖项。

java.lang.NullPointerException is usually caused when you try to use a reference that points to no location in memory (null) as though it were referencing an object. Calling a method on a null reference or trying to access a field of a null reference will trigger a NullPointerException.(https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it)

相关问题