Implicit Waits and how to handle delayed elements

20 views
Skip to first unread message

Mercious

unread,
May 4, 2015, 8:06:39 PM5/4/15
to seleniu...@googlegroups.com
Hey there,

im new to using Selenium. I have read about implicit waits and i now wonder: Do they also apply to this scenario:

1) Click some button the page
2) -> Result should display a second button (no page-reload)
3) -> Click the appeared button

What if, in step 3), the button has not yet correctly appeared (thus is still hidden, for example) when we want to exceute appearedButton.click(); ? Will an implicit wait that was currently set to x seconds try to click that button for x seconds? Or do implicit waits not apply to this kind of scenario at all, only for a scenario where findElement is called and has not suceeded?

What is the best way to handle this scenario, programming wise?

I have a certain button that fails 30/100 times in IE. In FF and Chrome it succeeds 100/100 times, but in IE those 30% failure happen.

Thanks and regards

murali seleniumtrainer

unread,
May 5, 2015, 2:51:47 AM5/5/15
to seleniu...@googlegroups.com
Hi,

I am slightly confused but below things will help you..

You can user WebDriverWait instead of implicity wait as you are trying to wait until presence of required element. please refer this link where they explained beautifully : http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp

You can also user WebElement.isDisplayed to cross check element is displayed or not..

If you what to handle the exceptions, then you can use try/catch..

let me know, if am wrong..

Thank You,
Murali

Mercious

unread,
May 5, 2015, 3:18:46 AM5/5/15
to seleniu...@googlegroups.com
You are basically answering the question, yes. I was just wondering if implictWaits also work for actions like .click(). But they dont.

Isn't it a good idea to write a complete utility-class then? Instead of using WebElement.click() you should wrap around it and use something like myClick(WebElement whatElement, int tryHowLong); or something like it?

So that if .. for some reason the buttons i want to click on are still disabled (maybe because the site is reacting slow, or whatever) the test doesnt fail but retrys for a certain amount of time? 
 

murali seleniumtrainer

unread,
May 5, 2015, 4:52:15 AM5/5/15
to seleniu...@googlegroups.com
Hi Mercious,

You are correct, good to create one utility class..

Generally i will do like..

Keyword class: for all selenium keywords nothing but methods to click, input by passing object, test data and some wait time as you said..etc..
app_keywords class: if required, some thing like higher level keywords related to applications may be selecting headers, login, selecting tabs by passing objects and data..

Thank You,
Murali

Mercious

unread,
May 5, 2015, 5:11:56 AM5/5/15
to seleniu...@googlegroups.com
Cool, i thought so, thank you :)

So i would have:
- A general utility class that wraps something like click() and other stuff to be safe by using explicitWait inside
- A Page Object Class for every Page that i need to test 


Reply all
Reply to author
Forward
0 new messages