I have this kind of a table to deal with:
The path for the headers is:
List<WebElement> headers;
headers = driver.findElements(By.xpath("//*[@id=\"table1\"]/thead/tr/th"));
The path for the table body is:
List<WebElement> dataTable;
dataTable = driver.findElements(By.xpath("//*[@id=\"table1\"]/tbody/tr/td"));
List of headers has size of 6, list of dataTable has size of 24.
I am trying to put this to a list of maps
List<Map<String, String>> listOfMaps = new ArrayList<Map<String,String>>();
So far I've managed to add just the first entry:
for (int i = 0; i < headers.size(); i++) {
mapa.put(headers.get(i).getText(), dataTable.get(i).getText());
}
and the output is:
{Last Name=Smith, First Name=John, Email=jsmith@gmail.com, Due=$50.00, Web Site=http://www.jsmith.com, Action=edit delete}
But if I put it to the loop where row size = 4, it will give me a list of 4 same maps. What do I have to do to make it work? I would like to have that kind of format (list of maps) so I can send it as a JSON in API POST testing.
Thank you for your help!
