Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Component IDs(How to set component IDs for automated testing)
Component IDs [message #1403177] Tue, 22 July 2014 07:34 Go to next message
Rok Štembergar is currently offline Rok ŠtembergarFriend
Messages: 4
Registered: July 2014
Junior Member
I want to perform tests on our Scout Web and Swing application with Robot Framework using Selenium and Swing library. These require components to have some form of identification on individual components.

I've noticed that this problem should be solved with Luna, at least for the Swing part in this post: http://www.eclipse.org/forums/index.php/t/636879/
Could anyone shed some light oh how this can be achieved, maybe also for the Web part of the app?

Thank you
Re: Component IDs [message #1403230 is a reply to message #1403177] Tue, 22 July 2014 14:26 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 989
Registered: October 2011
Senior Member
Can you tell what the requirements are for "Robot Framework using Selenium and Swing library"? I assume they define how they need to access to the GUI component.

For example: a common practice in the web, is to work with the "id" attribute of the elements (I am not sure to know if this is possible with Eclipse RAP).

What has been achive with Luna to provide a mechanism to have unique id for each element in the Scout Model. Depending on your use case (this is precisely why I ask) you need to propagate this id to the component in the UI layer.

.
Re: Component IDs [message #1403347 is a reply to message #1403230] Wed, 23 July 2014 07:05 Go to previous messageGo to next message
Rok Štembergar is currently offline Rok ŠtembergarFriend
Messages: 4
Registered: July 2014
Junior Member
First of i would like to thank you for your reply.

For the Selenium Library, it can locate elements in html code by looking their tags, text, links, css.. 'It is also possible to give an arbitrary XPath or DOM expression as locator.'

So basically, as far as i can see, anything that makes a component unique in html code would do. Testing this in Luna i saw no noticable identification of a component in the Web application, aside from text, but this is not a good way to locate components.

For the Swing Library, the identifier can be:

- The logical name of the component given by the developer. This is the recommended approach as such internal names are likely to be stable.

- The index of the component in its own context, such as the 3rd button in the context. Indexes change when components are added, removed or reordered so this is a relatively fragile approach.

- Title, label or other visible text of the component. Visible texts can change, especially if the application is translated, so this is also a fragile approach.

I made it work with labels and indexes, but the first option is probably best to aim for. I hope i clarified things a bit and again, thank you.
Re: Component IDs [message #1404209 is a reply to message #1403347] Wed, 30 July 2014 13:17 Go to previous messageGo to next message
Rok Štembergar is currently offline Rok ŠtembergarFriend
Messages: 4
Registered: July 2014
Junior Member
I have here a part of the SwingLibrary's output which listed components from the swing application:

   Level: 11 Component: org.eclipse.scout.rt.ui.swing.ext.JPanelEx Index: 13 Name: null
                                     Level: 12 Component: org.eclipse.scout.rt.ui.swing.ext.JPanelEx Index: 14 Name: Synth.GroupBoxBody
                                        Level: 13 Component: org.eclipse.scout.rt.ui.swing.ext.JPanelEx Index: 15 Name: null
                                           Level: 14 Component: org.eclipse.scout.rt.ui.swing.ext.JStatusLabelEx Index: null Name: null
                                              Level: 15 Component: org.eclipse.scout.rt.ui.swing.ext.JPanelEx Index: 16 Name: null


SwingLibrary can successfully locate components by Name ( tested with the name Synth.GroupBoxBody from the above code ).

Taken from SwingLibrary's page:

If the identifier matches to internal name of a component (set using setName method in Java code), that component is chosen.

We need a way to set names for components/inputs etc. @ClassId as the name would be ok. Class names directly could probably also work.
Re: Component IDs [message #1404233 is a reply to message #1404209] Wed, 30 July 2014 15:09 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 989
Registered: October 2011
Senior Member
I did not forget you. I did not have enough time to test and to describe the new mechanim introduced with luna.

I think the AbstractSwingEnvironment.assignWidgetId(ITypeWithClassId, ISwingScoutComposite) is the method you are looking for.

It seems to me, that there is a new parameter "org.eclipse.scout.rt.widgetIdsEnabled" that you can set to true to active the mechanism. The Problem is, the current "assign id mechanism" implementation is not doing what you decribe here:

Quote:
If the identifier matches to internal name of a component (set using setName method in Java code), that component is chosen.


By the way, using setName() is also what Jubula needs. So you need to override assignWidgetId().

Here a dirty hack (without checking the "org.eclipse.scout.rt.widgetIdsEnabled" parameter) that you can use to test:

public class SwingEnvironment extends DefaultSwingEnvironment {

  @Override
  protected void assignWidgetId(ITypeWithClassId model, ISwingScoutComposite uiField) {
    JComponent swingField = uiField.getSwingField();
    swingField.setName(model.classId());
  }
}


I did not try it. I did not discuss it with the developpers. It is only what I found out from some code analysis.

It would be great to test and document this new feature in detail.

For the moment the only input I found is here:
https://wiki.eclipse.org/Scout/NewAndNoteworthy/4.0#Using_Id_in_test_tools

[Updated on: Wed, 30 July 2014 15:11]

Report message to a moderator

Re: Component IDs [message #1404305 is a reply to message #1404233] Thu, 31 July 2014 07:08 Go to previous messageGo to next message
Rok Štembergar is currently offline Rok ŠtembergarFriend
Messages: 4
Registered: July 2014
Junior Member
@Order(20.0)
    @ClassId("7be3874c-9323-44be-833b-cd354ca0c1ce")
    public class NameInputField extends AbstractTextField {


And the SwingLibrary's output:

 Level: 14 Component: org.eclipse.scout.rt.ui.swing.ext.decoration.JTextFieldWithDecorationIcons Index: 1 Name: 7be3874c-9323-44be-833b-cd354ca0c1ce


Works like a charm!

If i understand correctly, org.eclipse.scout.rt.widgetIdsEnabled enables SWT and SWING only. Is there a way to propagate these IDs for the web app?
As i mentioned above, the SeleniumLibrary offers a plethora of ways to find components, almost anything would do (id tag, name tag, class names, etc.).

Again thank you for your reply and time!
Re: Component IDs [message #1404321 is a reply to message #1404305] Thu, 31 July 2014 08:55 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 989
Registered: October 2011
Senior Member
Rok Štembergar wrote on Thu, 31 July 2014 09:08
If i understand correctly, org.eclipse.scout.rt.widgetIdsEnabled enables SWT and SWING only. Is there a way to propagate these IDs for the web app?

As i mentioned above, the SeleniumLibrary offers a plethora of ways to find components, almost anything would do (id tag, name tag, class names, etc.).


You are correct. It would really be nice to have the Web-UI too. I think nobody took time to understand how it can be implemented with Eclipse-RAP.

.

[Updated on: Thu, 31 July 2014 13:11]

Report message to a moderator

Previous Topic:Merge FormDatas
Next Topic:Deploy scout application in Apache ServiceMix
Goto Forum:
  


Current Time: Mon Aug 31 15:41:32 GMT 2015

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

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