appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 759 forks source link

bug: Java Client 8 can't connect to local Appium 2 server #1909

Open MSlaski opened 1 year ago

MSlaski commented 1 year ago

Is there an existing issue for this?

Current Behavior

After migration from Appium 1 to Appium 2 (also Selenium 3 to Selenium 4) all my tests are not working. The issue is related to connection from java client to local Appium server

Java code is returning error:

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: 'POLO-1357.lan', ip: 'fe80:0:0:0:1835:b628:a560:a83b%en0'

Server is not logging anything from this test Im starting server via CLI: appium server --address 127.0.0.1 --port 4723 --allow-cors *I know that the port 4723 is a default one so can be omitted

When I will call simple GET /status or /sessions I can reach response from my local server:

[HTTP] --> GET /status
[HTTP] {}
[debug] [AppiumDriver@53b3] Calling AppiumDriver.getStatus() with args: []
[debug] [AppiumDriver@53b3] Responding to client with driver.getStatus() result: {"build":{"version":"2.0.0-beta.66"}}
[HTTP] <-- GET /status 304 3 ms - -
[HTTP]
[HTTP] --> GET /status
[HTTP] {}
[debug] [AppiumDriver@53b3] Calling AppiumDriver.getStatus() with args: []
[debug] [AppiumDriver@53b3] Responding to client with driver.getStatus() result: {"build":{"version":"2.0.0-beta.66"}}
[HTTP] <-- GET /status 304 1 ms - -
[HTTP]
[HTTP] --> GET /sessions
[HTTP] {}
[debug] [AppiumDriver@53b3] Calling AppiumDriver.getSessions() with args: []
[debug] [AppiumDriver@53b3] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /sessions 304 2 ms - -

Im trying to run test on real iOS Device (which was used by Appium 1 already - so was working before the upgrade)

Driver Initialisation:

        XCUITestOptions options = new XCUITestOptions();
        options.setPlatformName(Platform.IOS.name());
        options.setPlatformVersion(device.getPlatformVersion());
        options.setDeviceName(device.getName());
        options.setUdid(device.getUdid());
        options.setBundleId("MY_BUNDLE_ID");
        options.setXcodeCertificate(new XcodeCertificate("GY9QC33CMS", "Apple Development"));
        options.setAutomationName(AutomationName.IOS_XCUI_TEST);
        options.setIncludeSafariInWebviews(true);

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

When Im trying to use Appium Inspector it is possible to attach to the device but first, I have to run WebDriverAgentRunner application on my iOS Device, without that it will not work. Even when WDA Runner was launched and Im trying to start tests, the connection is still not working.

My Pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>GROUP_ID</groupId>
    <artifactId>Integration_Tests</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.version>3.3.10</serenity.version>
        <cucumber.version>7.11.0</cucumber.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <byte-buddy.version>1.11.9</byte-buddy.version>
        <rest-assured.version>5.1.1</rest-assured.version>
        <maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
        <selenium.version>4.5.2</selenium.version>
        <aspectj.version>1.9.6</aspectj.version>
        <appium.version>8.2.0</appium.version>
        <java-jwt.version>3.19.2</java-jwt.version>
        <allure-maven.version>2.10.0</allure-maven.version>
        <slf4j-simple.version>1.7.32</slf4j-simple.version>
        <junit.version>4.13.2</junit.version>
        <assertj.version>3.20.2</assertj.version>
        <lombok.version>1.18.20</lombok.version>
        <json-simple.version>1.1.1</json-simple.version>
        <gson.version>2.8.7</gson.version>
        <allure.version>2.22.0</allure.version>
        <jackson.version>2.12.4</jackson.version>
        <ashot.version>1.5.4</ashot.version>
        <google-zxing.version>3.3.0</google-zxing.version>
        <maven-assembly-plugin.version>2.3</maven-assembly-plugin.version>
        <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
        <webdriver-manager.version>5.3.0</webdriver-manager.version>
        <jgit.version>6.3.0.202209071007-r</jgit.version>
        <!-- Spring - CallbackService -->
        <spring.boot.version>2.5.4</spring.boot.version>
        <tomcat.embed.version>9.0.52</tomcat.embed.version>
        <spring.web.version>5.3.9</spring.web.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>software.amazon.awssdk</groupId>
                <artifactId>bom</artifactId>
                <version>2.17.46</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-cucumber</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${rest-assured.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>json-path</artifactId>
            <version>${rest-assured.version}</version>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>xml-path</artifactId>
            <version>${rest-assured.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j-simple.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
<!--        Choose one if possible and remove other one -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>${json-simple.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-cucumber7-jvm</artifactId>
            <version>${allure.version}</version>
        </dependency>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-rest-assured</artifactId>
            <version>${allure.version}</version>
        </dependency>
        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>${allure-maven.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>ru.yandex.qatools.ashot</groupId>
            <artifactId>ashot</artifactId>
            <version>${ashot.version}</version>
        </dependency>
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>${appium.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-remote-driver</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-support</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>${google-zxing.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
            <version>${google-zxing.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>${maven-assembly-plugin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>${java-jwt.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>${webdriver-manager.version}</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>sso</artifactId>
            <version>2.17.46</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jgit</groupId>
            <artifactId>org.eclipse.jgit</artifactId>
            <version>${jgit.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.web.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring.boot.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>logback-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>${tomcat.embed.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.web.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-spring</artifactId>
            <version>3.2.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.8.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>io.qameta.allure</groupId>
                <artifactId>allure-maven</artifactId>
                <version>${allure-maven.version}</version>
                <configuration>
                    <reportVersion>2.18.0</reportVersion>
                    <installDirectory>${basedir}/target</installDirectory>
                    <allureDownloadUrl>
                        https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.18.0/allure-commandline-2.18.0.zip
                    </allureDownloadUrl>
                    <resultsDirectory>${basedir}/target/report/allure-results</resultsDirectory>
                    <reportDirectory>${basedir}/target/allure-report</reportDirectory>
                    <inputDirectories>${basedir}/target/report/allure-results</inputDirectories>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                        -Dcucumber.options="--plugin io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm"
                    </argLine>
<!--                    <rerunFailingTestsCount>1</rerunFailingTestsCount>-->
                    <systemPropertyVariables>
                        <allure.results.directory>target/report/allure-results
                        </allure.results.directory>
                    </systemPropertyVariables>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.version}</version>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven-assembly-plugin.version}</version>
                <configuration>
                    <descriptor>src/main/assembly/assembly.xml</descriptor>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <archive>
                                <manifest>
                                    <mainClass>com.idemia.pivt.TestRunner</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/test/resources</directory>
            </resource>
        </resources>
    </build>
</project>

I tried many things and always failed to run some tests. The same for Android Device and also regular Selenium Driver is not starting any browser. At the moment the most important thing is to fix Appium to unblock native mobile tests

BR Mateusz

PS Im not able to register or login to discuss Appium forum. All options are not working for me (email, GitHub, google) that's why Im asking for support here

Expected Behavior

Java-client 8 can connect to local Appium server 2

Minimal Reproducible Example

Already put at actual behaviour section

Environment

Link to Appium Logs

No response

Futher Information

No response

jlipps commented 1 year ago

Please include the full Appium log from startup?

MSlaski commented 1 year ago

@jlipps

╭─name@PC.lan ~
╰─➤  appium server --address 127.0.0.1 --port 4723 --allow-cors
[Appium] Welcome to Appium v2.0.0-beta.66
[Appium] Non-default server args:
[Appium] {
[Appium]   address: '127.0.0.1',
[Appium]   allowCors: true
[Appium] }
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /Users/mateusla/.appium/node_modules/appium-uiautomator2-driver
reusing global emitter
[Appium] Attempting to load driver xcuitest...
[debug] [Appium] Requiring driver at /Users/mateusla/.appium/node_modules/appium-xcuitest-driver
[Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[Appium] Available drivers:
[Appium]   - uiautomator2@2.24.0 (automationName 'UiAutomator2')
[Appium]   - xcuitest@4.26.0 (automationName 'XCUITest')
[Appium] Available plugins:
[Appium]   - execute-driver@2.0.6
[Appium]   - relaxed-caps@1.0.5
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
jlipps commented 1 year ago

It doesn't seem that any connections are hitting this server at all. Does your test script have the correct host and port listed?

MSlaski commented 1 year ago

Yup, it should use correct values. Again, Driver initialisation:

        XCUITestOptions options = new XCUITestOptions();
        options.setPlatformName(Platform.IOS.name());
        options.setPlatformVersion(device.getPlatformVersion());
        options.setDeviceName(device.getName());
        options.setUdid(device.getUdid());
        options.setBundleId("MY_BUNDLE_ID");
        options.setXcodeCertificate(new XcodeCertificate("GY9QC33CMS", "Apple Development"));
        options.setAutomationName(AutomationName.IOS_XCUI_TEST);
        options.setIncludeSafariInWebviews(true);

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

As you can see the URL is 127.0.0.1 with port 4723

saikrishna321 commented 1 year ago

@MSlaski Do you see any errors on the client side?

MSlaski commented 1 year ago

Full stack trace paste below.

I made few more tests now. Start Appium server (same way like mentioned above). Tried to connect via Appium Inspector - it failed with error code 70. WDA can't start. I install new WDA Runner via Xcode directly on the device and Trust the developer

After that (Automation was not running) I was able to connect to device via Appium Inspector. When I closed connection I tired to run test and it failed

Definition.userCanOpenApplication(com.idemia.pivt.helpers.MobileDevice)
      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: 'POLO-1357.lan', ip: 'fe80:0:0:0:1835:b628:a560:a83b%en0'
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
        at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
        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 com.idemia.pivt.step_definitions_mobile_native.ScanQrCodeStepDefinition.userCanOpenApplication(ScanQrCodeStepDefinition.java:46)
        at ✽.user can open application on device IP13(file:///Users/mateusla/Work/Repos/pivt-integration-tests/pivt-bdd-tests/src/test/resources/features/id&v_native_front_or_back_page.feature:8)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '4.5.3', revision: '4b786a1e430'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '11.3', java.version: '11.0.11'
Driver info: driver.version: IOSDriver
        at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:130)
        at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102)
        at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:155)
        at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:189)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:541)
        at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:229)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
        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 com.idemia.pivt.step_definitions_mobile_native.ScanQrCodeStepDefinition.userCanOpenApplication(ScanQrCodeStepDefinition.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
        at io.cucumber.java.Invoker.invoke(Invoker.java:24)
        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:85)
        at io.cucumber.core.runner.TestStep.run(TestStep.java:57)
        at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
        at io.cucumber.core.runner.TestCase.run(TestCase.java:84)
        at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
        at io.cucumber.junit.PickleRunners$NoStepDescriptions.lambda$run$0(PickleRunners.java:151)
        at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:129)
        at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
        at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:129)
        at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:148)
        at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:144)
        at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:28)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at io.cucumber.junit.FeatureRunner.run(FeatureRunner.java:137)
        at io.cucumber.junit.CucumberSerenityRunner.runChild(CucumberSerenityRunner.java:259)
        at io.cucumber.junit.CucumberSerenityRunner.runChild(CucumberSerenityRunner.java:59)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at io.cucumber.junit.CucumberSerenityRunner$RunCucumber.evaluate(CucumberSerenityRunner.java:288)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
        at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
        at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
        at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
        at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
        at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:188)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:154)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:128)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
        at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:126)
        ... 74 more
