BrowserStack App Automate enables you to test native and hybrid mobile applications using Appium automation framework. Its easy to run your Appium tests written in C# on real Android and iOS devices on BrowserStack. This guide will help you get started with your first test.
username
and access key
. To obtain your access credentials, sign up for a free trial or purchase a plan..apk
or .aab
file) or an iOS app (.ipa
file).apk
or .ipa
file and are looking to simply try App Automate, you can download and test using our sample Android app or sample iOS app.
Upload your Android app (.apk
or .aab
file) or iOS app (.ipa
file) to BrowserStack servers using our REST API. Here is an example cURL
request to upload the app :
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
-F "file=@/path/to/app/file/Application-debug.apk"
A sample response for the above request is shown below:
{
"app_url":"bs://j3c874f21852ba57957a3fdc33f47514288c4ba4"
}
Note the value of app_url
returned in the API response (bs://j3c874f21852b.....
in the above example).
This value will be used later to set the app
capability to specify application under test in your Appium test scripts.
cURL
command until you get the response back.In this step, you will learn how to configure your Appium test script using desired capabilities to test remotely on BrowserStack’s real device cloud. You will need to make the following changes in your C# test script :
app
capability.
Use the app_url
value returned at the time of app upload (Step 2) to set this capability.device
capability. https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub
If you are using our Sample App, the sample test below will install the Sample App (Wikipedia App) on the device, search for ‘browserstack’ and asserts for the list of results. If you are using your own app, modify the code as per your test cases. Copy the code below into your editor, and run the test from the command-line interface.
using System;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using System.Collections.Generic;
namespace BrowserStackAppiumSingleTest
{
class MainClass
{
readonly static string userName = "YOUR_USERNAME";
readonly static string accessKey = "YOUR_ACCESS_KEY";
public static void Main(string[] args)
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("browserstack.user", userName);
caps.SetCapability("browserstack.key", accessKey);
caps.SetCapability("device", "Google Pixel 3");
caps.SetCapability("app", "<app_url>");
AndroidDriver<AndroidElement> driver = new AndroidDriver< AndroidElement >(new Uri("https://hub-cloud.browserstack.com/wd/hub"), caps);
AndroidElement searchElement = (AndroidElement)new WebDriverWait(driver,TimeSpan.FromSeconds(30)).Until(
ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))
);
searchElement.Click();
AndroidElement insertTextElement = (AndroidElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
ExpectedConditions.ElementToBeClickable(MobileBy.Id("org.wikipedia.alpha:id/search_src_text"))
);
insertTextElement.SendKeys("BrowserStack");
System.Threading.Thread.Sleep(5000);
IReadOnlyList<AndroidElement > allTextViewElements = driver.FindElementsByClassName("android.widget.TextView");
Console.WriteLine(allTextViewElements.Count > 0);
driver.Quit();
}
}
}
If you are using our iOS Sample App, the sample test below will install the Sample App (BStackSample App) on the device, navigate to the Login screen, enters the login email and check whether the email is registered on WordPress. If you are using your own app, modify the code as per your test cases. Copy the code below into your editor, and run the test from the command-line interface.
using System;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;
using System.Collections.Generic;
namespace BrowserStackAppiumSingleTest
{
class MainClass
{
readonly static string userName = "YOUR_USERNAME";
readonly static string accessKey = "YOUR_ACCESS_KEY";
public static void Main(string[] args)
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("browserstack.user", userName);
caps.SetCapability("browserstack.key", accessKey);
caps.SetCapability("device", "iPhone 11 Pro");
caps.SetCapability("app", "<app_url>");
IOSDriver driver = new IOSDriver (new Uri("https://hub-cloud.browserstack.com/wd/hub"), caps);
IOSElement textButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))
);
textButton.Click();
IOSElement textInput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))
);
textInput.SendKeys("hello@browserstack.com");
IOSElement textOutput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(
ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))
);
Assert.AreEqual(textOutput.Text,"hello@browserstack.com");
driver.Quit();
}
}
}
You can access results of your test sessions on the App Automate dashboard as well as using our REST API. You can drill down into the details of a specific test session to view its execution details and debugging information such as video recording, network logs and device logs.
Contact our Support team for immediate help while we work on improving our docs.
Contact our Support team for immediate help while we work on improving our docs.