appium / java-client

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

Failed to start local Appium server #1906

Closed RameshBabuPrudhvi closed 1 year ago

RameshBabuPrudhvi commented 1 year ago

Description

Failed to start Local Appium Server using AppiumDriverLocalService

Environment

C:\Users\bramesh>appium driver list --installed √ Listing installed drivers

Details

Unable to start Appium Local Server using java. Appium java Client Version - 8.4.0

Code To Reproduce Issue [ Good To Have ]

    void startLocalServer() {
        try {
            var reportsPath = ofNullable(ConfigFactory.getConfig().getReports())
                    .map(reports -> reports.get("reportsPath")).orElse("target");
            var logFilePath = Path.of(reportsPath, "appium-server.log");
            service = new AppiumServiceBuilder()
                    .withIPAddress("127.0.0.1")
                    .usingAnyFreePort()
                    .withArgument(GeneralServerFlag.SESSION_OVERRIDE)
                    .withArgument(GeneralServerFlag.BASEPATH, "/wd/")
                    .withLogFile(logFilePath.toFile())
                    .build();
            logger.info(() -> "Starting Appium server...");
            service.start();
        } catch (Exception e) {
            throw new DriverConnectionException("Failed starting Appium Server..", e);
        }
    }

Exception Stacktraces

Please create a gist with the pasted stacktrace of the exception thrown by java.

Link To Appium Logs

[Appium] Welcome to Appium v2.0.0-beta.64 [Appium] Non-default server args: [Appium] { address: '127.0.0.1', basePath: '/wd/', port: 17977, sessionOverride: true } [Appium] Attempting to load driver windows... [debug] [Appium] Requiring driver at C:\Users\bramesh.appium\node_modules\appium-windows-driver [Appium] Attempting to load driver uiautomator2... [debug] [Appium] Requiring driver at C:\Users\bramesh.appium\node_modules\appium-uiautomator2-driver 05/07/2023 01:14:31 - [DEBUG] - [io.github.selcukes.core.listener.ResourceCleanupProvider.afterTest:55] - Cleanup Test Resource...

io.github.selcukes.commons.exception.DriverConnectionException: Failed starting Appium Server..

at io.github.selcukes.core.driver.AppiumEngine.startLocalServer(AppiumEngine.java:62)
at io.github.selcukes.core.driver.AppiumEngine.getServiceUrl(AppiumEngine.java:42)
at io.github.selcukes.core.driver.DesktopManager.getServiceUrl(DesktopManager.java:48)
at io.github.selcukes.core.driver.DesktopManager.createDriver(DesktopManager.java:39)
at io.github.selcukes.core.driver.DriverFactory.create(DriverFactory.java:74)
at io.github.selcukes.core.driver.DriverManager.createDevice(DriverManager.java:90)
at io.github.selcukes.core.driver.DriverManager.createDriver(DriverManager.java:58)
at io.github.selcukes.core.page.Pages.winPage(Pages.java:34)
at io.github.selcukes.core.tests.win.NotepadTest.notepadTest(NotepadTest.java:32)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

Caused by: io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\bramesh\AppData\Roaming\npm\node_modules\appium\build\lib\main.js, --port, 17977, --address, 127.0.0.1, --base-path, /wd/, --session-override] Process output: [Appium] Welcome to Appium v2.0.0-beta.64 [Appium] Non-default server args: [Appium] { address: '127.0.0.1', basePath: '/wd/', port: 17977, sessionOverride: true } [Appium] Attempting to load driver windows... [debug] [Appium] Requiring driver at C:\Users\bramesh.appium\node_modules\appium-windows-driver [Appium] Attempting to load driver uiautomator2... [debug] [Appium] Requiring driver at C:\Users\bramesh.appium\node_modules\appium-uiautomator2-driver

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:182)
at io.github.selcukes.core.driver.AppiumEngine.startLocalServer(AppiumEngine.java:60)
... 35 more

Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://127.0.0.1:17977/wd/status] to be available after 20005 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:89) at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:147) at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:169) ... 36 more Caused by: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204) at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:87) ... 38 more

05/07/2023 01:14:31 - [DEBUG] - [io.github.selcukes.testng.listeners.TestListener.onFinish:30] - workspace Execution finished... 05/07/2023 01:14:31 - [INFO] - [io.github.selcukes.core.driver.AppiumEngine.stopServer:69] - Stopped Appium server... 05/07/2023 01:14:31 - [DEBUG] - [io.github.selcukes.core.listener.ResourceCleanupProvider.afterSuite:40] - Test Suite Execution finished...

RameshBabuPrudhvi commented 1 year ago

Issue could not be reproduced, therefore it is being closed. https://github.com/selcukes/selcukes-java-skeleton/actions/runs/4906692593/jobs/8761311348?pr=98