The element is defined like this:
<div class ="frm-group'>
<label class ="ng.binding" "Source Environment" ..... </label>
<select class "ng-touched" ...... </select>
</div>
<div class ="frm-group'>
<label class ="ng.binding" "Target Environment" ..... </label>
<select class "ng-touched" ...... </select>
</div>
Div class is the parent class and "lable" and "select" class is the child class.
Problem Statement: I have to do the following :: If the Label.getText() matches with a string, then click on its respective select class and perform action.
I am capturing all the lable class elements in one WebElement List,
Below is my code:
public void add inputs(){
// here I will get two elements int the list
List<Webelement> labels = BrowserFactory.getdriver().findElements(By.xPath("//div/label[@class='ng.binding']")
// here I will get two elements related to select in the list
List<Webelement> selectDropdown= BrowserFactory.getdriver().findElements(By.xPath("//div/select[@class='ng-touched']")
for (Webelement label: labels )
{
if (label.getText().equals("Target Environment"))
{
// here I have to click the select(dropdown) of the matched label
}
}
}
Help pelase..