Selenium how to Enter data in to tabular format frame - in horizontal way in UI

半城伤御伤魂 提交于 2020-04-12 07:31:06

问题


My List> Has below Data :

[{Test_Case_id=tc1, Delimiter=|,SourceFile=/tmp/tes.dat,targetFile=/tmp/tgt.file},
{Test_Case_id=tc2, Delimiter=;,SourceFile=/tmp/tes1.dat,targetFile=/tmp/tgt1.file},
{Test_Case_id=tc3, Delimiter=|,SourceFile=/tmp/tes2.dat,targetFile=/tmp/tgt2.file}]

In UI page, I have to enter these values in the table. the table looks like below

//<Header>
Test_Case_id     Delimiter      SourceFile      TargetFile
<Input Box>      <Input Box>  <Input Box>   <Input Box>
<Input Box>      <Input Box>  <Input Box>   <Input Box>
<Input Box>      <Input Box>  <Input Box>   <Input Box>

With the code below, it is writing data in the horizontal format

Test_Case_id     Delimiter      SourceFile      TargetFile
tc1              tc2            tc3             <Input Box>
<Input Box>      <Input Box>  <Input Box>       <Input Box>
<Input Box>      <Input Box>  <Input Box>       <Input Box>
int counter =1;
for (WebElement inputhd: inputHeaders)
{
  for (Map<String,String> fetchrow : fetchfilteredrows) // in fetchfilterdrows the above List<Map<String,String>> data is tored.
{
for (Map.Entry<String,String> entry : fetchrow.entrySet())
{
if(input.getText().equalsIgnoreCase(entry.getKey().trim()))
{
//////for (i=0; i<fetchfilteredrows.size(); i++)
{
WebElement inputText = inputhd.findElement(By.xpath(".following::input["+counter+"]"));
WebElement.EnterText(inputText, entry.getValue().trim());
//////}
}
}
counter =counter+1;
}
}

How can write the data to UI horizontally the first row, then enter the second row and enter the second row test case details. Tried adding the for loo, which i have given in "//////" comments.. does not wrk out.

Element Structure is like Below.

<div class ="table-class">
<table class ="table-response">
<thead>
<tr>
<th class = "ng-binding" >Test_Case_id</th>
<th class="ng-binding"> Delimiter</th>
<th class="ng-binding"> SourceFile</th>
<th class="ng-binding"> TargetFile</th>
</tr>

</thead>
<tbody>

////first row in table
<tr class ="ng-scope">
   <td class="ng-input">
   <input class="ng-scope-input" id=Test_Case_id">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="Delimiter">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="sourceFile">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="TargetFile">
</td>
</tr>

////second row in table
<tr class ="ng-scope">
   <td class="ng-input">
   <input class="ng-scope-input" id=Test_Case_id">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="Delimiter">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="sourceFile">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="TargetFile">
</td>
</tr>


////third row in table
<tr class ="ng-scope">
   <td class="ng-input">
   <input class="ng-scope-input" id=Test_Case_id">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="Delimiter">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="sourceFile">
</td>
<td class ="ng-input">
<input class="ng-scope-input" id="TargetFile">
</td>
</tr>
</tbody>
</table>

来源:https://stackoverflow.com/questions/61145274/selenium-how-to-enter-data-in-to-tabular-format-frame-in-horizontal-way-in-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!