Search code examples
javaiosipadautomationappium

Appium - Could not start a new session on iPad


I am trying to automate iOS app on real iPad device. My code was working fine till last week and suddenly started throwing error from today. Neither Xcode, nodejs, java or Appium has been upgraded. No code has been updated whatsoever.

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;
    }

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

Below is the complete error message

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

Solution

  • I managed to resolve my issue by removing following dependency

    <dependency>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-devtools</artifactId>
                <version>4.0.0-beta-4</version>
            </dependency>