I am working on automation test framework in selenium java. In my test application we have used angular grid-controller.
2 Answers
Finally I got the answer myself, For every angular grid , angular generates the column index(hex number) , which is appended to the class attribute of the tag. So we can access the cell value with same class attribute and and iterate through all the rows for the host name column as shown in image please find the code snippet in selenium for same:
[![List<WebElement> rows = driver.findElements(By.xpath("//*[contains(@class,'ui-grid-cell ng-scope ui-grid-disable-selection ui-grid-coluiGrid-0006')]//div"));
int iSize = rows.size();
for (int i = 0; i < iSize; i++) {
String sValue = "192.168.30.70";
if (sValue.equalsIgnoreCase(inputtext)) {
rows.get(i).click();
break;
}
}
so in this way we can search the particular grid column for the matching value.
2 Comments
I tried your code and somehow it didn't work for me, it didn't click the row or it didn't do anything. Here's a screenshot of my application: screenshot
And here is my code:
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
List<WebElement> rows = driver.findElements(By.xpath("//*[contains(@class,'ui-grid-cell hoverable-cell ng-scope ui-grid-coluiGrid-0084')]//div"));
int iSize = rows.size();
for (int i = 0; i < iSize; i++) {
String sValue = "MATT";
if (sValue.equalsIgnoreCase("matt")) {
rows.get(i).click();
break;
}
}

