Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » timing difficulties resolved by sleep -- is there a better way ?
timing difficulties resolved by sleep -- is there a better way ? [message #38513] Wed, 10 June 2009 02:49 Go to next message
Steven Chamberlin is currently offline Steven Chamberlin
Messages: 30
Registered: July 2009
Member
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 #39017 is a reply to message #38513] Tue, 16 June 2009 16:19 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe Graw
Messages: 24
Registered: July 2009
Junior Member
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
Re: timing difficulties resolved by sleep -- is there a better way ? [message #39048 is a reply to message #39017] Tue, 16 June 2009 16:35 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
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
>
Re: timing difficulties resolved by sleep -- is there a better way ? [message #39361 is a reply to message #39048] Wed, 17 June 2009 12:42 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe Graw
Messages: 24
Registered: July 2009
Junior Member
I can open a new bug and attach my current wait conditions if you are
interested and than you can decide if some of them could be useful for
swtbot. Generally, I use wait conditions very extensively just to be on
the safe side especially if the application has many background jobs. I
also use them often implicitely with the page object pattern. For
instance, I have a basic page object for dialogs where the confirm method
(click the "Yes" or "OK" button of the dialog) contains an implicite wait
conditions which waits until the dialog shell has disappeared. I can also
upload my current small basic page object library if you want to add more
support for the page object pattern in the swtbot project.

Kay
Re: timing difficulties resolved by sleep -- is there a better way ? [message #39392 is a reply to message #39361] Wed, 17 June 2009 13:52 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
Hi Kay,

Sounds quite some good enhancements for swtbot for me. Looking forward
to seeing some code :)

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr


On 17/6/09 18:12, Kay-Uwe Graw wrote:
> I can open a new bug and attach my current wait conditions if you are
> interested and than you can decide if some of them could be useful for
> swtbot. Generally, I use wait conditions very extensively just to be on
> the safe side especially if the application has many background jobs. I
> also use them often implicitely with the page object pattern. For
> instance, I have a basic page object for dialogs where the confirm
> method (click the "Yes" or "OK" button of the dialog) contains an
> implicite wait conditions which waits until the dialog shell has
> disappeared. I can also upload my current small basic page object
> library if you want to add more support for the page object pattern in
> the swtbot project.
>
> Kay
>
Re: timing difficulties resolved by sleep -- is there a better way ? [message #39423 is a reply to message #39392] Wed, 17 June 2009 17:03 Go to previous message
Kay-Uwe Graw is currently offline Kay-Uwe Graw
Messages: 24
Registered: July 2009
Junior Member
Have a look at Bug 280641.:-)

Kay
Previous Topic:An ETA on merging swtbot4gef into swtbot?
Next Topic:Bug in version 2.0.0.329 ?
Goto Forum:
  


Current Time: Fri Oct 24 21:22:40 GMT 2014

Powered by FUDForum. Page generated in 0.02813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software