Appium Tutorials - Select Radio Button Of Android App

Selecting radio button of android software app in appium automation test is same action as selecting check-box as described in my Earlier article. Only difference between check-box selection and radio button selection is you can select only one radio button at a time from given list of radio buttons but you can select all check-box from given list. So it is easy to select radio button of any android software app using appium automation test. Let's take simple example to understand how to select radio button of android app In appium software automation test.

App To Use And Aim To Achieve In Appium Test
We will use API Demos app In this appium software automation test to learn how to select radio button of android app as shown in bellow given screenshot.

appium select radio button of android app

Manually you can go to above screen from API Demos app's Home -> Views -> Controls -> 2. Dark Theme.

Create And Run Test
Create and bellow given radio button selection appium test in eclipse.
package Android;

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;

public class SelectingRadioButton {
 AndroidDriver driver;

 public void setUp() throws Exception {
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability("deviceName", "ZX1B32FFXF");
  capabilities.setCapability("browserName", "Android");
  capabilities.setCapability("platformVersion", "4.4.2");
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("appPackage", "");
  driver = new AndroidDriver(new URL(""), capabilities);
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

 public void select() throws InterruptedException {
  // Scroll till element which contains "Views" text If It Is not visible on screen.
  // Click on Views.
  // Scroll till element which contains "Controls" text If It Is not visible on screen.
  // Click on Controls.
  // Scroll till element which contains "2. Dark Theme" text If It Is not visible on screen.
  driver.scrollTo("2. Dark Theme");
  // Click on 2. Dark Theme.
  driver.findElement("2. Dark Theme")).click();
  // Click on RadioButton 2 to select it.
  driver.findElement("RadioButton 2")).click();

 public void End() {

Run above test in eclipse using testng and appium and observe execution in android mobile screen. Last syntax in @Test method will select radio button.

This way you can select radio button of any android app using appium software automation test.

No comments:

Post a Comment