如何访问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"));

只需点击第一个链接。我需要第二个链接。我想点击“手机隐私通知”有人有什么建议吗?
java - 单击TextView类内的链接-LMLPHP

最佳答案

您可以使用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

09-25 16:17