Caused by: java.lang.NoClassDefFoundError: io/netty/handler/codec/DefaultHeaders$ValueValidator
        at org.asynchttpclient.RequestBuilderBase.<init>(RequestBuilderBase.java:98)
        at org.asynchttpclient.RequestBuilderBase.<init>(RequestBuilderBase.java:92)
        at org.asynchttpclient.RequestBuilder.<init>(RequestBuilder.java:35)
        at org.asynchttpclient.RequestBuilder.<init>(RequestBuilder.java:31)
        at org.asynchttpclient.Dsl.request(Dsl.java:73)
        at org.openqa.selenium.remote.http.netty.NettyMessages.toNettyRequest(NettyMessages.java:58)
        at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:56)
        at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
        at io.appium.java_client.remote.AppiumCommandExecutor.lambda$createSession$0(AppiumCommandExecutor.java:158)
        at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
        at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
        at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
        at io.appium.java_client.remote.AppiumCommandExecutor.lambda$createSession$0(AppiumCommandExecutor.java:158)
        at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
        at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:120)
        ... 79 more
Caused by: java.lang.ClassNotFoundException: io.netty.handler.codec.DefaultHeaders$ValueValidator
        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:522)
        ... 95 more
jlipps commented 1 year ago

no clue then. the issue is not with the appium server so i'm out of ideas. seems like a client side issue somehow.

