I am unable to get Appium to start an Android session and did not find anything related to the error message I am getting when I searched online.
When I run my test Appi
@Dave Thomas, hi.
Considering official spec says that
I think You should dig into capabilities set-up.
Let me share piece of code that might be helpful for You:
package io.mytestproject.appium.tests;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.testproject.appium.pom.tests.pages.LoginPage;
import io.testproject.appium.pom.tests.pages.ProfilePage;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
public class PositiveLoginTest {
private final static String APP_PACKAGE_NAME = "io.mytestproject.demo";
private final static String APP_ACTIVITY_NAME = ".MainActivity";
public void setup() throws Exception {
// Prepare Appium session
DesiredCapabilities capabilities = DesiredCapabilities.android();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
capabilities.setCapability(MobileCapabilityType.UDID, "YOUR_DEVICE_UDID");
capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, APP_PACKAGE_NAME);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, APP_ACTIVITY_NAME);
// Initialize driver
AndroidDriver driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
...... }
}
Please also see this article to understand the difference between web and mobile test automation drivers and corresponding capabilities.
And also, providing the whole listing of Appium Desired Capabilities
Hope this helps for You, Regards, Eugene
Replace ApplicationName> Absolute to either App or (appPackage and appActivity)
//Either add following line in the DesiredCapabilities
capabilities.setCapability(MobileCapabilityType.App, "Path to your apk file");
//OR add following two capabilities if the app is already installed in the testing device
capabilities.setCapability("appPackage", "app package name");
capabilities.setCapability("appActivity, "app activity name");