首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在appium的textview中点击文本链接

如何在appium的textview中点击文本链接
EN

Stack Overflow用户
提问于 2018-09-10 19:02:49
回答 3查看 2K关注 0票数 8

如何在appium的textview中点击文本链接

对于ex。我有一个字符串,但没有帐户?Register

只有注册有一个链接,其他文本是禁用的,当我点击注册它导航到注册屏幕。

但我不能点击注册。

引用图像

EN

回答 3

Stack Overflow用户

发布于 2018-09-11 13:31:24

代码语言:javascript
运行
复制
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

票数 3
EN

Stack Overflow用户

发布于 2019-08-30 15:24:32

我通常在测试中尽量避免使用XPATH,因此,为了通过文本搜索元素,我正在做类似这样的操作,它将返回一个By元素,以便在webdriver交互中使用。

代码语言:javascript
运行
复制
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的等价物,但它也应该以某种方式成为可能;)

票数 1
EN

Stack Overflow用户

发布于 2019-10-10 16:39:43

使用这个简单的代码

代码语言:javascript
运行
复制
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52256409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档