-1

I am automating a web application using Selenium Java, this web application has angular js ng-repeat table as below which creates row with checkbox inside each row. I need to select few checkbox based on condition to test.

I am using below code to find these checkbox but unable to find and click.

    // To locate table.
    WebElement mytable = driver.findElement(By.xpath("//table[@class='table']/tbody"));
    // To locate rows of table.
    List<WebElement> rows_table = mytable.findElements(By.id("check"));
    // To calculate no of rows In table.
    int rows_count = rows_table.size();
    System.out.println(rows_count);

Webpage source looks like below

`<table class="table" ng-cloak> 
<tbody>
<tr ng-repeat="C orderBy : colsort:reverseSort">
<td>
<input id="check" type="checkbox" ng-checked="C.Addc" ng-model="C.Addc" ng-    click="FindMsg(C.Addc,C.MSG)" />
</td>
<td>
{{C.ItemCode}}
</td>
<td>
{{C.Code}}
</td>
<td title="{{C.LongDescription}}">
{{C.LongDescription.substr(0,30)}}...
</td>
<td style="width: 40px; text-align: right">
{{formattingEnd(C.Enduserprice)}}
</td>
<td>
{{C.type}}
</td>
<td>
{{C.statusflag.toUpperCase}}
</td>
<td>
{{C.SInstType}}
</td>
</tr>
</tbody>
</table>`
3
  • Where is the code which you use to click? What is the element with id="checkCPE"? Commented Nov 24, 2016 at 12:30
  • first I am trying to identify the checkboxs and count with below code. but it is returning 0. id="check" is the checkbox repeated in each row of table. <<>> List<WebElement> rows_table = mytable.findElements(By.id("check")); Commented Nov 24, 2016 at 12:59
  • Check if there are more than one tables on page and if your table located inside iframe/frame Commented Nov 24, 2016 at 13:16

1 Answer 1

0

ngWebDriver worked like a charm.

ngWebDriver = new NgWebDriver((JavascriptExecutor) driver); ngWebDriver.waitForAngularRequestsToFinish(); List<WebElement> wes = driver.findElements(ByAngular.repeater("C in SearchCPE")); System.out.println("Row Count is : "+wes.size());

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.