单击TextView类中的链接

时间:2016-03-23 17:22:29

标签: java android selenium appium

如何访问TextView中的第二个链接?到目前为止我试过了:

  AndroidElement d = (AndroidElement) driver.findElement(By.xpath("//android.widget.TextView[@text='Notice']"));
    d.click();

使用:

driver.findElement(By.Id("com.optimum.rdvr.mobile:id/toc_text"));

只需点击第一个链接即可。我需要得到第二个链接。我想点击“移动隐私声明”任何人都有建议吗?

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用Linkify

String termsOfUse = getResources().getString(R.string.terms_of_use);
String privacyNotice = getResources().getString(R.string.privacy_notice);

legalDescription.setText(
    String.format(
        getResources().getString(R.string.message),
        termsOfUse,
        privacyNotice )
);

//add the links
Pattern privacyNoticeMatcher = Pattern.compile(privacyNotice);
Linkify.addLinks(legalDescription, privacyNoticeMatcher , "privacy:");
Pattern termsOfUseMatcher = Pattern.compile(termsOfUse);
Linkify.addLinks(legalDescription, termsOfUseMatcher , "termsOfUse:");

通过Multiple Clickable links in TextView on Android