Expandable List
import java.net.URL;
import java.util.List;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Example10ExpandableList {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
DesiredCapabilities dc= new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "Android"); //Android Emulator
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.1");
//when we ara working on multiple apps we can just copy these lines of command only thing we need to change is apk file location thats it
dc.setCapability(MobileCapabilityType.APP, "C:\\apkfiles\\ApiDemos.apk");
URL url =new URL("http://127.0.0.1:4723/wd/hub");
AndroidDriver
//******* above code copied from previous program
//below ode will click on views
driver.findElementsById("android:id/text1").get(10).click();
//below cmd will click on Expandable Lists as i notices that Expandable list has 8th index and id as android:id/text1
driver.findElementsById("android:id/text1").get(8).click();
//try accesability id
driver.findElementByAccessibilityId("1. Custom Adapter").click();
//People Names
List
for(WebElement e:val){
String t=e.getText();
if(t.equalsIgnoreCase("People Names")){
e.click();
}
}
//we can write a command to find all the objects in the page with the same classname
Thread.sleep(9500);
driver.quit();
}
}