如何使用SeleniumWeb驱动程序java单击某个href,该href将某些单词作为文本
我正在尝试单击href,它既没有id也没有名称。其文本为“先前保险的证明”。当我尝试使用xpath时如何使用SeleniumWeb驱动程序java单击某个href,该href将某些单词作为文本,java,selenium,text,href,Java,Selenium,Text,Href,我正在尝试单击href,它既没有id也没有名称。其文本为“先前保险的证明”。当我尝试使用xpath时 "webDriver.findElement(By.xpath("//form*[@name='plaRequiredDocumentsForm']/table[3]/tbody/tr[4]/td/table/tbody/tr/td/table/tbody/tr[2]/td[3]/a")).click()" 它在控制台中打印“无法评估或不会导致WebElement” 网站代码为: <F
"webDriver.findElement(By.xpath("//form*[@name='plaRequiredDocumentsForm']/table[3]/tbody/tr[4]/td/table/tbody/tr/td/table/tbody/tr[2]/td[3]/a")).click()"
它在控制台中打印“无法评估或不会导致WebElement”
网站代码为:
<FORM method=post name=plaRequiredDocumentsForm>
<INPUT name=expVIPCacheKey value=null type=hidden>
<INPUT name=wintag value=1411453320424 type=hidden>
<DIV style="DISPLAY: none" id=signatureOptionSection>
<TABLE width=750>
<TBODY>
<TR>
<TD style="PADDING-LEFT: 10pt">
Signature Option : <INPUT class=bodytext onclick="javascript: setPageDataChangeIndicator(); toggleSignatueStatus(this)" name=signature value=ePad type=radio value2="" value1="">
E-Pad <INPUT class=bodytext onclick="javascript: setPageDataChangeIndicator(); toggleSignatueStatus(this)" name=signature value=ink CHECKED type=radio value2="" value1=""> Ink
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
<TABLE width=750>
<TBODY>
<TR>
<TD style="TEXT-ALIGN: right; PADDING-LEFT: 5pt; PADDING-RIGHT: 10pt">
<A onblur="if (this.children[0]) this.children[0].className='';window.defaultStatus=''" onfocus="if (this.children[0] != null) this.children[0].className='activeButton';window.defaultStatus='button exit '" onmouseover="window.status='button exit ';return true;" href="javascript:formExit()">
<IMG class=bodytext border=0 align=middle src="../../../images/button_exit.gif"></A> <A onblur="if (this.children[0]) this.children[0].className='';window.defaultStatus=''" onfocus="if (this.children[0] != null) this.children[0].className='activeButton';window.defaultStatus='button image center '" onmouseover="window.status='button image center ';return true;" href="javascript:imageCenterSubmit()"><IMG class=bodytext border=0 align=middle src="../../../images/image_center.gif"></A>
<A onblur="if (this.children[0]) this.children[0].className='';window.defaultStatus=''" onfocus="if (this.children[0] != null) this.children[0].className='activeButton';window.defaultStatus='button refresh '" onmouseover="window.status='button refresh ';return true;" href="javascript:refresh()">
<IMG class=bodytext border=0 align=middle src="../../../images/button_refresh.gif"></A>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE><BR>
<TBODY>
<TR>
<TD style="PADDING-LEFT: 10pt"><FONT color=red size=2>
<B>IMPORTANT:</B> Scanning into the Application of Insurance document type will automatically apply a copy to the Subscription Agreement document type if a Subscription Agreement is required. Each document will be approved independently. </FONT>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE class=surroundingTable border=1 width=750>
<TBODY>
<TR>
<TD colSpan=2>
<TABLE class=txnTable>
<TBODY>
<TR class=sectionHeader>
<TD>
<DIV style="FLOAT: left">Household Documents </DIV>
<DIV style="FLOAT: right"><A tabIndex=-1 href="javascript:openHelpTagWindow('/TR/eAgent/Ade/eauto.help.ade?req_page=help&TransType=NN&StateCode=OH&HelpTextId=H02710001')">
<IMG border=0 src="../../../images/icon_question_mark_green_cropped.gif" width=15 height=15></A>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD colSpan=2>
<TABLE class=surroundingTable>
<TBODY>
<TR>
<TD>
<TABLE class=txnTable>
<TBODY>
<TR class=columnHeader>
<TD>Household Number</TD>
<TD>Document</TD>
<TD>Status</TD>
<TD>Customer Notified</TD>
<TD>Due Date</TD>
<TD>Signature</TD>
<TD></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR><BR>
<TR>
<TD colSpan=2>
<TABLE class=txnTable>
<TBODY>
<TR class=sectionHeader>
<TD>
<DIV style="FLOAT: left">Client Documents </DIV>
<DIV style="FLOAT: right">
<A tabIndex=-1 href="javascript:openHelpTagWindow('/TR/help.ade?req_page=help&TransType=NN&StateCode=OH&HelpTextId=H02710002')">
<IMG border=0 src="../../../images/icon_question_mark_green_cropped.gif" width=15 height=15></A>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD colSpan=2>
<TABLE class=surroundingTable>
<TBODY>
<TR>
<TD>
<TABLE class=txnTable>
<TBODY>
<TR class=columnHeader>
<TD>Client Name</TD>
<TD>Date of Birth</TD>
<TD>Document</TD>
<TD>Status</TD>
<TD>Customer Notified</TD>
<TD>Due Date</TD>
<TD>Signature</TD>
<TD></TD>
</TR>
<TR class=resultsOff>
<TD>KARTHICK KAMAL </TD>
<TD>December 24, 1986</TD>
<TD>
<A href="JavaScript:openDocumentWindow('null','A ','A0002','NR','CL',' 734383047','2566332','null','1611745392','734383047','false');">Affinity Discount Documentation </A>
</TD>
<TD>Not Received </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD> </TD>
</TR>
<TR class=resultsOff>
<TD></TD>
<TD></TD>
<TD>
**<A href="JavaScript:openDocumentWindow('null','A ','A0054','NR','CL',' 734383047','2566332','null','1611745392','734383047','false');">Proof of Prior Insurance </A>**
</TD>
</TR>
签名选项:
电子印刷油墨
重要提示:如果需要订阅协议,扫描保险文档类型的应用程序将自动将副本应用于订阅协议文档类型。每一份文件都将得到独立批准。
家庭文件
户数
文件
地位
通知客户
到期日
签名
客户文件
客户名称
出生日期
文件
地位
通知客户
到期日
签名
卡姆卡马尔
1986年12月24日
未收到
****
请帮助我解决此问题。使用“driver.findElements(By.cssLocator(“td>a”))”方法获取元素列表
迭代上述列表中的每个元素,获取其中的文本,并将其与预期文本进行比较。它与您的元素匹配,然后您可以对其执行操作。使用以下XPath:
//a[contains(text(),'Proof preor Insurance')]谢谢瓦伦,但我的问题没有解决。我使用的是List linkList=webDriver.findElements(By.cssSelector(“td>a”);“。它返回很多href的内容,但我不想要。