# How to click a link inside a textview?

**URL:** <https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368>\
**Category:** Support\
**Created:** [December 3, 2015, 4:46pm UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368 "2015-12-03T16:46:45Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [December 3, 2015, 4:46pm UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/1 "2015-12-03T16:46:45Z")

</div>

Folks,

I have one application in which I have a textview and inside that there’s link called “terms and conditions”. I see there is no any other identifier for clicking on link. Can anyone suggest a way to click on that specific link.?

Attaching the screenshot and the hierarchy for your ready reference.

 ![](https://discuss.appium.io/uploads/default/original/2X/9/953cafe438a418ee12f7af875b0aeed97622e06b.png) ![](https://discuss.appium.io/uploads/default/original/2X/b/b30e98459329e4308ac05ac220c18c1793a83fed.PNG)

---

<div class="post-metadata">

**Author:** ![willosser](https://discuss.appium.io/user_avatar/discuss.appium.io/willosser/32/2454_2.png) [@willosser](https://discuss.appium.io/u/willosser)\
**Post date:** [December 3, 2015, 5:11pm UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/2 "2015-12-03T17:11:31Z")

</div>

The textview is clickable. If you click on that element, you will have clicked the link.

---

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [December 14, 2015, 7:29am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/3 "2015-12-14T07:29:12Z")

</div>

My test is getting passed. Meaning that it clicks on text, and T&C page doesn’t open. That means I can click on textview but can’t click on link.

Here is the piece of code.

> driver.scrollTo(“the Terms and Conditions”);  
> System.out.println(driver.findElement(tnc).getText());  
> driver.findElement(tnc).click();

Here is the console output

> I have read and agree to the Terms and Conditions  
> PASSED: launch

---

<div class="post-metadata">

**Author:** ![Ilya\_G](https://discuss.appium.io/letter_avatar_proxy/v4/letter/i/958977/32.png) [@Ilya\_G](https://discuss.appium.io/u/Ilya_G)\
**Post date:** [May 26, 2016, 4:26pm UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/4 "2016-05-26T16:26:40Z")

</div>

Hey, did you find a way to click on that element inside TextView?

---

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [July 4, 2016, 4:01am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/5 "2016-07-04T04:01:41Z")

</div>

No I didn’t. The work-around is to take some position based on percentage and then click on the element. That solved my problem somehow but it doesn’t work throughout the devices.

---

<div class="post-metadata">

**Author:** ![Ilya\_G](https://discuss.appium.io/letter_avatar_proxy/v4/letter/i/958977/32.png) [@Ilya\_G](https://discuss.appium.io/u/Ilya_G)\
**Post date:** [July 4, 2016, 8:13pm UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/6 "2016-07-04T20:13:44Z")

</div>

How I did: found coordinates of that element and then using location you find that link. In my case it was very easy because link located always on the right side of that element(tested on big and small devices and it worked fine)

---

<div class="post-metadata">

**Author:** ![Manigandan\_V](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@Manigandan\_V](https://discuss.appium.io/u/Manigandan_V)\
**Post date:** [August 4, 2016, 9:38am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/7 "2016-08-04T09:38:40Z")

</div>

Hi,

Can you please help me in sharing the line of code in clicking link in textview (like syntax or the method to click link text in textview)

Please help me in resolving this issue.

Thanks in advance  
Mani.V

---

<div class="post-metadata">

**Author:** ![Ilya\_G](https://discuss.appium.io/letter_avatar_proxy/v4/letter/i/958977/32.png) [@Ilya\_G](https://discuss.appium.io/u/Ilya_G)\
**Post date:** [August 5, 2016, 2:14am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/8 "2016-08-05T02:14:25Z")

</div>

Enjoy. Let me know if you have questions:

`WebElement element = driver.findElement(By.id(txtSuppAppDescription)); Point point = element.getLocation(); int x = point.x +1; int y = point.y + element.getSize().getHeight() - 1; new TouchAction(driver).tap(x, y).perform();`

---

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [August 5, 2016, 6:36am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/9 "2016-08-05T06:36:53Z")

</div>

Hey @Ilya_G, thanks for the solution. It worked pretty well. Bad, it didn’t click in my head previously. 🙂

Thanks a lot!🙂

---

<div class="post-metadata">

**Author:** ![sairaghava12345](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@sairaghava12345](https://discuss.appium.io/u/sairaghava12345)\
**Post date:** [August 5, 2016, 6:57am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/10 "2016-08-05T06:57:59Z")

</div>

Hi,

Can you please share your code. For me its not clicking.

Please help me.

My code

WebElement element = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextView[1]"));

```
           Point point = element.getLocation();

           System.out.println(point);

           int x = point.x +1;

           int y = point.y + element.getSize().getHeight() - 1;

           System.out.println("Going to click");

           new TouchAction(driver).tap(x, y).perform();

           System.out.println("Clicked for first time");

           new TouchAction(driver).tap(x, y).perform();

           System.out.println("Clicked for second time");

           new TouchAction(driver).tap(x, y).perform();

           System.out.println("Clicked for third time");

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [August 5, 2016, 6:59am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/11 "2016-08-05T06:59:57Z")

</div>

What error does it give?

---

<div class="post-metadata">

**Author:** ![sairaghava12345](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@sairaghava12345](https://discuss.appium.io/u/sairaghava12345)\
**Post date:** [August 5, 2016, 7:02am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/12 "2016-08-05T07:02:05Z")

</div>

HI Mashkurm,

Its not giving any error. The output I’m getting is

(35, 281)

Going to click

Clicked for first time

Clicked for second time

Clicked for third time

PASSED: deviceCapabilities

PASSED: mobileFunctionality

Please help me.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![mashkurm](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@mashkurm](https://discuss.appium.io/u/mashkurm)\
**Post date:** [August 5, 2016, 9:02am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/13 "2016-08-05T09:02:28Z")

</div>

@sairaghava12345 - May be due to your device size. Please check whether the element is located on the same point (35,281)?

---

<div class="post-metadata">

**Author:** ![Manigandan\_V](https://discuss.appium.io/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@Manigandan\_V](https://discuss.appium.io/u/Manigandan_V)\
**Post date:** [August 5, 2016, 9:57am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/14 "2016-08-05T09:57:20Z")

</div>

Hi Ilya\_G,  
Thanks for your answer. But I can’t able to click on text. Pls check the following xpath code.

WebElement el=driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATextView[1]"));

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Greatman](https://discuss.appium.io/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Greatman](https://discuss.appium.io/u/Greatman)\
**Post date:** [May 6, 2017, 1:35am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/15 "2017-05-06T01:35:04Z")

</div>

Hi @Ilya_G, I got your idea, could you please explain your code because I have many pages in native app, which requires to find link and click. so main part which I don’t understand is point.x + 1 and same with int y where you did -1. why do we have to do +1 and -1?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![deepirms2619](https://discuss.appium.io/letter_avatar_proxy/v4/letter/d/258eb7/32.png) [@deepirms2619](https://discuss.appium.io/u/deepirms2619)\
**Post date:** [January 31, 2018, 9:29am UTC](https://discuss.appium.io/t/how-to-click-a-link-inside-a-textview/7368/16 "2018-01-31T09:29:47Z")

</div>

Hi Greatman,  
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.  
Thanks
