Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Created July 15, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/603b373439b92e03e859252ff4b013bd to your computer and use it in GitHub Desktop.
Save nadvolod/603b373439b92e03e859252ff4b013bd to your computer and use it in GitHub Desktop.
Setting up Android capabilities for a real device test in Sauce Labs
var capabilities = new AppiumOptions();
//We can run on any version of the platform as long as it's the correct device
//Make sure to pick an Android or iOS device based on your app
capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Google Pixel 4");
capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
//make sure you set locale as sometimes it opens in a different location and throws off locations
capabilities.AddAdditionalCapability("locale", "en");
capabilities.AddAdditionalCapability("language", "en");
//The next major version of Appium (2.x) will **require** this capability
capabilities.AddAdditionalCapability("automationName", "UiAutomator2");
//It's a good practice to set an appWaitActivity so that the automation knows when the app is loaded
capabilities.AddAdditionalCapability("appWaitActivity", "com.swaglabsmobileapp.MainActivity");
//It's a good practice to use the latest appium version
capabilities.AddAdditionalCapability("appiumVersion", "1.17.1");
/*
* !!!!!!
* TODO first you must upload an app to RDC so that you get your app key
* Then, make sure you can hardcode it here just to get started
*/
capabilities.AddAdditionalCapability("testobject_api_key", new ApiKeys().Rdc.Apps.SampleAppAndroid);
capabilities.AddAdditionalCapability("name", TestContext.CurrentContext.Test.Name);
//It's important to keep the newCommandTimeout on the higher end as Real Devices are slow
capabilities.AddAdditionalCapability("newCommandTimeout", 180);
_driver = new AndroidDriver<AndroidElement>(new Uri(RdcUsHubUrl), capabilities);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment