Appium无法启动新会话求助:NoSuchMethodError报错未解决
Appium Android自动化测试无法启动新会话问题求助
使用环境:
- Appium v2.0.0-beta.66
- Selenium 4.11.0
- TestNG 7.4.0
- Windows 11 64位
- Java 18.0.1.1
执行Android自动化测试时,无法启动新会话,报错日志如下:
[RemoteTestNG] detected TestNG version 7.4.0 [Configuration] [WARN] Detected a static method [BaseTR.TestEngineTR.startSuite()]. Static configuration methods can cause unexpected behavior. Aug 17, 2023 4:32:05 PM BaseTR.TestEngineTR startSuite INFO: Properties file loaded successfully Aug 17, 2023 4:32:05 PM BaseTR.TestEngineTR startSuite INFO: Intializing extent Reports Aug 17, 2023 4:32:05 PM BaseTR.TestEngineTR startSuite INFO: Extent report is available under the same directoryC:\Users\subhashini_r\eclipse-workspace\DemoNewPOM\Reports\testReport.html SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. [35m[Appium][39m Welcome to Appium v2.0.0-beta.66 [35m[Appium][39m Non-default server args: [35m[Appium][39m { address: [32m'127.0.0.1'[39m, localTimezone: [33mtrue[39m } [35m[Appium][39m Attempting to load driver uiautomator2... [debug] [35m[Appium][39m Requiring driver at C:\Users\\.appium\node_modules\appium-uiautomator2-driver [35m[Appium][39m Appium REST http interface listener started on 127.0.0.1:4723 [35m[Appium][39m Available drivers: [35m[Appium][39m - uiautomator2@2.18.0 (automationName 'UiAutomator2') [35m[Appium][39m No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [38;5;0m[HTTP][0m [37m-->[39m [37mGET[39m [37m/status[39m [38;5;0m[HTTP][0m [90m{}[39m [debug] [38;5;16m[AppiumDriver@da8a][0m Calling AppiumDriver.getStatus() with args: [] [debug] [38;5;16m[AppiumDriver@da8a][0m Responding to client with driver.getStatus() result: {"build":{"version":"2.0.0-beta.66"}} [38;5;0m[HTTP][0m [37m<-- GET /status [39m[32m200[39m [90m5 ms - 47[39m [38;5;0m[HTTP][0m [90m[39m FAILED: configureAppium org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: '', ip: '' Build info: version: '4.11.0', revision: '040bc5406b' System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1.1' Driver info: io.appium.java_client.android.AndroidDriver Command: [null, newSession {capabilities=[{appium:deviceName="Pixel2API33", platformName=ANDROID, appium:automationName=UIAutomator2, appium:app=C:\Users\subhashini_r\eclipse-workspace\DemoNewPOM\src\test\resources\General-Store.apk}], desiredCapabilities=Capabilities {appium:app: C:\Users\sc\eclip..., appium:automationName: UIAutomator2, appium:deviceName: "Pixel2API33", platformName: ANDROID}}] Capabilities {appium:app: C:\Users\s\eclip..., appium:automationName: UIAutomator2, appium:deviceName: "Pixel2API33", platformName: ANDROID} at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:159) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89) at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101) at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:113) at BaseTR.TestEngineTR.configureAppium(TestEngineTR.java:211) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:794) at org.testng.TestRunner.run(TestRunner.java:596) at org.testng.SuiteRunner.runTest(SuiteRunner.java:377) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332) at org.testng.SuiteRunner.run(SuiteRunner.java:276) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212) at org.testng.TestNG.runSuitesLocally(TestNG.java:1134) at org.testng.TestNG.runSuites(TestNG.java:1063) at org.testng.TestNG.run(TestNG.java:1031) 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.NoSuchMethodError: 'java.lang.String org.openqa.selenium.json.Json.toJson(java.lang.Object, int)' at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:126) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:111) at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:105) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:101) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:182) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518) ... 32 more =============================================== Default test Tests run: 1, Failures: 1, Skips: 0 =============================================== =============================================== Default suite Total tests run: 1, Passes: 0, Failures: 1, Skips: 0 ===============================================
已尝试的解决方式:
- 修改过Appium服务端口
- 参考过相关问题的讨论内容,但问题仍未解决
求助内容:
希望能得到解决该问题的方法,同时想了解这类问题是否已有成熟的解决方案。
内容的提问来源于stack exchange,提问作者Subhashini Ramanathan
相关产品推荐
相关产品推荐

