Andoid Appium coding examples

Hi Friends,

I set up the environment, Appium for Android and done some positive flows for apps.

Now i want to learn framework so i need your help friends kindly help me and suggest any websites/tutorials for learning process.

Thanks in Advance

1 Like

You can check for frameworks.

Appium is independent of frameworks

Hi @amitjaincoer191 in toolsqa NO frameworks for Appium.

I already said Frameworks are independent of Appium / Selenium.

Hi @amitjaincoer191 thank you and sry am not noticed tat

@amitjaincoer191 hi how to handle listview/dropdown in app ?? kindly hlp me

from above screenshot i want to click and select the India (+91).

After click on Country(id: text_country_name) pop up open with the list of Country now i want to select Country India from this list (id:rl_row_countryname)

Kindly help me out

how to write code or take xpath for this ??

can you post ui automator screenshot of this view ?

Hi @amitjaincoer191 Ya sure kindly find the below screenshot from UI Automator

Screenshot 2: Country list view. Here i have to select country from Netherland to India.

And also please tell how to take XPATH in appium @amitjaincoer191

Thanks and am awaiting for your reply.

1 Like


Here you can select country using following xpath :


Above is xpath to select country India , you can replace country name as per your need.

So it will be driver.findElement(By.xpath("//android.widget.TextView[@text=‘India’]"));

Hope this help you…

Hi @iRANG_QA Thanks for ur reply but its not working yar :worried:

Shows below error:

org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 31 milliseconds

UI Automator won’t find elements that are not displayed on screen. You have to scroll to it.

Tried this is working for me. So here It will start scrolling until given country “Malta” is not found and once found it will be clicked and scrolling loop will be closed. This is tested code, it should work.

public void HandlingScrollonList() throws InterruptedException{

	System.out.println("Clicking " + _driver.findElement(By.xpath("(//android.widget.TextView)[2]")).getAttribute("name"));
	List <WebElement> elem = _driver.findElements(By.xpath("(//android.widget.TextView)"));
	System.out.println("elem.size()  " + elem.size());
	System.out.println("elem.get(1).getLocation().getX()  " + elem.get(1).getLocation().getX() + 
					   "  elem.get(1).getLocation().getY()  " + elem.get(1).getLocation().getY());	
	System.out.println("elem.get(elem.size()-1).getLocation().getX()  " + elem.get(elem.size()-2).getLocation().getX() +
					   "  elem.get(elem.size()-1).getLocation().getY()  " + elem.get(elem.size()-2).getLocation().getY());
	int x1 = elem.get(1).getLocation().getX();
	int y1 = elem.get(1).getLocation().getY();
	int x2 = elem.get(elem.size()-1).getLocation().getX();
	int y2 = elem.get(elem.size()-1).getLocation().getY();
	TouchAction tAction=new TouchAction(_driver);
	do  {

	if (_driver.findElements("Malta (+356)")).size()>0)
		_driver.findElement("Malta (+356)")).click();
	} while (_driver.findElements("Malta (+356)")).size()==0);

Hi @amitjaincoer191 : :worried: not working am getting below error amit. how it is working for u ??

FAILED CONFIGURATION: @AfterMethod afterMethod
org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 29 milliseconds

can u pls share source code. find the below scrnshot, asks drivr to mobile driver suggestion box.

ok @Alexis can u suggest how to do

Java client 3.1 if u r using it will work…
With 3.1 android/appium driver classes are changed …
So change java client do driver declaration in right way it will work …

As I said it is working on my machine that’s why I passed code to u …

so now what can i do ?? kindly explain what i have to install/import

Just download java_client3-1.jar from maven repository… Remove older version of jar from ecllipse build path … and add new one … It will ask to change declaration of

driver=new AndroidDriver();
Then that touch actions error will go…

Hi @amitjaincoer191 Find the below source code and say what issue is there

configured build path with java client 3.1 as u said refer below scrnshot

package Amzn;

import io.appium.java_client.TouchAction;

import java.util.List;
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.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;

public class Chillitalk {
static AndroidDriver driver;

public void beforeMethod() throws Exception {

	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("automationName", "Selendroid");
	capabilities.setCapability("deviceName", "HT42FWE01991"); /*HTC Mobile*/
	capabilities.setCapability("platformVersion", "5.0.1");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("app", app.getAbsolutePath());
	capabilities.setCapability("appPackage", "");

	driver = new AndroidDriver<>(new URL(""), capabilities);
	driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

public void login() throws Exception 

//Here i pasted your given code



kindly help me and sorry to disturb u @amitjaincoer191 . am getting below error.

If you have declared Android Driver correctly then it should work.
Also I suggest you to use selendroid server stand alone 2.46 as newer version like 2.47.1 may have some issues.
Can you join me at “amitjics” on skype. As I had written code base on u r app, so it should work.

k ll cme on Skype. Inbx me whn u free