lundi 22 août 2016

how to get text from span in the below code

UI/web PageI want to get text from all the check boxes given in a drop down box in order to compare those values with db. Please help me. I am able to count the size by options.size(), but unable to get the text/strings to compare with each string in db.

//Click on Select Box
Thread.sleep(500);
driver.findElement(By.xpath(".//*[@id='DivZone']/div/button")).click();
Thread.sleep(500);
List<WebElement> options =    
driver.findElements(By.xpath("//input[contains(@name, 
'multiselect_ddlZone')]"));
//List<WebElement> options = driver.findElements(By.cssSelector(".ui-
corner-all.ui-state-hover>span"));
List<String> all_elements_text=new ArrayList<>();
if(region!=null)
{
for(int i=1; i<options.size(); i++)
{
all_elements_text.add(options.get(i).getText());
System.out.println(options.get(i).getText());
boolean isThere = false;
for (int j = 0; j < region.size(); j++) 
{
if 
(options.get(i).getText().equalsIgnoreCase(region.get(j))) {
// Code to display warning
isThere = true;
}
}
if(isThere)
System.out.println(options.get(i).getText()+" is matched 
with Database data");
else
System.out.println(options.get(i).getText()+" is not matched 
with Database data");
}
}




Aucun commentaire:

Enregistrer un commentaire