java - Selenium Webdriver. Error 'org.openqa.selenium.StaleElementReferenceException: Element is no longer valid' -


selenium webdriver + java. code:

public list<userdata> getusers() {         list<userdata> users = new arraylist<userdata>();         webelement userlist = driver.findelement(by.id("users"));         iselementdisplayed(by.xpath("//table[@id='users']/*/tr[position() > 1]"), 10);         list<webelement> tablerows = driver.findelements(by.xpath("//table[@id='users']/*/tr[position() > 1]"));         (webelement tablerow : tablerows) {                  list<webelement> cells  = tablerow.findelements(by.tagname("td"));             userdata user = new userdata();             user.fio = cells.get(2).gettext();             user.login = cells.get(3).gettext();             user.rank = cells.get(4).gettext();             user.cabinet = cells.get(5).gettext();             users.add(user);             }                return users; 

}

after delete user table, method throws:

org.openqa.selenium.staleelementreferenceexception: element no longer valid

here:

list<webelement> tablerows = driver.findelements(by.xpath("//table[@id='users']/*/tr[position() > 1]")); 

how can fix error, without refreshing page?

please note! not

element no longer attached dom 

error

i thinking deleting user rebuilds part of dom via javascript. therefore, although page has not reloaded, html has changed, resulting in selenium throwing stale element. if html rebuilt, selenium says found elements stale , must refound.

this occurs if original element still in newly refreshed dom. if has been rebuilt selenium thinks better safe sorry , therefore invalidate everything.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -