Android Native element functions / classes Appium

Scroll on element

// Scroll on the dropdown
driver.findElementByAndroidUIAutomator("new UiScrollable(new
UiSelector()).scrollIntoView(text(\"Argentina\"));");
driver.findElementByAndroidUIAutomator("new UiScrollable(new
UiSelector()).scrollIntoView(text(\"Argentina\"));");

// if above does not work
driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new
UiSelector()).scrollable(true).instance(0)).scrollIntoView(new
UiSelector().textMatches(\"Argentina\"));))"));
driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new
UiSelector().scrollable(true).instance(0)).scrollIntoView(new
UiSelector().textMatches(\"Argentina\").instance(0))"));
driver.findElement(By.xpath("//span[contains(text(),'Argentina')]")).click();


// toast message pop up message
// Standard toast message xpath for any apps
driver.findElement(By.id("com.androidsample.generalstore:id/btnLetsShop")).click();


// gettng pop up message
String message =
driver.findElement(By.xpath("//android.widget.Toast[1]")).getAttribute("name");



// Scroll from page to particular element by name
driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().resourceId(\"com.androidsample.generalstore:id/rvProductList\")).scrollIntoView(new UiSelector().textMatches(\"Jordan Lift Off\").instance(0))"));
int totalItems = driver.findElements(By.id("com.androidsample.generalstore:id/productName")).size();

for (int i = 0; i < totalItems; i++)

{

String text = driver.findElements(By.id("com.androidsample.generalstore:id/productName")).get(i).getText();

if (text.equalsIgnoreCase("Jordan Lift Off"))

{

driver.findElements(By.id("com.androidsample.generalstore:id/productAddCart")).get(i).click();

break;

}

}

Comments

Popular posts from this blog

Inspect iOS app using Appium Inspector

How to Upload a file to S3 Bucket on AWS using JAVA