[英]Selenium Webdriver - Store multiple linktext's
I'm automating a web application using Selenium Webdriver(Java), but having difficulty in storing multiple linktext's. 我正在使用Selenium Webdriver(Java)自动化Web应用程序,但是很难存储多个linktext。 Below is my html code, I have to fetch all email id's to verify before inserting new one.
以下是我的html代码,在插入新的电子邮件ID之前,我必须先获取所有电子邮件ID进行验证。
<tr class="odd" >
<td><input type="radio" name="item" value="52"></td>
<td><a href="/Abcdef/UpdateAction.do?userno=52">abcd.xyz@abc.com</a></td>
<td>Abcd Xyz</td>
<td>internal</td>
</tr>
<tr class="even" >
<td><input type="radio" name="item" value="151"></td>
<td><a href="/Abcdef/UpdateAction.do?userno=151">klmn.opqr@abc.com</a></td>
<td>Klmn Opqr</td>
<td>internal</td>
. 。 .
。
Likewise it has around 20 linktext's(email id's) and those email id's need to be stored for verification. 同样,它具有大约20个linktext(电子邮件ID),并且需要存储这些电子邮件ID以进行验证。
Any help would be greatly appreciated 任何帮助将不胜感激
WebElement
variable. WebElement
变量中。 Lets call the variable table
table
List<WebElement> emails = table.findElements(By.partialLinkText("0"));
List<WebElement> emails = table.findElements(By.partialLinkText("0"));
WebElement
classes WebElement
类的形式存储在此处 getText
on each of item from the list getText
Thanks for your earlier reply. 感谢您的早日答复。
I used below code to print all linktext's with in table. 我用下面的代码在表中打印了所有的链接文本。
WebElement table = driver.findElement(By.id("table_id"));
List<WebElement> emails = table.findElements(By.tagName("a"));
for(WebElement tdElement : emails) {
System.out.println(tdElement.getText());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.