Results 1 to 6 of 6

Thread: Locating specific controls

  1. #1

    Default Locating specific controls

    I am currently having trouble with using the following code in which I have to press the Save button on a form but when I run it the error Locator Multiple matches error triggers.


    ST.button('form[itemId="frmDiscountCode"] button[itemId="btnSave"]').click(10, 10);

    I am getting confused with this since there is only one open form with a save button. I have this child form that I need to open, save and close repeatedly so I suspect this is the cause of the locator error. I also find the Inspector unhelpful as it still throws a the locator error even if it says the locator only found 1 component after I specified a lot of property.


    Is it possible to implement something like Ext.WindowManager.getActive() on Sencha Test? I need a way to know which form is currently on focus and maybe from there I can have a better way to access the controls inside a specific form using ST API.

  2. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    331
    Answers
    52

    Default

    If you have multiple forms that match this locator, but only one is visible at a time, you could try something like this:

    Code:
    form[itemId="frmDiscountCode"][hidden=false] button[itemId="btnSave"]
    Does that help?
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  3. #3

    Default

    Sorry it didn't work. The locator matches multiple items error still triggers. I am curious of how the component query locator can find multiple controls of the same properties but yet the control I wanted to click should be unique.


    Is there a way to see a list of this multiple matches so I can verify if there is really a duplicate control that I can't see?

  4. #4
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    331
    Answers
    52

    Default

    If you run the app normally in the browser, bring up the browser's debugging tools, then run this command in the console, this will return an array of the matching components:

    Code:
    Ext.ComponentQuery.query('form[itemId="frmDiscountCode"][hidden=false] button[itemId="btnSave"]')
    This should help to see the multiple matches.

    You can also see which HTML element the component relates to from the console:

    Code:
    // Get the dom element of the first matching component
    Ext.ComponentQuery.query('form[itemId="frmDiscountCode"][hidden=false] button[itemId="btnSave"]')[0].el.dom
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  5. #5
    Sencha User
    Join Date
    Jul 2018
    Posts
    1

    Default

    I am now able to verify those multiple matches. However, I found out that the array length increases depending on how many instances of the control existed. I tested this by opening and closing a form and looking for the same control repeatedly and this time I am targeting a unique combobox on a form. I don't know if the locator should work this way but the increasing length of the array can cause confusion when I am only looking for a unique control on a single visible form. Please check the image below, I was able to query an increasing size of array whenever I open the same form.

    7-28-2018 3-51-22 AM.jpg

    Anyway, my problem now is how to target the specific item on the array using ST.comboBox(...)?

    Thanks!

  6. #6
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    331
    Answers
    52

    Default

    If you are unable to differentiate between the various instances of the form, you could tag on ":first" or ":last" to just reference the first or last rendered instance of the form, for example:

    Code:
    form[itemId="frmDiscountCode"]:last combobox[itemId="cboDiscountCode"]
    But it sounds to me like the app should be changed so that it destroys old instances of the form when closed, rather than keeping them?

    Otherwise, have you checked the properties on each form instance to see if there's a way to differentiate between them? You could do that by running a component query in the browser on 'form[itemId="frmDiscountCode"]' and looking at the properties of each form to see if any are different between the different instances.

    Thanks.
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

Similar Threads

  1. Locating elements on Canvas by selenium webdriver
    By amit3416 in forum Ext JS 6.x Q&A
    Replies: 0
    Last Post: 27 Jul 2017, 1:19 AM
  2. locating points on Vector image
    By mkariti in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 13 Aug 2011, 2:18 AM
  3. Replacing standard html form controls with Ext JS controls (better way?)
    By dolzenko in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 11 Feb 2008, 1:19 PM

Posting Permissions

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