Search code examples
sencha-testsencha-test-2.1

Method to clear pre-filled data of a ST.future.Component


Is there a way to clear an input field while using the ST.component("locator"); API?

Using ST.component("locator").setValue(""); results in the following error:

TypeError: ST.component(...).setValue is not a function...




PS: Is the old forum now permanently closed? Is there a way to view older questions?

Edit: Seems like the other forum was down yesterday, therefore the PS.


Solution

  • If it's an Ext JS field you will need to use the ST.field API in Sencha Test, which has a setValue method. This method isn't available on the more generic ST.component API.

    ST.field('myfield')
        .setValue('');
    

    Or if it's a normal input field (not an Ext JS component), then you can do the following:

    ST.element('@myfield')
        .execute(function(field) {
            field.dom.value = '';
        });