How can I click on Text link inside of TextView (Android)

Hi Aleksei!

How can i click on those links one by one as it doesn’t have any id’s
please help me how to resolve it.
Thanks in advance.

@Prashanth try on same screen:

  1. switch to webview
  2. print “driver.getPageSource()”. publish it and give us a link

@Prashanth if you use latest appium 1.6.5+ just log:


latest appium can switch to webView itself. if not i will show how to do it later…

I am using (Ohpiuchus) and i have windows 8.1 don’t have mac to upgrade to latest appium version

you do not need mac :-). to install latest appium in windows you need:

  1. install nodeJS ->
  2. in command prompt execute:
npm install -g appium@beta

although it’s beta - it has tons of improvements. if you doubt you can install previours like:

npm install -g [email protected]

now all is needed to start appium on windows PC is in command line execute “appium” :slight_smile:

Ok i will try it. and let you know.

it prints the page source as below how can i find elements to click on those links please help me.

<?xml version="1.0" encoding="UTF-8"?>

Hi VolodymyrGlushkov,
Can you please share me your code to click on Text link inside a TextView. Im facing similar kind of issue, i tried with below snippet. It doesnt work.

Element = Please click on the Our website using ‘Click here’
locator id = com.demoApp.sampleDemoApplication:id/text_title

*Click here has the link, which i need to click on from script.

Point point = element.getLocation();
size = getIOSDriver().manage().window().getSize();
int x = point.x + 1;
int y = point.y + element.getSize().getHeight() - 1;
TouchAction touchAction = new TouchAction(getIOSDriver());
touchAction.tap(x, y).perform();

Much appreciated for your response.

How to do driver.tap ?
do I need to use touchActions?

@Priya_Khiwal tons of examples :- >

AndroidDriver, where does this come from? I am not able to resolve this dependency…

Right from java client ->

@Aleksei tap method could not be found using driver.tap and also referred the one which you had posted here still no luck.
Tried below code,
Getting error --> org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.

Point center1 = driver.findElementById("new_order").getCenter();
TouchAction startStop = new TouchAction(driver)
            .tap(point(center1.x, center1.y))
            .tap(element(driver.findElementById("new_order"), 5, 5));//Getting error here

visit need to click. The entire TextView id is “new_order”
To place a new order, visit

1 Like

removed first answer.

update code to something like:

        MobileElement el = (MobileElement) driver.findElementById("new_order");
        Point center = el.getCenter();
        TouchAction startStop = new TouchAction(driver)
                .tap(point(center.x + (el.getSize().width / 2) - 5, center.y)); // where -5 is to avoid el right border

check that “el” will be found

@Aleksei Thanks it’s working on pixel 2 device1. i hope it will work on all device sizes.
And also two more question . 1.How did you calculate that it should be -5?
2. How to make it work when we have more than one clickable link like one mentioned by Prashanth

  1. you can replace -5 to some % as something in example of @mykola-mokhnach.
    • in mine example right part is: + width / 2 - 5px.
    • in mykola’s: el.left.x + width * %. where % from 0 to 100%. i suggest use 90% (based on your screenshot)
  2. improve given tap example with giving not only X offset but Y offset also.

What if the clickable text is dynamic(sometimes first line and sometimes second line) and in the middle of string…How can we make it work?
Like, say Example: “place a new order, with XYZ.”

Hi Aleksei,

I tried the way but tap is not being performed. I have used Google_Pixel_real device

MobileElement el = (MobileElement) driver.findElement(By.xpath("//*[contains(@text,‘Details’)]"));
Point center = el.getCenter();
TouchAction startStop = new TouchAction(driver)
.tap(point(center.x + (el.getSize().width / 2) - 5, center.y)); // where -5 is to avoid el right border

can you please let me know are we able to click as clickable is false but enabled is true.

If so, Please let me know what to change here for x and y coordinates.

  1. Enable on phone in developer menu show touches! Now we will start seeing where tap actually happen.
  2. in your code you trying to tap 100% in wrong place. You tap between text lines in left part of found element. but you need to tap into low bottom of element Y with some offset from left. so you can test it with code like:
        MobileElement el = (MobileElement) driver.findElement(By.xpath("//*[contains(@text,‘Details’)]"));
        for (int step = 5; step <= el.getSize().width; step = step + 5) {
            System.out.println("step: '" + step + "'");
            PointOption pointOption = new PointOption()
                    .withCoordinates(el.getLocation().x + step, el.getLocation().y - 10); // you can change '10' do any value that better fit
            new TouchAction(driver).tap(pointOption).perform();
            try {
                Thread.sleep(5000); // 5 sec wait to see if tap happened and 'Details' link pressed
            } catch (Exception ignored) {