Problem with StaleElementReferenceException error pops up occasionally

后端 未结 3 1161
一整个雨季
一整个雨季 2021-01-29 03:12

Hi I have this code which is generating me:

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not

3条回答
  •  生来不讨喜
    2021-01-29 04:09

    @Jonx -> It's not the only reason. Question is also about app, @ranger is using. If it's dynamic (with reloading elements e.g. cause new live data) it's also raises this issue. depending on time when data comes in (e.g. after getting reference to element but before performing action). This can be pain in the ass -,-

    @Yun - like this idea, but also (if in testing), using Page Object Pattern, good idea is to use views, and then perform actions within try-except blocks, or actually defining Page elements as property methods, so You'll get clean code, and WebDriver will look for element each time call. That eases up issue.

    Yeah, I know that this is not so "well-performance" solution, but - as always - trade offs for stable behaviour with live-dynamic apps.

提交回复
热议问题