timing difficulties resolved by sleep -- is there a better way ? [message #38513] |
Tue, 09 June 2009 22:49  |
Eclipse User |
|
|
|
I seem to be having timing problems that are only resolved by adding sleep
to the code. For example, if I create a project, then right after, code
like this:
bot.menu("File").menu("New").menu("Other...").click();
sometimes fails, with WidgetNotFoundException: Could not find widget".
This is resolved if I put a bot.sleep in front of it for a few seconds to
make sure the previous operation was completed. Other times it's
successful even without the bot.sleep but if I want it to pass
successfully consistently I have to put the bot.sleep there. I end up
putting a lot of bot.sleeps all over my code to avoid these kind of random
failures.
Adjusting the timeout value seems to have no effect, it just waits longer
until it throws the WidgetNotFoundException...
Anyone else experience similar problem? How to avoid it without so many
bot.sleeps?
Thanks!
-- Steve
|
|
|
|
Re: timing difficulties resolved by sleep -- is there a better way ? [message #39048 is a reply to message #39017] |
Tue, 16 June 2009 12:35   |
Eclipse User |
|
|
|
Using waitForCondition for improving robustness is the right way to do
UI tests, sleeps just make things too slow, not to mention unpredictable
and unreadable.
Also I'd be interested to know what kind of waits you're using and if
there are any particular waits that you'd like to share with others :)
--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
On 16/6/09 21:49, Kay-Uwe Graw wrote:
> Apart from the fact, that there are still some issues with menu and
> contextmenu in SWTBot I would suggest using the ICondition interface and
> bot.waitUntil method. Using these you can write custom wait conditions
> which ensure that the previous operation has finished. Of course, you
> need to be able to identify in your application ui, when the previous
> operation has finished. For instance, I have a custom wait condition
> which waits that the text in the console view in the eclipse ide has a
> certain value to ensure that an ant task has finished. I generally use
> wait conditions quite a lot to make tests more robust, e.g. waiting
> explicitly for views and dialogs to appear or disappear, for widgets
> beeing disabled or enabled etc.
>
> Kay
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02488 seconds