FAQ
I have tried the typical method of waiting for an element, which isn't
working for me, and it still throws an exception at the end of the wait
period. And so I am experimenting and trying to figure out a 100% reliable
hack to get around it. ( I have tried things similar to this
thread: https://groups.google.com/forum/?fromgroups#!topic/webdriver/QPNepc2n2eI
but they are not effective.)

So, this is what I have been trying, which doesn't work because the first
time the exception is thrown, I get thrown out of the loop instead of
re-trying. Does anyone know how to properly do a "element retry" after
catching an exception ? Shouldn't I expect the loop to be retried when I
formally catch the exception or is this expectation false? Can you spot
the problem in my code that causes the retry to fail?

----------------------------------------------
public static void clickByLocator( By locator ) {
boolean search = true;
int weWait = 30;
int cycle = 1;
while ( search && cycle <= 3 ) {
try {
driver.findElement( locator ).click();
search = false; // stop searching if no error
} catch ( StaleElementReferenceException sere ) {
staticlogger.info( "\n\n\nElement was stale. Trying again.\n" +
sere.getMessage() + "\n" +
sere.getCause().getLocalizedMessage() + "\n\n" );
//sere.printStackTrace();
}
weWait +=30; // increase wait value for next cycle
cycle +=1;
driver.manage().timeouts().implicitlyWait( weWait, TimeUnit.SECONDS );
}
driver.manage().timeouts().implicitlyWait( DEFAULT_IMPLICIT_WAIT,
TimeUnit.SECONDS );
staticlogger.info("Finished safe click.");
}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/5rwvsX-ndvUJ.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jon Thor Austen at Mar 12, 2013 at 5:00 pm
    I found a possible solution. I am blogging about it here if you want to
    see my current status on this :
    http://thegreenoak.blogspot.com/2013/03/getting-around-webdriver.html

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/YO0F4pvnNcEJ.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedMar 12, '13 at 4:23p
activeMar 12, '13 at 5:00p
posts2
users1
websiteseleniumhq.org

1 user in discussion

Jon Thor Austen: 2 posts

People

Translate

site design / logo © 2022 Grokbase