Code:
public class AppDAta {
public static URL url;
public static DesiredCapabilities capabilities;
public static AndroidDriver<AndroidElement> driver;
//1
@Test
public void setupAppium() throws MalformedURLException {
//2
final String URL_STRING = “http://127.0.0.1:4723/wd/hub”;
url = new URL(“http://127.0.0.1:4723/wd/hub”);
//3
DesiredCapabilities cap= new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “Nexus_4_API_27”);
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, “android”);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “3.6.0”);
cap.setCapability(MobileCapabilityType.APP, “/Users/uss/Desktop/untitled folder/Appium/src/main/java/Appium/ApiDemos-debug.apk”);
cap.setCapability(MobileCapabilityType.NO_RESET, true);
// cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, “XCUITest”);
cap.setCapability(“useNewWDA”, false);
//4
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(url, cap);
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
//driver.resetApp();
}
}
Getting this type of error in console:
FAILED: setupAppium
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb’ in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the corect Android SDK root directory path.
Build info: version: ‘3.6.0’, revision: ‘6fbf3ec767’, time: ‘2017-09-27T15:28:36.4Z’
System info: host: ‘tests-Mac-mini.local’, ip: ‘fe80:0:0:0:431:f1c:51d3:566a%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.13.6’, java.version: ‘1.8.0_111’
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb’ in PATH. Please set the ANDROID_HOME or ANDROID_SDK_ROOT environment variables to the corect Android SDK root directory path.
Source: Read More