0

What I want to do is to access a web page that has some elements displayed in a grid and some buttons that implement the filtering functionality. The problem is that when I get the list of elements and try to inspect their properties, the error "The Element is not Attached to the DOM" is thrown every time. Nothing that I have tried seems to work. What I noticed though was that after applying a filter, the grid with objects reloads with the filtered results and this may cause the error. How I can get rid of this error?

This is the code that I have (I am using Page Objects): // field container containing all the elements

    @FindBy(id = "MainContent_dtUnitsRepeaterDesktop")
        private WebElement gridContent;
        @FindBy(css = "div.sizes")
        private List<WebElement> unitSizes;

//method returning the list of web elements that hold the text I need
public List<WebElement> getUnitSizes() {
        List<WebElement> units = gridContent.findElements(By.cssSelector("div.sizes"));
        driverWaitObject.until(ExpectedConditions.visibilityOfAllElements(units));
        return units;
    }
//method that is extracting the text from each web element
public List<String> checkElementResults(List<WebElement> elemList) {
        for (WebElement elem: elemList) {
            unitType.add(elem.getText());
        }
return unitType;
}

// method to check and return
    public List<String> checkElementSizeResults() {
        return facilityPageObject.checkElementResults(facilityPageObject.getUnitSizes());
    }

As far as I have noticed the call that generated this error is at line "unitType.add(elem.getText());"

Any suggestions would be welcome (I am a beginner of Selenium WebDriver automation).

3