Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid.getField() issue for field with same name as a method of 'fields' object

    I believe I have encountered an issue with 'reserved field names' when trying to execute Selenium tests against my application. It is a basic application with a single ListGrid and 5 columns. Everything in the app seems to work okay.

    When using the SCLocator/Autotest to look up a value in the ListGrid by column name, I get null for one particular column ('size'), while the rest of the them produce the expected results.
    i.e.:
    Code:
    isc.AutoTest.getElement('//ListGrid[ID="myGrid"]/body/row[0]/col[fieldName=label]');
    works fine, while:
    Code:
    isc.AutoTest.getElement('//ListGrid[ID="myGrid"]/body/row[0]/col[fieldName=size]');
    yields null.

    Going through a debugger I traced the issue to the listGrid.getField() method. It starts with:
    Code:
    getField : function (id) {
        if (this.fields == null || id == null) return null;
    
        var field;
    
        if (this._noNumericFields) {
            field = this.fields[id];
            if (field != null) return field;
        } else {
            // Number: assume index.
            if (isc.isA.Number(id)) return this.fields[id];
    When the isc.AutoTest call gets to this method, the 'id' parameter is the column name specified in the locator.

    this._noNumericFields is true, so field = this.fields[id].

    In the case of a field named 'size', this.fields['size'] returns a function (method of the fields object). For the other columns it is null and later code returns the desired field.

    Looking at the 'fields' object, there are a whole number of functions for which this could occur, like 'contains, create, duplicate, first, ...' -- all the methods that make sense on a field collection.

    I did not spend enough time to understand the _noNumericFields logic but it looks like perhaps a shortcut to save further isc.isA.Number, isc.isA.String, etc testing against the 'id' for a numbered column. Would removing this check cause a performance problem elsewhere?

    It is easy enough to avoid by renaming the field to something that is not a method of 'fields', but I have found it convenient to use the same name as the property in my data.

    I am using SmartClient Version: v9.0p_2014-01-05/LGPL Deployment, but the code looks the same in the 10.0d.

    Thanks for the great product!

    #2
    Thanks for the report and analysis. We've made a change to address this issue in both 9.0p and 9.1d branches. Please try the next nightly build dated Feb 7 or above

    Regards
    Isomorphic Software

    Comment

    Working...
    X