lundi 24 octobre 2016

Issue selecting all the checkboxes on a webpage using Selenium + Java

So basically my program logins into a page, checks all the boxes and clicks another button to do an action with it.

So I login, navigate to my webpage, but I am trying to click all the boxes on the webpage in question with this segment of code using Java + Selenium, and it isn't doing anything:

java.util.List<WebElement> els =
    driver.findElements(By.xpath("//input[@type='checkbox']"));
for (WebElement el : els) {
  if (!el.isSelected()) {
    el.click();
  }
}

The HTML code when I inspect the element for the checkbox looks like this:

<div class="actions-column table-cell">
    <input data-ng-model="item.isChecked" data-ng-show="item.canEdit ||item.canPromote || item.displayBumpUpCTA" class="check-ad ng-valid ng-dirty" value="1200304741" data-ng-change="selectItem(item)" type="checkbox">

I tried using CSS Selector as well with my above code but nothing seems to select all the boxes :( :(

I can post screenshots/videos etc of the problem, but just to recap, no checkboxes at all are being checked when I run the code




Aucun commentaire:

Enregistrer un commentaire