0

I have list of elements of specific type, I want to swipe one of this element right or left, How i can do this using appium ?
I know i can use driver.Swipe(); to swipe in appium but how to use to swipe specific element ?
My list of elements is
var contacts = driver.FindElements(By.ClassName("android.widget.ImageView")); contacts[7].Click();
How can I swipe element contacts[7] to right or left?

1

The code below is taken from the test suite for the Appium C# bindings. Basically, you use the element's coordinates as a starting point for the swipe. The only thing you need to know is the target coordinates for the swipe. Of course, if you just want to swipe in a specific direction you can hardcode the coordinates.

[Test ()]
public void ComplexTouchActionTestCase ()
{
    IList<AppiumWebElement> els = driver.FindElementsByClassName ("android.widget.TextView");
    var loc1 = els [7].Location;
    AppiumWebElement target = els[1];
    var loc2 = target.Location;
    driver.Swipe (loc1.X, loc1.Y, loc2.X, loc2.Y, 800); //this action includes almost all touch actions
    Assert.AreNotEqual(loc2.Y, target.Location.Y);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.