如何在appium的textview中点击文本链接
对于ex。我有一个字符串,但没有帐户?Register
只有注册有一个链接,其他文本是禁用的,当我点击注册它导航到注册屏幕。
但我不能点击注册。
引用图像
发布于 2018-09-11 13:31:24
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();
我发现这个解决方案here in appium discussion
发布于 2019-08-30 15:24:32
我通常在测试中尽量避免使用XPATH,因此,为了通过文本搜索元素,我正在做类似这样的操作,它将返回一个By
元素,以便在webdriver交互中使用。
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");
}
}
不幸的是,我现在还不知道iOS的等价物,但它也应该以某种方式成为可能;)
发布于 2019-10-10 16:39:43
使用这个简单的代码
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
https://stackoverflow.com/questions/52256409
复制相似问题