Results 1 to 6 of 6

Thread: Referencing objects using ST

  1. #1
    Sencha User
    Join Date
    May 2017
    Posts
    20

    Default Answered: Referencing objects using ST

    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


  2. 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...locator_wizard

    Thanks!
    Joel

  3. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    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...inspector.html

    Thanks!
    Joel

  4. #3
    Sencha User
    Join Date
    May 2017
    Posts
    20

    Default

    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?

    inspectscreenshot.jpg

  5. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    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...locator_wizard

    Thanks!
    Joel

  6. #5
    Sencha User
    Join Date
    May 2017
    Posts
    20

    Default

    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

  7. #6
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    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

Similar Threads

  1. Replies: 2
    Last Post: 10 Oct 2012, 6:41 AM
  2. [CLOSED] Mixing configuration objects and Ext.create defined objects creates unclickable panel
    By stefankendall in forum Sencha Touch 2.x: Bugs
    Replies: 1
    Last Post: 19 Mar 2012, 7:14 AM
  3. Referencing private objects when extending a component (TreePanel)
    By caseyb in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 14 Oct 2010, 5:56 PM
  4. Referencing objects created in object config
    By hworg in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 3 Jun 2009, 4:11 AM
  5. Getting (referencing) objects: variables or ids?
    By Jonny in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 9 Sep 2008, 8:52 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •