Appium - Android App Spinner Value Selection Example

Spinner Is a drop downward In android software native app where yous can pick out Item from the drib downward list equally per your requirement. Spinner can bring scroll If listing Is large together with also It tin give notice bring scroll If at that spot are solely few Items In drib downward list. Appium software automation tool support scrollTo component to scroll at your desired Item. In this example, We volition larn how to scroll downward In spinner list Items of android software app together with and hence how to pick out Item from spinner list using appium software automation test.

App Used For Android Spinner Test
We bring to use API Demos android software app for this bear witness together with yous tin give notice downloading API Demos android software app from HERE. You require to Install API Demos app In your android device.

Aim To Active In Spinner Test
We wants to scroll downward In Planet spinner listing together with and hence pick out Item "Pluto" from the listing equally shown In bellow Image. Earlier nosotros already learnt how to scroll downward using scrollTo() method In THIS EXAMPLE. We volition role same method hither to scroll downward In spinner list.


Manually yous tin give notice navigate to to a higher house hide from API Demos software app -> Tap on Views -> And together with hence tap on Spinner.

Create And Run Appium Test For Spinner
Create novel bear witness file Spinner.java under Android packet of projection In eclipse together with write bellow given android appium bear witness script In It.

Spinner.java
package Android;  import io.appium.java_client.android.AndroidDriver; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;  populace shape Spinner {  AndroidDriver driver;    @BeforeTest  populace 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  populace void selectPlanetValue() {   // Scroll till chemical component which contains "Views" text.   driver.scrollTo("Views");   // Click on Views.   driver.findElement(By.name("Views")).click();   // Scroll till chemical component which contains "Spinner" text.   driver.scrollTo("Spinner");   // Click on chemical component which contains "Spinner" text.   driver.findElement(By.name("Spinner")).click();   //Find raise chemical component of Planet drib downward to uniquely Identify It's shaver drib down.   WebElement ele = driver.findElementById("io.appium.android.apis:id/spinner2");   //Click on Planet drib downward to opened upward drib downward list.   ele.findElement(By.id("android:id/text1")).click();   // Scroll till chemical component which contains "Pluto" text In drib downward list.   driver.scrollTo("Pluto");   //Select "Pluto" from drib downward listing Items.   driver.findElementByName("Pluto").click();  }   @AfterTest  populace void End() {   driver.quit();  } }

Spinner Test Description
Spinner software automation bear witness Is real uncomplicated together with at 1 time to empathise If yous bring read my all previous android appium examples. When yous live to a higher house bear witness In eclipse,
  • First It volition navigate to Spinners screen.
  • Then locate raise of Planet spinner.
  • Using raise reference, It volition locate planet spinner together with click on It.
  • Then It volition scroll downward In spinner list
  • And select "Pluto" from list.
This Is the agency to handgrip spinner In android appium test.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post