How can I click on Text link inside in textview in appium
for ex. i have a string and Don't Have an Account? Register
Only Register has a link other text are disable, when i click on Register it navigate to Register screen.
But I can't click on Register.
Refer a image
WebElement element = driver.findElement(By.id("element id here"));
Point point = element.getLocation();
//you can change follwing point based on your link location
int x = point.x +1;
int y = point.y + element.getSize().getHeight() - 1;
new TouchAction(driver).tap(x, y).perform();
I find this solution here in appium discussion
I usually try to avoid XPATH in my tests, hence to search for Elements by Text I am doing something like this, which will return a By
element to be used in the webdriver interaction.
public static By byText(final String text)
{
switch (Configuration.getInstance().getPlatform())
{
case ANDROID:
// This requires a UiAutomator2 test driver:
return MobileBy.AndroidUIAutomator("new UiSelector().text(\"" + text + "\")");
case IOS:
default:
throw new RuntimeException("not implemented");
}
}
Unfortunately I don't know the equivalent to iOS just now, but it should also be possible somehow ;)
Use this simple code
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With