I am trying to launch the Appium programmatically for my automation framework.
As soon as Appium is launched though code, the Appium driver fails consistently.
Below is the code for Appium launch:
String appiumPath = Joiner.on(File. separator ).join("/", “Applications”, “Appium.app”, “Contents”,“Resources”,“app”,“node_modules”,“appium”,“build”,“lib”,“main.js”);
String nodePath = Joiner.on(File. separator ).join("/", “usr”, “local”, “bin”,“node”);
if(!checkIfServerisRunning(4723)) {
service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodePath))
.withAppiumJS(new File(appiumPath))
.withIPAddress(“127.0.0.1”)
.usingPort(4723)
*.withLogFile(new File("***txt"))
service.start();
}
This returns a 200 response.
However once the capabilities are loaded and the driver(AppiumDriver) is initialized,
driver = new AppiumDriver<>(new URL(service.getUrl().toString()), capabilities);
or
driver = new AppiumDriver<>(
new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
this always give me an error as below:
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘WASD17791’, ip: ‘2600:8806:105:ad00:0:0:0:1a99%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘11.0.11’
Driver info: driver.version: AppiumDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
at getResponseForW3CError (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)
}
Can you please help me with this?