Results 1 to 7 of 7

Thread: Waiting for data to load into grid before running tests?

  1. #1

    Default Answered: Waiting for data to load into grid before running tests?

    I was wondering how to validate that grids, charts, etc. have been loaded with data without just delaying with wait(). Waiting for the grids to be visible doesn't work because the grid's still visible even if it's empty. I know you could add listeners to the ExtJS components, but I'm trying to do this without changing anything about our components.

    Apologies if this is a dumb question. I'm new to Sencha Test.

    Thanks!

  2. Not a dumb question at all! You can use the "rowAt" API to wait for a record to be available in the grid, so if your grid will always contain at least 1 record, your tests won't proceed until it evaluates as present:

    Code:
    // Wait for grid and row to be available, then click the row when it's available
    ST.grid('#mygrid')
        .rowAt(0)
        .click();
    This capability is described in a little more detail in the docs here: https://docs.sencha.com/sencha_test/..._timing_issues.

    Hope that helps.

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

    Default

    Not a dumb question at all! You can use the "rowAt" API to wait for a record to be available in the grid, so if your grid will always contain at least 1 record, your tests won't proceed until it evaluates as present:

    Code:
    // Wait for grid and row to be available, then click the row when it's available
    ST.grid('#mygrid')
        .rowAt(0)
        .click();
    This capability is described in a little more detail in the docs here: https://docs.sencha.com/sencha_test/..._timing_issues.

    Hope that helps.
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  4. #3

    Default

    Thanks! That worked for grids, but I'm not sure if there's an equivalent way of doing such a thing for combo boxes that are dynamically loaded. Is such a thing possible?

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

    Default

    The Sencha Test Futures APIs should handle that also - when you expand a combobox, the combobox's bound list is shown and will be populated with items once the store has been loaded with records. So doing something like this would work:

    Code:
    it('Should expand dynamically loaded combo box and select a value', function() {
        ST.comboBox("combobox[reference=states]")
            .expand();
        
        // The Futures APIs will wait for this item in the list to become available
        ST.element('combobox[reference=states] boundlist => [data-recordindex="1"]')
            .click();
    });
    If the combobox takes a long time to load its data, you can extend the default timeout (5 seconds), if needed:

    Code:
    it('Should expand dynamically loaded combo box and select a value', function() {
        ST.comboBox("combobox[reference=states]")
            .expand();
        
        // Allow up to 30 seconds for data to show in combobox (completes sooner if data loads sooner)    
        ST.element('combobox[reference=states] boundlist => [data-recordindex="1"]', 30000)
            .click();
    });
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  6. #5
    Sencha Premium Member
    Join Date
    Dec 2015
    Posts
    13

    Default

    Does that also work in the Modern Tookit? According to the Docs ST.comboBox is only available in Classic, but I was able to use that to expand the combobox. When I try to click on the first item in the list, your above code doesn't work. When I inspect the items I don't see anything that's unique besides the internally generated ID.

    Thanks.

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

    Default

    Although you can use the combobox API to expand the combo (looks like the docs need updating), the expanded list (the boundlist) isn't a child of the combobox in the Modern toolkit, so you would need to use a slightly different locator. This should work - essentially find a boundlist that has an "ownerField", which is also visible:

    Code:
    ST.element('boundlist[ownerField]:visible => [data-recordindex="1"]')
        .click();
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  8. #7
    Sencha Premium Member
    Join Date
    Dec 2015
    Posts
    13

    Default

    Thank you Daniel. The above code works for what I need.

Similar Threads

  1. Replies: 1
    Last Post: 17 Nov 2016, 5:29 AM
  2. [FIXED] Running tests of packages in CLI
    By stevesum in forum Bugs
    Replies: 9
    Last Post: 2 Aug 2016, 8:00 PM
  3. Running Unit Tests hangs saying "Loading Tests"
    By nathaniel.fields in forum Q&A
    Replies: 8
    Last Post: 31 May 2016, 1:25 AM
  4. Screen block while waiting grid load?
    By lewisw71 in forum Ext: Q&A
    Replies: 1
    Last Post: 1 Jul 2014, 8:32 AM
  5. while running a ajax request, see a waiting mask
    By ballibum in forum Ext 3.x: Help & Discussion
    Replies: 10
    Last Post: 22 Sep 2009, 3:45 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
  •