Results 1 to 4 of 4

Thread: Validating combo box selection

  1. #1
    Sencha User
    Join Date
    Mar 2017
    Posts
    45

    Default Validating combo box selection

    I have a multi-select state combo box that allows a user to type in a state and select it from the list. The issue I'm having is validating the selection of the combo box. Sencha test is returning an empty array during my inspection when it should be returning the display value.

    The locator used to place focus in the state combo box
    Code:
    /**        * @method VendorTTMStates
            * @member stpo.VendorAdminDetails
            * @return {ST.future.ComboBox}
            */VendorTTMStates: {
                locator: 'tagfield[name="StateTTM"]',
                name: 'VendorTTMStates',
                type: 'comboBox',
                className: 'ST.future.ComboBox'
            },
    The field spec used to store the combo box data:
    Code:
    {                name: 'Vendor TTM States Served',
                    testName: 'is a  combobox that is optional',
                    locatorFn: stpo.VendorAdminDetails.VendorTTMStates,
                    input: 'WASHINGTON',
                    value: 'WA',
                    required: false,
                    multiCombo: true,
                    type: 'combobox'
                },

    The function used to type a state and select it from the combo box:
    Code:
    setComboSelection: function(spec) {        it('Should select ' + spec.name + ' from the combo box', function() {
                var target = spec.locatorFn();
                if (spec.multiCombo) {
                    target.click().type(spec.input);
                    target.type({
                            key: 'Enter'
                        }).displayValue(spec.input)
                        .and(function(field) {
                            console.log(spec.name,field);
                            field.expect('value').toBe([spec.value]);
                        });
                } else {
                    target.click().type(spec.input);
                    target.type({
                            key: 'Enter'
                        }).displayValue(spec.input)
                        .and(function(field) {
                            console.log(spec.name, field);
                            field.expect('value').toBe(spec.value);
                        });
                }
    and the output from ST:
    Expected [ ] to be [ 'WA' ].

    This only impacts my multicombo field specs. Single select combo box inspections return the value as expected. Any idea why my multi-combo expect is returning an empty array?

    Thanks,
    Shawn

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

    Default

    Hi Shawn,

    I'm having difficulty replicating this issue. Which type of scenario are you using - WebDriver or In-Browser? And what version of Ext JS?

    The example test below passes for me:

    Code:
    // Scenario URL: http://examples.sencha.com/extjs/6.5.3/examples/kitchensink/?classic#form-tag
    describe('MultiSelect', function () {
        it('should type and select a value', function() {
            ST.comboBox('tagfield[reference=states]')
                .click()
                .type('Wash')
                .type({
                    key: 'Enter'
                })
                .expect('value').toEqual(['CA', 'WA']);
        });
    });
    Thanks.
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  3. #3
    Sencha User
    Join Date
    Mar 2017
    Posts
    45

    Default

    This is an WebDriver scenario using Ext JS version 6.5.3.57 and ST 2.2.0.148.

    I tried the approach you provided above using the .toEqual method and passing in the 'WA' value but that wasn't recognized either. It continues to return an empty array of [ ]

    A second issue I've encountered, and maybe I'm just missing it, but I've added console.log statements to inspect what value is being returned by the field parameter. The log statement is not displayed in ST or in the browser. I've added a 60 second wait and opened the dev console to view the logs but I can't find where if or where they're being logged to. Any suggestions on that?

    Code:
    setComboSelection: function(spec) {        it('Should select ' + spec.name + ' from the combo box', function() {
                var target = spec.locatorFn();
                if (spec.multiCombo) {
                    target.click().type(spec.input);
                    target.type({
                            key: 'Enter'
                        }).expect('value').toEqual(['WA']);
                        //.displayValue(spec.input);
                        /*.and(function(field) {
                            console.log(spec.name,field);
                            field.expect('value').toBe([spec.value]);
                        });*/
                } else {
                    target.click().type(spec.input);
                    target.type({
                            key: 'Enter'
                        }).displayValue(spec.input)
                        .and(function(field) {
                            console.log(spec.name, field);
                            field.expect('value').toBe(spec.value);
                        });
                }

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

    Default

    It's almost like the value hasn't updated by the time you run the expect on it. Do you have any logic that runs on the tag field before the value is set?

    What happens if you add a slight delay before checking the value, using the "wait" API, for example:

    Code:
    ST.comboBox('tagfield[reference=states]')
        .click()
        .type('Wash')
        .type({
            key: 'Enter'
        })
        .wait(2000)
        .expect('value').toEqual(['CA', 'WA']);
    Does that make any difference?

    Also, for debugging WebDriver scenarios, you need to run the scenario in Debug mode (by clicking the Debug button, instead of the Run button). Sencha Studio will then display a Dev Tools tab, containing a Console where messages will get logged. You can also add "debugger;" statements in your test suites to break at a particular point.
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

Similar Threads

  1. Populating second combo based on first combo selection
    By infocontroller in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 1 Sep 2009, 8:49 PM
  2. Need help on combo box selection
    By gywinston in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 26 Sep 2008, 5:04 PM
  3. How to populate combo based on selection in other combo
    By mhuibers in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 27 Nov 2007, 7:53 AM

Posting Permissions

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