Instantly share code, notes, and snippets.

View AppiumTests.cs
[TestMethod]
public void TapTest()
{
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("android:id/content");
Point point = element.Coordinates.LocationInDom;
touchAction.Tap(point.X, point.Y, 2).Perform();
}
View AppiumTests.cs
[TestMethod]
public void MoveToTest()
{
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("android:id/content");
Point point = element.Coordinates.LocationInDom;
touchAction.MoveTo(point.X, point.Y).Perform();
}
View AppiumTests.cs
[TestMethod]
public void SwipeTest()
{
_driver.StartActivity("io.appium.android.apis", ".graphics.FingerPaint");
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("android:id/content");
Point point = element.Coordinates.LocationInDom;
Size size = element.Size;
touchAction
.Press(point.X + 5, point.Y + 5)
View AppiumTests.cs
[TestMethod]
public void LocatingElementInsideAnotherElementTest()
{
var mainElement = _driver.FindElementById("decor_content_parent");
var button = mainElement.FindElementById("button");
button.Click();
var checkBox = mainElement.FindElementByClassName("android.widget.CheckBox");
checkBox.Click();
View AppiumTests.cs
[TestMethod]
public void LocatingElementsTest()
{
AndroidElement button = _driver.FindElementById("button");
button.Click();
AndroidElement checkBox = _driver.FindElementByClassName("android.widget.CheckBox");
checkBox.Click();
AndroidElement secondButton = _driver.FindElementByAndroidUIAutomator("new UiSelector().textContains(\"BUTTO\");");
View AppiumTests.cs
string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
var appiumOptions = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1");
appiumOptions.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".ApiDemos");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.App, testAppPath);
View AppiumTests.cs
private static AndroidDriver<AndroidElement> _driver;
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
string testAppPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", "ApiDemos-debug.apk");
var desiredCaps = new AppiumOptions();
desiredCaps.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android_Accelerated_x86_Oreo");
desiredCaps.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis");
desiredCaps.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
View AppiumTests.cs
[TestMethod]
public void TapTest()
{
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("IntegerA");
Point point = element.Coordinates.LocationInDom;
touchAction.Tap(point.X, point.Y, 2).Perform();
}
View AppiumTests.cs
[TestMethod]
public void MoveToTest()
{
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("IntegerA");
Point point = element.Coordinates.LocationInDom;
touchAction.MoveTo(point.X, point.Y).Perform();
}
View AppiumTests.cs
[TestMethod]
public void SwipeTest()
{
ITouchAction touchAction = new TouchAction(_driver);
var element = _driver.FindElementById("IntegerA");
Point point = element.Coordinates.LocationInDom;
Size size = element.Size;
touchAction
.Press(point.X + 5, point.Y + 5)