Component IDs [message #1403177] |
Tue, 22 July 2014 03:34  |
Eclipse User |
|
|
|
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 #1403347 is a reply to message #1403230] |
Wed, 23 July 2014 03:05   |
Eclipse User |
|
|
|
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 #1779950 is a reply to message #1779891] |
Tue, 16 January 2018 01:44   |
Eclipse User |
|
|
|
Andreas,
If you pass the URL parameter ?inspector=true to your application, Scout will automatically add two HTML5 attributes to the DOM elements for all fields:
- data-classid: contains the value of the @ClassId annotation of the field
- data-modelclass: contains the java class name of the field
Note that the URL parameter is disabled by default on production systems for security reasons. In development mode, the parameter is enabled by default. Otherwise it can explicitly be allowed by setting scout.urlHints.enabled=true in your config.properties.
These IDs are intended to be used in automated tests. In fact, we use Selenium ourselves. There is an AbstractSeleniumTest in the module org.eclipse.scout.rt.ui.html.selenium that you can inherit your test classes from. It is available from the 6.1.x branch and provides some nice utility functions, e.g. to select the input field of a scout form field. (As you have noted, form fields consist of a wrapped DOM structure. The container represents the model field and consists of the label, the mandatory indicator, a status icon, and the actual input field it self. Some fields, such as the date field, can contain more than one <input> field. The correct element can be selected using XPath expressions in selenium. The provided utility functions automatically convert Java class references to XPath expressions.)
Here is an example selenium test for the "Widgets" demo application:
https://github.com/BSI-Business-Systems-Integration-AG/org.eclipse.scout.docs/tree/releases/6.1.x/code/widgets/org.eclipse.scout.widgets.ui.html.app.selenium
Regards,
Beat
|
|
|
Re: Component IDs [message #1780005 is a reply to message #1779950] |
Tue, 16 January 2018 08:17  |
Eclipse User |
|
|
|
Just to make it clear (since this thread is actually quite old and originally discusses Swing, SWT and RAP UIs of Scout <= 4): What I descriped only applies to the new HTML 5 UI (since Scout version 5.2). The code snippets Andreas provided seem to imply that he indeed uses the new UI (e.g. getConfiguredCssClass did not exist in previous versions). My appologies if I should have guessed wrongly, though.
In case you are still using Swing/SWT/RAP UI: I'm not aware of a simple built-in method to generate IDs in the output. It should be possible somehow (after all, it's just software), but I would not put too much effort in this, since the old UIs are not maintained anymore. My recommendation would be to upgrade to a newer version of Scout and switch to the HTML UI. There are migration guides at http://eclipsescout.github.io/.
Regars,
Beat
|
|
|
Powered by
FUDForum. Page generated in 0.07420 seconds