Element is obsolete message when using CacheLookup

395 views
Skip to first unread message

sqa tester

unread,
Feb 18, 2010, 5:32:56 PM2/18/10
to webdriver
I have implemented use of PageFactory and AjaxElementLocatorFactory.

When I use @CacheLookup, I get Element is obsolete message.

This happens when I do the following:

clickLinkA -> takes user to pageA
clickLinkB -> takes user to pageB
clickLinkA -> Element is Obsolete error occurs.

What can I do to take advantage of @CacheLookup in situation like
this? It seems i have to find element again. I am wondering if another
way other than having to include the FindBy in the page object method
since currently it is defined in @FindBy annotation.

Eran M.

unread,
Feb 19, 2010, 7:30:52 AM2/19/10
to webd...@googlegroups.com
Hi,

From your work-flow description, it is unclear how you perform the 3rd step - has page B been opened in a new window?
"Element is obsolete" indicates that page A has been re-loaded or somehow modified.
Does your test work reliably without the @CacheLookup annotation? What was the motivation behind adding the @CacheLookup annotation in the first place?

Eran


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


sqa tester

unread,
Feb 19, 2010, 2:19:28 PM2/19/10
to webdriver
i would like to cache the web element in order to improve performance.

LinkA and LinkB are links on side panel. When you click on LinkA it
opens Page A on center panel. When you click on LinkB it opens Page B
on center panel. The side panel links are always there. Page A and
Page B
are opened on same page.

Test works without @CacheLookup. Will @CacheLookup break my test if I
have to move page to page?

There might be workflows where I am in same page and need to access
webelements in that page repeatedly. In those cases, I d like to take
advantage of @CacheLookup.

On Feb 19, 4:30 am, "Eran M." <eran....@gmail.com> wrote:
> Hi,
>
> From your work-flow description, it is unclear how you perform the 3rd step
> - has page B been opened in a new window?
> "Element is obsolete" indicates that page A has been re-loaded or somehow
> modified.
> Does your test work reliably without the @CacheLookup annotation? What was
> the motivation behind adding the @CacheLookup annotation in the first place?
>
> Eran
>

> On 18 February 2010 22:32, sqa tester <thesqates...@gmail.com> wrote:
>
> > I have implemented use of PageFactory and AjaxElementLocatorFactory.
>
> > When I use @CacheLookup, I get Element is obsolete message.
>
> > This happens when I do the following:
>
> > clickLinkA -> takes user to pageA
> > clickLinkB -> takes user to pageB
> > clickLinkA -> Element is Obsolete error occurs.
>
> > What can I do to take advantage of @CacheLookup in situation like
> > this? It seems i have to find element again. I am wondering if another
> > way other than having to include the FindBy in the page object method
> > since currently it is defined in @FindBy annotation.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "webdriver" group.
> > To post to this group, send email to webd...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > webdriver+...@googlegroups.com<webdriver%2Bunsu...@googlegroups.com>

Colin Alworth

unread,
Feb 19, 2010, 2:44:21 PM2/19/10
to webd...@googlegroups.com
>Test works without @CacheLookup. Will @CacheLookup break my test if I have to move page to page?
Yes - CacheLookup finds the element on the page, and if the page loaded changes, even if it changes back, the element that was loaded no longer applies. Without the CacheLookup, the driver.findElement call will be run again.

This can be made more clear by loading a page using the regular findElement calls, loading another page, loading the original, and trying to use the original element:

driver.get("http://example.com/1.html");
WebElement elt = driver.findElement(By.id("content"));
driver.get("http://example.com/2.html");
driver.get("http://example.com/1.html");
elt.click();

To unsubscribe from this group, send email to webdriver+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.




--
218.348.4347
nilo...@gmail.com

Eran M.

unread,
Feb 22, 2010, 1:11:08 PM2/22/10
to webd...@googlegroups.com
Colin's explanation makes it quite clear when caching elements can be used.
Did anyone time their tests with and without cached lookup of elements? It would be interesting to get some ballpark figures for the time different (which will heavily depend on the browser, OS and the rest of the testing environment, of course).

Eran
Reply all
Reply to author
Forward
Message has been deleted
0 new messages