for a table kind of Element structure..as given below, how to apply the following-sibling . If the table hearder matches with the input string, enter the value in its corresponding text box.
<div class ="table-class">
<table class ="table-response">
<thead>
<tr>
<th class = "ng-binding" >testcase</th>
<th class="ng-binding"> environment</th>
<th class="ng-binding"> source folder</th>
</tr>
</thead>
<tbody>
<tr class ="ng-scope">
<td class="ng-input">
<input class="ng-scope-input" id='testcaseid">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="environmentid">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="source folder">
</td>
</tr>
</tbody>
</table>
</div>
In UI, this will be exactly in below format:
//Table Header
TestCAse ID Environement Source folder
<text box> <text box> <Text box>
TestCAse ID |
Environement |
Source folder |
<text box> |
<text box> |
<text box> |
|
|
Code is
public void add inputs(){
// here I will get three elements in the list
List<Webelement> tlabels = BrowserFactory.getdriver().findElements(By.xPath("//div/table/thead/tr[@class='ng.binding']")
// here I will get three elements related to input box in the list
List<Webelement> ltexts= BrowserFactory.getdriver().findElements(By.xPath("//div/table/tbody/tr/td/input[@class='ng-scope-input']")
for (Webelement label: tlabels )
{
if (label.getText().equals("TestCAse ID"))
{
// here I have to enter the string . //need help how we can use following-sibling for table type of structure.
}
}
}