Results 1 to 5 of 5

Thread: Futures api - testing fields after navigation

  1. #1
    Sencha Premium User
    Join Date
    Jan 2009
    Posts
    451
    Answers
    19

    Default Answered: Futures api - testing fields after navigation

    Using the futures API, what's the proper way to get a handle to a component and then make assertions about its properties?

    I can perform cross page navigation easily using the API with a combination of ST.element and ST.component calls and invoking methods like type and click. Once I'm at the page I want with the correct application state, how would I, for example, get a handle to a button on the page and check whether it is visible or not?

  2. I am not sure about ExtJS 2.x, because ST supports ExtJS 4+, but code should be similar.

    You are able to return some variables from execute and send it forward. Then you are able work with it and put it into an assertion.

    For example:
    Code:
    ST.button('button')
        .press()
        .execute(function (button) {
            return button.pressed; 
        })
        .and(function () {
            expect(this.future.data.executeResult).toBeTruthy();
        });
    or

    Code:
    ST.button('button')
        .press()
        .get('pressed')  // more properties should be here
        .and(function () {
            expect(this.future.data.pressed).toBeTruthy();
        });
    Just for case - we talk about WebDriver scenario, if you have InBrowser scenario, it is easier.

    I hope that will help.

    Vojtěch

  3. #2
    Sencha Premium User
    Join Date
    Jan 2009
    Posts
    451
    Answers
    19

    Default

    Looking at the docs, I think I'm beginning to understand how this is designed.

    Code:
     ST.component('@futureCmp')
         .get('height')
         .and(function () {
             expect(this.future.data.height).toBe(200);
         })
    This construct allows me to get properties on a component.

    What I would really like is to get a reference to the component itself and execute arbitrary methods on it. However, I'm using the WebDriver functional tests and according to the docs

    Retrieves the values of the specified list of properties from the future's underlying component. These values will then be available on the future itself (for example, to be used in expectations within an and() method).
    This method is particularly useful for WebDriver-based tests where direct access to Ext JS components is not possible within the context of the executed spec.
    Even if direct access to the component is not possible for the WebDriver tests, is there some API that would let me send arbitrary JavaScript to the browser, execute it on the page under test, and return a simple result?

  4. #3
    Sencha User vojtech.cerveny's Avatar
    Join Date
    Jun 2015
    Location
    Ostrava, Czech republic
    Posts
    52
    Answers
    10

    Default

    Hi!
    I think that direct access to component is not possible. You can access to properties (as you described) and then check it. I am not sure, if calling some methods from test is the best practice. Can you provide some example how you want to use it?

    Look at this quote - for me, as I understand WebDriver scenarios, you should interact with you app and then collect results, if properties or something is changed.

    The WebDriver scenarios are, therefore, geared more for functional testing, for general usage testing of the finished application. In these tests, you're more interested in application behavior outcomes, rather than interacting with the code itself.
    But if you want execute some code on your page, you can use this:
    Code:
    ST.execute(function(){
     alert('I am a captain now.'); });
    ST.execute and your test are two separate parts, keep it in mind

    Feel free to contact me any time.
    Vojtěch
    “Testers don’t like to break things; they like to dispel the illusion that things work.”— Kaner, Bach, Pettichord

  5. #4
    Sencha Premium User
    Join Date
    Jan 2009
    Posts
    451
    Answers
    19

    Default

    Thanks for the info! I'm asking in the context of functional testing on an Ext 2.x app. I haven't tried it yet, but I'd like a backup plan in case the ST abstractions don't work well with such an old version. So, I'd like to do something like execute code on the page Ext.getCmp(...).isVisible() and verify the return value.

    Is it possible to return something from the ST.execute call that I can inspect back on the Sencha Test side? I know they're separate and I can't return components and such, but primitive values maybe?


    Quote Originally Posted by vojtech.cerveny View Post
    Hi!
    I think that direct access to component is not possible. You can access to properties (as you described) and then check it. I am not sure, if calling some methods from test is the best practice. Can you provide some example how you want to use it?

    Look at this quote - for me, as I understand WebDriver scenarios, you should interact with you app and then collect results, if properties or something is changed.



    But if you want execute some code on your page, you can use this:
    Code:
    ST.execute(function(){
     alert('I am a captain now.'); });
    ST.execute and your test are two separate parts, keep it in mind

    Feel free to contact me any time.
    Vojtěch

  6. #5
    Sencha User vojtech.cerveny's Avatar
    Join Date
    Jun 2015
    Location
    Ostrava, Czech republic
    Posts
    52
    Answers
    10

    Default

    I am not sure about ExtJS 2.x, because ST supports ExtJS 4+, but code should be similar.

    You are able to return some variables from execute and send it forward. Then you are able work with it and put it into an assertion.

    For example:
    Code:
    ST.button('button')
        .press()
        .execute(function (button) {
            return button.pressed; 
        })
        .and(function () {
            expect(this.future.data.executeResult).toBeTruthy();
        });
    or

    Code:
    ST.button('button')
        .press()
        .get('pressed')  // more properties should be here
        .and(function () {
            expect(this.future.data.pressed).toBeTruthy();
        });
    Just for case - we talk about WebDriver scenario, if you have InBrowser scenario, it is easier.

    I hope that will help.

    Vojtěch
    “Testers don’t like to break things; they like to dispel the illusion that things work.”— Kaner, Bach, Pettichord

Similar Threads

  1. Sync futures and playable
    By Wilky in forum Q&A
    Replies: 2
    Last Post: 12 Sep 2016, 12:23 AM
  2. Promises and Deferreds/Futures in Ext JS?
    By Debug in forum Community Discussion
    Replies: 23
    Last Post: 25 Mar 2016, 12:06 PM
  3. How dinamically remove Ext.ux.touch.grid futures
    By tino7_03 in forum Sencha Touch 2.x: Discussion
    Replies: 1
    Last Post: 12 Jan 2012, 7:01 AM
  4. [DUP] VType fields disable navigation keys in Opera
    By benczi in forum Ext:Bugs
    Replies: 2
    Last Post: 23 Nov 2011, 8:12 AM
  5. Testing with EXT GWT Grid with input fields
    By kai_tea in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 1 Sep 2009, 3:35 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
  •