Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Best Practice similar to using ID's in Selenium
Best Practice similar to using ID's in Selenium [message #494472] Fri, 30 October 2009 19:12 Go to next message
Mr. Gaffo is currently offline Mr. GaffoFriend
Messages: 9
Registered: October 2009
Junior Member
Coming from Selenium testing, often when there are multiple buttons with the same text on a page one finds them by their unique id. What would be the equivalent of that in SWTBot?

In some of the other window testing tools I have used they use the (g/s)etData() property of all of the UI elements to set a unique data.

Any help would be appreciated.
Re: Best Practice similar to using ID's in Selenium [message #494476 is a reply to message #494472] Fri, 30 October 2009 19:26 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Mr. Gaffo wrote:
> Coming from Selenium testing, often when there are multiple buttons with
> the same text on a page one finds them by their unique id. What would be
> the equivalent of that in SWTBot?
>
> In some of the other window testing tools I have used they use the
> (g/s)etData() property of all of the UI elements to set a unique data.
>
> Any help would be appreciated.

you can set the data of a widget using the method setData(String,
Object), where the first argument should be the same as
SWTBotPreferences#DEFAULT_KEY (org.eclipse.swtbot.widget.key) and the
second should be the unique id.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Best Practice similar to using ID's in Selenium [message #494480 is a reply to message #494472] Fri, 30 October 2009 19:40 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
IDs is probably a bad idea.

SWTBot gives you nicer APIs to find widgets with some more information.
SWTBot is designed for maintainability in mind. You can lookup widgets
using inGroup() and a lot of other additional information. Using those
will make your tests more maintainable and readable.

--
Ketan
studios.thoughtworks.com | twitter.com/ketanpkr
-

It takes a smart husband to have the last word and not use it.

On 31/10/09 12:42 AM, Mr. Gaffo wrote:
> Coming from Selenium testing, often when there are multiple buttons with
> the same text on a page one finds them by their unique id. What would be
> the equivalent of that in SWTBot?
>
> In some of the other window testing tools I have used they use the
> (g/s)etData() property of all of the UI elements to set a unique data.
>
> Any help would be appreciated.
Re: Best Practice similar to using ID's in Selenium [message #494481 is a reply to message #494476] Fri, 30 October 2009 19:46 Go to previous messageGo to next message
Mr. Gaffo is currently offline Mr. GaffoFriend
Messages: 9
Registered: October 2009
Junior Member
Like this?

http://github.com/gaffo/swtbotexamples/blob/master/junit/com /uberu/TextWithIdTest.java

Ignore the verification stuff from #36 to #54.

This test doesn't work for me.

That is a full git repo and eclipse app btw so you can just pull it if you want.

Also, do you think that some examples like this might get taken as patches?
Re: Best Practice similar to using ID's in Selenium [message #494482 is a reply to message #494480] Fri, 30 October 2009 19:51 Go to previous messageGo to next message
Mr. Gaffo is currently offline Mr. GaffoFriend
Messages: 9
Registered: October 2009
Junior Member
Ketan Padegaonkar wrote on Fri, 30 October 2009 15:40
IDs is probably a bad idea.

SWTBot gives you nicer APIs to find widgets with some more information.
SWTBot is designed for maintainability in mind. You can lookup widgets
using inGroup() and a lot of other additional information. Using those
will make your tests more maintainable and readable.



Ketan,
I can't find any good full examples on how to actually do that. All of the examples that I have seen just control pre-made eclipse dialogs that I don't have the source for so I can't see how the gui was actually coded.
I'm doing straight SWT / Jface as well so the eclipse based examples help me less.

I've got some examples up at http://github.com/gaffo/swtbotexamples that I'm attempting to build up.

I'm really only using ID's because that's the simplest thing I can think of to get to work to prove out SWTBot to my team at the moment. I'm get that IDs are a last ditch thing for long lists of things. I'm actually a core developer on Webrat and we try to keep people from using IDs as well.

Thanks.
Re: Best Practice similar to using ID's in Selenium [message #494492 is a reply to message #494482] Fri, 30 October 2009 20:55 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Mr. Gaffo wrote:

> I don't have the source for so I can't see how the gui was actually coded.

There is a nice util that comes with SWTBot which is designed just for
that: the EclipseSpy View ;)

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Best Practice similar to using ID's in Selenium [message #494503 is a reply to message #494492] Fri, 30 October 2009 22:15 Go to previous message
Mr. Gaffo is currently offline Mr. GaffoFriend
Messages: 9
Registered: October 2009
Junior Member
Pascal G wrote on Fri, 30 October 2009 16:55

There is a nice util that comes with SWTBot which is designed just for
that: the EclipseSpy View Wink



I'm guessing that comes when you install the plugin? I'll take a look and see if that helps.

It stll doesn't tell me what's wrong with http://github.com/gaffo/swtbotexamples/blob/master/junit/com /uberu/TextWithIdTest.java

-Mike

[Updated on: Fri, 30 October 2009 22:17]

Report message to a moderator

Previous Topic:Git Repo Out Of Date
Next Topic:Testing exported RCP fails with StackOverflow
Goto Forum:
  


Current Time: Fri Apr 19 04:34:03 GMT 2024

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

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

Back to the top