MSlaski commented 1 year ago

I also tried at different device, the same issue. Appium inspector is able to connect, java-client not

saikrishna321 commented 1 year ago

This is a dependency conflict issue. Please use java-client version 8.5.0 and let it download all the required selenium dependencies.

MSlaski commented 1 year ago

Hello @saikrishna321 Unfortunately it's still the same issue. java-client upgraded to 8.5.0, selenium-java to 4.9.1

 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: 'POLO-1384.local', ip: 'fe80:0:0:0:10fa:c52b:fed1:94b7%en0'
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:561)
        at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
        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.ios.IOSDriver.<init>(IOSDriver.java:104)
appium server --address 127.0.0.1 --allow-cors
[Appium] Welcome to Appium v2.0.0-beta.66
[Appium] Non-default server args:
[Appium] {
[Appium]   address: '127.0.0.1',
[Appium]   allowCors: true
[Appium] }
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /Users/mateusla/.appium/node_modules/appium-uiautomator2-driver
reusing global emitter
[Appium] Attempting to load driver xcuitest...
[debug] [Appium] Requiring driver at /Users/mateusla/.appium/node_modules/appium-xcuitest-driver
[Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[Appium] Available drivers:
[Appium]   - uiautomator2@2.24.0 (automationName 'UiAutomator2')
[Appium]   - xcuitest@4.26.0 (automationName 'XCUITest')
[Appium] Available plugins:
[Appium]   - execute-driver@2.0.6
[Appium]   - relaxed-caps@1.0.5
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
mykola-mokhnach commented 1 year ago

Host info: host: 'POLO-1384.local', ip: 'fe80:0:0:0:10fa:c52b:fed1:94b7%en0'

address: '127.0.0.1',

Maybe the client tries to connect to ipv6 address while the server is only listening on ipv4 one?

MSlaski commented 1 year ago

@mykola-mokhnach do you know how to verify that?

During Driver initialisation Im providing IPv4 address. I checked also help for Appium server and didn't find anything related to IPv4 or IPv6

jlipps commented 1 year ago

if you start the appium server with -a 0.0.0.0 does it help?

MSlaski commented 1 year ago

@jlipps Same when I tried yo use address 0.0.0.0 - for both server and Driver initialisation :/

jlipps commented 1 year ago

@MSlaski don't use it in driver initialization. Only in server.

MSlaski commented 1 year ago

@jlipps Unfortunately it is still not working. server started with -a 0.0.0.0. Java Client can't connect. Also tried with Appium Inspector and using address 127.0.0.1 I was able to connect to device so still the same issue

jlipps commented 1 year ago

k sounds like it's a java client issue then, which I can't help with.

shilpiad commented 1 year ago

hi I am also facing the same with appium 2,did we have any solution for this

sandipchopkar95 commented 1 year ago

I also faced it, i just deleted the selenium dependency and update maven project now it is working for me. and all selenium classes, methods i got from java client 8.5.0

shilpiad commented 1 year ago

Oh ya, updated the selenium dependency to latest and java client as well,It worked,Thanks

AlllxT commented 1 year ago

The same issue for me with java-client 8.5.1 and selenium 4.11.0... if I remove selenium dependency -> then test is working with appium 2 server. If selenium dependecy is present -> org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

upd:

you should do like this:

    <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>4.11.0</version>
        </dependency>
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>8.5.1</version>
        </dependency>

it will work