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

AppiumDriverLocalService on java-client 8.0.0 not working #1658

Closed rishikhanna1401 closed 1 year ago

rishikhanna1401 commented 2 years ago

While trying to programmatically open appium server using java-client 8.0.0 I see below error msg:

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/bin/appium Arguments: [/usr/local/lib/node_modules/appium/lib/appium.js, --port, 18384, --address, 0.0.0.0] Process output: usage: /usr/local/lib/node_modules/appium/build/lib/main.js [-h] [–shell] [–allow-cors] [–reboot] [–ipa IPA] [-a ADDRESS] [-p PORT] [-pa BASEPATH] [-ka KEEPALIVETIMEOUT] [-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT] [-r BACKENDRETRIES] [–session-override] [-l] [-g LOGFILE] [–log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}] [–log-timestamp] [–local-timezone] [–log-no-colors] [-G WEBHOOK] [–safari] [–default-device] [–force-iphone] [–force-ipad] [–tracetemplate AUTOMATIONTRACETEMPLATEPATH] [–instruments INSTRUMENTSPATH] [–nodeconfig NODECONFIG] [-ra ROBOTADDRESS] [-rp ROBOTPORT] [–chromedriver-executable CHROMEDRIVEREXECUTABLE] [–show-config] [–no-perms-check] [–strict-caps] [–isolate-sim-device] [–tmp TMPDIR] [–trace-dir TRACEDIR] [–debug-log-spacing] [–suppress-adb-kill-server] [–long-stacktrace] [–webkit-debug-proxy-port WEBKITDEBUGPROXYPORT] [–webdriveragent-port WDALOCALPORT] [-dc DEFAULTCAPABILITIES] [–relaxed-security] [–allow-insecure ALLOWINSECURE] [–deny-insecure DENYINSECURE] [–command-timeout DEFAULTCOMMANDTIMEOUT] [-k] [–platform-name PLATFORMNAME] [–platform-version PLATFORMVERSION] [–automation-name AUTOMATIONNAME] [–device-name DEVICENAME] [–browser-name BROWSERNAME] [–app APP] [-lt LAUNCHTIMEOUT] [–language LANGUAGE] [–locale LOCALE] [-U UDID] [–orientation ORIENTATION] [–no-reset] [–full-reset] [–app-pkg APPPACKAGE] [–app-activity APPACTIVITY] [–app-wait-package APPWAITPACKAGE] [–app-wait-activity APPWAITACTIVITY] [–device-ready-timeout DEVICEREADYTIMEOUT] [–android-coverage ANDROIDCOVERAGE] [–avd AVD] [–avd-args AVDARGS] [–use-keystore] [–keystore-path KEYSTOREPATH] [–keystore-password KEYSTOREPASSWORD] [–key-alias KEYALIAS] [–key-password KEYPASSWORD] [–intent-action INTENTACTION] [–intent-category INTENTCATEGORY] [–intent-flags INTENTFLAGS] [–intent-args OPTIONALINTENTARGUMENTS] [–dont-stop-app-on-reset] [–calendar-format CALENDARFORMAT] [–native-instruments-lib] [–keep-keychains] [–localizable-strings-dir LOCALIZABLESTRINGSDIR] [–show-ios-log] [–async-trace] [–chromedriver-port CHROMEDRIVERPORT] [–log-filters LOGFILTERS] [-v] /usr/local/lib/node_modules/appium/build/lib/main.js: error: unrecognized arguments: /usr/local/lib/node_modules/appium/lib/appium.js

Sample Start-up code(worked on java-client 8.0.0-beta version):

service = AppiumDriverLocalService .buildService(new AppiumServiceBuilder() .usingDriverExecutable(new File("/usr/local/bin/appium")) .withAppiumJS( new File( “/usr/local/lib/node_modules/appium/lib/appium.js”)) .usingPort(port)); service.start();

Appium Version Used: 1.20.0 and 1.22.0 Xcode Version: 13.2.1 npm:8.3.2 Node: v17.3.1

jamespizzurro commented 2 years ago

I'm also seeing this issue. Here's the code that was working prior to upgrading to 8.0.0 using the same version of Appium (1.22.3):

new AppiumServiceBuilder()
    .withAppiumJS(new File(System.getenv("APPIUM_PATH")))
    .withArgument(GeneralServerFlag.LOG_LEVEL, debugMode ? "debug" : "error")
    .withArgument(GeneralServerFlag.ALLOW_INSECURE, "chromedriver_autodownload")
    .withIPAddress("127.0.0.1")
    .usingAnyFreePort()
    .withCapabilities(capabilities, true)
    .withTimeout(Duration.ofSeconds(300))
    .build()
    .start();

Appium Server: v1.22.3 Appium Java client: 8.0.0 Xcode: v13.3 (13E113) npm: v6.14.13 Node: v14.17.0

jamespizzurro commented 2 years ago

@rishikhanna1401 The workaround posted by @cmaganu in Issue #1636 fixed this issue for me: https://github.com/appium/java-client/issues/1636#issuecomment-1075324178

new AppiumServiceBuilder()
    .withAppiumJS(new File(System.getenv("APPIUM_PATH")))
    .withArgument(GeneralServerFlag.LOG_LEVEL, debugMode ? "debug" : "error")
    .withArgument(GeneralServerFlag.ALLOW_INSECURE, "chromedriver_autodownload")
    .withIPAddress("127.0.0.1")
    .usingAnyFreePort()
    .withArgument(GeneralServerFlag.BASEPATH, "/wd/hub/")
    .withCapabilities(capabilities, true)
    .build()
    .start();
Dor-bl commented 1 year ago

@mykola-mokhnach, I assume this can be closed since appium server 1 is deprecated

mykola-mokhnach commented 1 year ago

@mykola-mokhnach, I assume this can be closed since appium server 1 is deprecated

Most likely yes