0

I have a scenario in my framework to get the row count and select one or multiple rows from the grid. Here, the class name and attributes are the same for all rows, the id is kept on changing for each row.

[attached a screenshot][1].

I've written this xpath to get header checkbox. However, it thrown stale element exception. I'm attaching the DOM here. enter image description here

NarendraR
  • 7,577
  • 10
  • 44
  • 82
Marks
  • 1
  • 1
  • 1
    Add code trial and HTML snippet instead of image for better response – NarendraR Jun 18 '20 at 12:13
  • 1
    Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Jun 18 '20 at 12:26

1 Answers1

0

if you want get count, get as element list size by

By appct = By.xpath("//input[@class='ag-input-field ag-checkbox-input']");
int count = driver.findElements(appct).size();

and if you want click first two check boxes,

if(count > 2){
      driver.findElements(appct).get(0).click();
      driver.findElements(appct).get(1).click();
}
Jayanth Bala
  • 758
  • 1
  • 5
  • 11