2016-03-23 26 views
3

如何访问以单击TextView内的第二个链接?到目前为止,我尝试:单击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

+0

您选择父元素,因此很难说。选择链接元素本身。尝试使用Appium检查器。 –

回答

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

+0

但我只能访问UI。我实际上测试应用程序,而不是开发它。有什么想法吗? –