I have a <section>
tag in which there is <tfoot>
tags and many <td>
tags.
I want to store the 1st & 4th td elements of a in a Map, but i get index out of bounds exception.
Now, how can we use FindElement or FindElement method on a WebElement itself. Does this find all the child elements? Apologies as i have messed up all my code.
There are 14 tags on the page and i want to retrieve the text of td elements that are inside tfoot tag from each and every section, Product name and price, then store it in a String, String Map. Also, there is lot of whitespace in td element values.
<div>
<table class="right">
<tfoot>
<tr class="product">
<td>Product 1
</td>
<td class="rt">323.00</td>
<td class="rt">
6
</td>
<td class="rt">
6
</td>
<td class="rt">
</td>
</tr>
</tfoot>
</table>
</div>
List sectionsList = driver.findElements(By.tagName("section"));
Iterator<WebElement> it = sectionsList.iterator();
while(it.hasnext())
{
System.out.println(itr.next().findElements(By.tagName("tfoot")).get(1).findElements(By.tagName("td")).get(0)
.getText());
Now, i want to store the td values in a Hashmap.
Map<String, String> map1 = new HashMap<String, String>();
for(int i=1; i<sections.size()+1; i++){ map1.put(sectionList.get(i).findElements(By.tagName("tfoot")).get(1).findElements(By.tagName("td")).get(0).getText() , sectionList.get(0).findElements(By.tagName("tfoot")).get(1).findElements(By.tagName("td")).get(3).getText()); }