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.
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.
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)
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();
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");
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?
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();