Retrieving all values from drib downwards listing of android app software inwards appium software automation examination is footling tricky chore but non hard. You tin sack thought how to SELECT VALUE from drib downwards list's popup inwards appium test. We tin sack use findElements() method of selenium webdriver to locate together with larn all values from drib downwards list.
Aim Of Test And App To Use
Our primary aim is to shop all values from drib downwards listing of android software application. We volition piece of job API Demos app inwards this android software automation test.
Manually y'all tin sack thought higher upward covert from API Demos app's Home -> Views -> Controls -> 2. Dark Theme. -> Tap on Drop Down.
Created really uncomplicated software automation examination to larn all values from drib downwards of android application.
GetDropDownList.java
package Android; import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; world cast GetDropDownList { AndroidDriver driver; @BeforeTest world void setUp() throws Exception { DesiredCapabilities capabilities = novel DesiredCapabilities(); capabilities.setCapability("deviceName", "ZX1B32FFXF"); capabilities.setCapability("browserName", "Android"); capabilities.setCapability("platformVersion", "4.4.2"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("appPackage", "io.appium.android.apis"); capabilities.setCapability("appActivity","io.appium.android.apis.ApiDemos"); driver = novel AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); } @Test world void select() throws InterruptedException { // Scroll till chemical gene which contains "Views" text If It Is non visible on screen. driver.scrollTo("Views"); // Click on Views. driver.findElement(By.name("Views")).click(); // Scroll till chemical gene which contains "Controls" text If It Is non visible on screen. driver.scrollTo("Controls"); // Click on Controls. driver.findElement(By.name("Controls")).click(); // Scroll till chemical gene which contains "2. Dark Theme" text If It Is non visible on screen. driver.scrollTo("2. Dark Theme"); // Click on 2. Dark Theme. driver.findElement(By.name("2. Dark Theme")).click(); // Typing inwards text box using sendKeys command. driver.findElement(By.id("io.appium.android.apis:id/edit")).sendKeys("Test"); //To cover keyboard driver.hideKeyboard(); //Click on dropdown to opened upward list. driver.findElement(By.id("android:id/text1")).click(); //Locate all drib downwards listing elements List dropList = driver.findElements(By.id("android:id/text1")); //Extract text from each chemical gene of drib downwards listing i past times one. for(int i=0; i< dropList.size(); i++){ MobileElement listItem = (MobileElement) dropList.get(i); System.out.println(listItem.getText()); } } @AfterTest world void End() { driver.quit(); } }
Run higher upward android software automation examination using appium to run into how to larn all values from drib downwards list. It volition impress all values inwards console.