Target : I want to comapare list of country code corresponding country name which is in Excel. Excel sheet have countrycode and country name in each column separated by ","(comma).I have taken this through below code.
String codes= hashmap.get("Country code"+i);
String countryname=hashmap.get("Country Name"+i);
String[] eachCNCODE= codes.split(",");
String[] eachCountry=countryname.split(",");
eachCNCODE & eachCountry arrays has the content of expected. Now i want to compare this with the content in webpage. so i have take webpage elements for countrycode & country name as below using List.
List<WebElement> countrycodes=driver.findElements(By.xpath("//*[@id='TBL_QryRslts']/tbody/tr/td[4")
List<WebElement> countryNames=driver.findElements(By.xpath("//*[@id='TBL_QryRslts']/tbody/tr/td[5]/div/a")
Now i want to compare eachCNCODE with countrycodes. Want to convert List<WebElement>
into String array then i want to compare each . Please help me on this
答案 0 :(得分:0)
您可以使用以下代码:
List<WebElement> countrycodes=driver.findElements(By.xpath("//*[@id='TBL_QryRslts']/tbody/tr/td[4")
List<String> strings = new ArrayList<String>();
for(WebElement e : countrycodes){
strings.add(e.getText());
}
希望它会对你有所帮助。