Appium - 无法在 iPad 上启动新会话

问题描述 投票:0回答:1

我正在尝试在真正的 iPad 设备上自动化 iOS 应用程序。我的代码直到上周都工作正常,从今天开始突然开始抛出错误。

Xcode
nodejs
java
Appium
均未升级。没有更新任何代码。

public AppiumDriver runOnRealDevice() {
        try {
            XCUITestOptions options = new XCUITestOptions();
            options.setDeviceName("my iPad");
            options.setPlatformVersion("16.5.1");
            options.setWdaLaunchTimeout(Duration.ofSeconds(20));
            options.setCapability("xcodeOrgId","......");
            options.setCapability("xcodeSigningId","iPhone Developer");
            options.setCapability("udid","......");
            driver = new IOSDriver(new URL("http://127.0.0.1:4723/"),options);
            
            driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(15));
            Map<String,String> params = new HashMap<String,String>();
            params.put("bundleId", "com.myapplebundleidentfier");
            driver.executeScript("mobile:launchApp",params);
        }catch (Exception e) {
            System.out.println("Here12 "+e.getLocalizedMessage());
            e.printStackTrace();
        }
        return driver;
    }

问题发生在

driver = new IOSDriver(new URL("http://127.0.0.1:4723/"),options);

以下是完整的错误信息

StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: '-MacBook-Air.local', ip: 'fe80:0:0:0:1044:a4fe:6300:fc53%en0'
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '13.4.1', java.version: '17.0.6'
Driver info: io.appium.java_client.ios.IOSDriver
Command: [null, newSession {capabilities=[{appium:udid=myudid, appium:xcodeOrgId=myxoceorgid, appium:wdaLaunchTimeout=20000, appium:xcodeSigningId=iPhone Developer, appium:deviceName=iPad, platformName=IOS, appium:automationName=XCuiTest, appium:platformVersion=16.5.1}], desiredCapabilities=Capabilities {appium:automationName: XCuiTest, appium:deviceName: Pritish’s iPad, appium:platformVersion: 16.5.1, appium:udid:dsssddsdssd, appium:wdaLaunchTimeout: 20000, appium:xcodeOrgId: dsdsdsdsdssd, appium:xcodeSigningId: iPhone Developer, platformName: IOS}}]
Capabilities {appium:automationName: XCuiTest, appium:deviceName: my iPad, appium:platformVersion: 16.5.1, appium:udid: sddsdsdsds, appium:wdaLaunchTimeout: 20000, appium:xcodeOrgId: ddsds, appium:xcodeSigningId: iPhone Developer, platformName: IOS}
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
    at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:159)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:92)
    at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:106)
    at WebPortal.IOSBaseTest.runOnRealDevice(IOSBaseTest.java:66)
    at WebPortal.IOSBaseTest.setup(IOSBaseTest.java:32)
    at WebPortal.IOSBaseTest.getDriver(IOSBaseTest.java:25)
    at stepDefinitions.TA124_ComprehensiveCI_StepDefinitions.<init>(TA124_ComprehensiveCI_StepDefinitions.java:36)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at io.cucumber.core.runtime.ObjectFactoryServiceLoader$DefaultJavaObjectFactory.cacheNewInstance(ObjectFactoryServiceLoader.java:141)
    at io.cucumber.core.runtime.ObjectFactoryServiceLoader$DefaultJavaObjectFactory.getInstance(ObjectFactoryServiceLoader.java:133)
    at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
    at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
    at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
    at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
    at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
    at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
    at io.cucumber.core.runner.TestStep.run(TestStep.java:64)
    at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
    at io.cucumber.core.runner.TestCase.run(TestCase.java:104)
    at io.cucumber.core.runner.Runner.runPickle(Runner.java:73)
    at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
    at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
    at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
    at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:200)
    at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
    at io.cucumber.core.cli.Main.run(Main.java:92)
    at cucumber.api.cli.Main.run(Main.java:30)
    at cucumber.api.cli.Main.main(Main.java:15)
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:194)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
    ... 48 more
java ios ipad automation appium
1个回答
0
投票
Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.openqa.selenium.json.Json.toJson(java.lang.Object, int)'

这应该意味着您的代码或您正在使用的库之一正在尝试调用当前加载的库版本中不存在的方法。当库版本不匹配时,经常会看到此错误。

由于您没有更改代码,并且Appium和其他工具的版本相同,因此您可能无意中更新了一些库。检查您的项目的依赖项(库/jar)是否一致且兼容。

  • 如果您使用 Maven,请检查您的
    pom.xml
    文件。
  • 如果您使用 Gradle,请检查您的
    build.gradle
    文件。

如果您的项目源代码使用 Git,

git status
应该有助于可视化任何更改。

确保Appium的Java客户端和Selenium的Java客户端版本兼容。

尝试清除缓存并重新安装依赖项。

  • 如果使用 Maven:
mvn clean install
  • 如果使用 Gradle:
./gradlew clean build

如果您仅在依赖项管理工具中指定 Appium Java 客户端,请尝试显式指定兼容的 Selenium 版本(请参阅兼容性矩阵)。 Appium的客户端对Selenium有依赖,版本之间可能存在兼容性问题。

另请检查您设备的操作系统版本是否已更新,这可能会影响 Appium 的行为。

© www.soinside.com 2019 - 2024. All rights reserved.