- Mar 30, 2018
- admin
- 0
Connect the Android device to Appium Studio
Here are the steps to follow to Connect Android Device to Appium Studio.
In Appium Studio go to Device tab.
Click the Add Device icon and select Android from the drop-down list.
If no Android device is detected, a pop-up window will appear offering several USB drivers links for download.
Once the USB driver is installed, repeat step (1).
A pop-up will appear and you will then see the serial number of the Android device.
You can choose in which orientation the device will be open:
a. Auto-Rotate – the device will open according to its real condition and orientation will change automatically if you move the device
b. Portrait.
c. Landscape.
Name the device, and then click on the “OK” button.
The selected device will appear in the “Device” list.
Open Device
Select the device and click the Open Device icon (check that its status changes from Ready to Open).
The device’s reflection should then appear on your desktop.
Test Automation Solution
- For Android devices, make below changes to App.config
<add key=”executionOS” value=”Android” />
<!–Set Capabilities common to Android devices–>
<add key=”androidDevice” value=”Android” />
<add key=”androidPlatformName” value=”Android” />
<add key=“androidDeviceName“ value=“SM-A710F“ />
<add key=“androidPlatformVersion“ value=“7.0“ />
<add key=“androidUdid“ value=“3300777fcc472399“/>
//Read the device info from App.Config file and set the capabilities
public static AppiumDriver<IWebElement> InitializeNewDriverInstance()
{
DesiredCapabilities cap = new DesiredCapabilities();
string capabilitySetting = string.Empty;
if (isInitialize)
return Instance;
try
{
if (executionOS == “Android”)
{
EventYear = ConfigurationManager.AppSettings.Get(“EventYear”);
cap.SetCapability(“device”, ConfigurationManager.AppSettings.Get(“androidDevice”));
cap.SetCapability(“deviceName”, ConfigurationManager.AppSettings.Get(“androidDeviceName”));
cap.SetCapability(“platformName”, ConfigurationManager.AppSettings.Get(“androidPlatformName”));
cap.SetCapability(“platformVersion”, ConfigurationManager.AppSettings.Get(“androidPlatformVersion”));
cap.SetCapability(CapabilityType.BrowserName, “Chrome”);
//cap.SetCapability(CapabilityType.BrowserName, “WebView Browser Tester”);
cap.SetCapability(MobileCapabilityType.NewCommandTimeout, 180);
//cap.SetCapability(MobileCapabilityType.NoReset, false);
cap.SetCapability(“unicodeKeyboard”, true);
cap.SetCapability(“resetKeyboard”, true);
cap.SetCapability(“instrumentApp”, true); //Added to hadle webviews
string str = null;
string[] strArr = null;
str = ConfigurationManager.AppSettings.Get(“androidPlatformVersion”);
char[] splitchar = { ‘.’ };
strArr = str.Split(splitchar);
int majorVersionNumber = Int32.Parse(strArr[0]);
if (majorVersionNumber >= 7)
{
var proc = new Process();
proc.StartInfo.FileName = ConfigurationManager.AppSettings.Get(“adb”);
proc.StartInfo.Arguments = “uninstall io.appium.settings”;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string outPut = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
var exitCode = proc.ExitCode;
proc.Close();
proc.StartInfo.Arguments = “uninstall io.appium.unlock”;
proc.Start();
outPut = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
exitCode = proc.ExitCode;
proc.Close();
}
Instance = new AndroidDriver<IWebElement>(new Uri(“http://127.0.0.1:4723/wd/hub”), cap, TimeSpan.FromSeconds(840));
Instance.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 0, 30);
//Instance.Navigate().GoToUrl(ConfigurationManager.AppSettings.Get(“URL”));
Instance.Navigate().GoToUrl(ConfigurationManager.AppSettings.Get(“URL”));
isInitialize = true;
ConfigureIOC(Platform.Android);
return Instance;
}
Read about how to connect iOS device to Appium Studio