PDA

View Full Version : Referencing objects using ST



RameshM
23 Jul 2017, 9:23 PM
Hi,

Our development team is using MVVM framework for developing web based application using Sencha Architect. They are using ItemId instead of Id and the coding style ‘this.up(‘#itemId’)’. In this case ‘this’ will be relative to specific event like click, select etc.As such all objects in a page, (like buttons, grids, text fields, check boxes, etc) don't have any unique ids or references. Therefore for test scripting, we need to we reverse the reference process in our scripts.

This however is very time consuming. To reference such an object, first we need to reverse track the code of the inspected item, till we discover an item with an id. Get its reference/ name using Ext.getCmp(). Then we figure out the correct path back to the object using ‘up’, ‘down’, ‘next’ and ‘previous’. Doing this for multiple items in a test case takes a lot of time.

In such cases, the recorder isn't of help, since the generated script can't be played back as an error pops like "Failed with error "Component Query locator matches multiple items: "toolbar"

Please advise how this issue can be circumvented and test scripting be made faster.

Regards
Ramesh

joel.watson
24 Jul 2017, 2:33 PM
Hi Ramesh--

Have you tried using the "Inspect" feature within the spec? It allows you to interact with the target page directly, clicking on items and retrieving the locators for them. And if the default locators aren't sufficient to find a unique item, you can open the wizard for the individual locator and specify the appropriate properties and/or hierarchical structure to easily create a locator that will identify the desired item.

Here is the guide for using the Inspector: http://docs.sencha.com/sencha_test/2.1.1/guides/inspector.html

Thanks!
Joel

RameshM
24 Jul 2017, 10:50 PM
Hi Joel,

We tried using the Inspect function within ST 2.1 for a button. However, we got an error message saying "Locator returned two matches".
Screenshot below. Are we doing anything wrong?

56661

joel.watson
25 Jul 2017, 3:14 AM
Hi Ramesh--

Yes, this indicates that there are more than one component with the text of "Add". To get a unique locator, you can open the "Locator Wizard" (click the locator string in the "Locator" column, and then click the "..." icon to open the wizard) to craft a more specific locator string:

http://docs.sencha.com/sencha_test/2.1.1/guides/inspector.html#inspector_-_using_the_locator_wizard

Thanks!
Joel

RameshM
25 Jul 2017, 9:59 PM
Hi Joel,

Thanks a lot for this. It is working as required and will hopefully speed things up for us with accuracy.

Would it be possible to integrate this function into the ST Recorder, so that we an cave a seamless record and playback experience? At present, most of the recordings can't be played back.

Regards
Ramesh

joel.watson
26 Jul 2017, 1:48 AM
Hi Ramesh--

Glad it's helping!

RE: Event Recorder, it's possible there might be some functionality sharing between the two in the future. However, best practices would be to use the API directly in conjunction with Page Objects and the Inspect functionality. Encapsulating the locators in a single location (the Page Object) makes for less brittle tests as changes in locators can be easily managed in one spot, instead of having to update many locators across many tests as your application changes and updates to locators are required.

Thanks!
Joel