1

I am working on automation test framework in selenium java. In my test application we have used angular grid-controller.

How to access grid row to perform few operations?Grid in Angular JS

2 Answers 2

3

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:

enter image description here

[![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.

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

2 Comments

Thanks, but how to proceed if I want to edit the rows.get(i) value instead of just a click() ?
If I want to select a row and row is not in view then what option I can use? Ag grid I think does not render rows until they are in view that is they are not part of page dom. Therefore finding the row is failing in Selenium Java
0

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;
    }
}

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.