我想在http://www.redbus.in/Booking/SelectBus.aspx?fromCityId=中获取标签中存在的所有 Travels 名称的名称(它们是动态的,因此想要在数组中进行计数)124&fromCityName=海得拉巴&toCityId=462&toCityName=孟买&doj=30-May-2013&busType=Any&opId=0
这是html文件的一部分
<div id="t1-results">
<table id="t1-list5" class="list5" cellspacing="0" cellpadding="0" style="margin-top:0px;">
<tbody id="t1-0">
<tr class="r1">
<td class="i1">Akbar Travels</td>
<td class="i2">
<td class="i3">
<td class="i4">
<td class="i5">
<td class="i6">
<td class="i7">
</tr>
<tr class="r2">
<tr class="r3">
</tbody>
<tbody class="hrblank">
<tbody id="t1-1" class="G">
<tr class="r1">
<td class="i1">Omer Travels</td>
<td class="i2">
<td class="i3">
<td class="i4">
<td class="i5">
<td class="i6">
<td class="i7">
</tr>
<tr class="r2">
<tr class="r3">
</tbody>
<tbody class="hrblank">
<tbody id="t1-2">
<tr class="r1">
<td class="i1">Sangita Travel Agency</td>
<td class="i2">
<td class="i3">
<td class="i4">
<td class="i5">
<td class="i6">
<td class="i7">
</tr>
我试过了
List<WebElement> linkElements = driver.findElements(By.tagName("//table[@cellspacing=\"0\"]"));
String[] linkTexts = new String[linkElements.size()];
当我调试时linkElements ArrayList<E> (id=82)
linkTexts String[0] (id=95)
不工作。
也试过这个
List<WebElement> linkElements = driver.findElements(By.tagName("t1-results"));
String[] linkTexts = new String[linkElements.size()];
谁能建议我如何取名字。