如何访问 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"));
只需点击第一个链接。我需要获得第二个链接。我想点击“移动隐私声明” 有人有什么建议吗?
最佳答案
您可以使用 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:");
关于java - 单击 TextView 类中的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36184759/