开发者

Selenium 2: Holding WebElements in cache after page has changed

I want to be able to use WebElement instances after i moved to another page. I am not sure if that's possible, but there would be the need to store the current state of the browser window. Any pointers or ideas how to do this?

To go even one step further: I'd also l开发者_Python百科ike to use the object after the WebDriver instance was closed.


You will need to get the info that you need from the webelement into other variables before moving to the next part of your test or killing the browser.

I would create a dictionary and then populate it with the webelement properties you want/need.

If you try use the webelement on another page you will get a StaleElementReferenceException thrown


There is also the @CacheLookup annotation you may use for WebElements, which is a:

Marker annotation to be applied to WebElements to indicate that it never changes (that is, that the same instance in the DOM will always be used)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