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

Unable to start service using AppiumDriverLocalService.buildService(builder) #1924

Open manivannan-r opened 1 year ago

manivannan-r commented 1 year ago

Description

Unable to start appium server programmatically, using AppiumDriverLocalService. I'm able to start appium via commandline.

Environment

APPIUM JAVA CLIENT : 8.5.0 APPIUM SERVER : 2.0.0-beta.71 NODE : v20.2.0 NPM : v9.6.6 OS : macOS Monterey (V 2.6.5 (21G531)) Chip : Apple M1 Pro

Code To Reproduce Issue

AppiumDriverLocalService service;
        AppiumServiceBuilder builder = new AppiumServiceBuilder();
        builder.withIPAddress(CommonUtil.getLocalIPAddress());
        builder.usingAnyFreePort();
//      builder.usingDriverExecutable(new File("/usr/local/bin/node"));
        builder.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));
//      builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
//      builder.withArgument(() -> GeneralServerFlag.BASEPATH.getArgument(), "/wd/hub");
                service = AppiumDriverLocalService.buildService(builder);
                service.start();

Exception

/usr/local/lib/node_modules/appium/node_modules/sharp/lib/sharp.js:37
  throw new Error(help.join('\n'));
        ^
Error: 
Something went wrong installing the "sharp" module

dlopen(/usr/local/lib/node_modules/appium/node_modules/sharp/build/Release/sharp-darwin-x64.node, 0x0001): symbol not found in flat namespace (__ZTVN4vips7VOptionE)

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current darwin-x64 runtime: "npm install --platform=darwin --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/sharp/lib/sharp.js:37:9)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/sharp/lib/constructor.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/sharp/lib/index.js:6:15)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
Exception in thread "main" io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 4723, --address, 0.0.0.0] 
Process output: 
/usr/local/lib/node_modules/appium/node_modules/sharp/lib/sharp.js:37
  throw new Error(help.join('\n'));
        ^
Error: 
mseremin commented 1 year ago

Did you solve this problem?

monushhmohan commented 1 year ago

Hi Mani,

Have you got a solution to issue yet?

I have facing exact issue whilst trying to automate handling appium server to start and stop.

Thanks

ashwithpoojary98 commented 1 year ago

@manivannan-r uninstall Appium and install the latest version of Appium(Try homebrew)