Announcement

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

    #16
    I never found the issue tracker, so I ended up adding an ugly hack to the user-extensions file.

    Something like this:
    Code:
    var isSCLocator = locator && 
                            ((locator.substring(0, "scLocator".length) == "scLocator") ||
                             (locator.substring(0, "scID".length) == "scID")),
            element = this.page().findElement(locator);
        if(this.hasSC() && isSCLocator) { ...

    Comment


      #17
      Originally posted by elopio
      I never found the issue tracker, so I ended up adding an ugly hack to the "ug" user-extensions file.
      ...
      Hi elopio, could you share your modified user-extension.js or post the whole "ugly hack" to the thread cause right now I can see that you have posted exactly the same code used in regular SmartGWT user-extension?
      My email is vbaibus@gmail.com
      Thank you!
      Last edited by vbaibus; 5 Apr 2011, 07:49.

      Comment


        #18
        You can find it here:
        http://code.openbravo.com/tools/auto...-extensions.js

        The section I posted was added to the type function.
        I never solved the first problem of the getTable function. As we don't use it to access smartclient tables, I just commented it out so it doesn't override the original getTable.
        Last edited by elopio; 5 Apr 2011, 08:09.

        Comment


          #19
          Hi, elopio,

          Which version of smartGWT and selenium you are using?

          I just encounter the same problem.
          I am using selenium1.0.11 and smartGWT2.4
          and I want to record the content TextItem(just the login system).
          However, I got the problem:" [error] Unexpected Exception: message -> invalid array length, fileName ->"

          It waste me a lot of time ....
          I just follow this link"http://rhq-project.org/display/RHQ/Testing+SmartGWT+with+Selenium#TestingSmartGWTwithSelenium-Setup"
          But it not work...

          Thx~

          Comment


            #20
            I reply myself.
            I wanted to use auto record to test UI.
            But the recorder didn't use scLocator, so just modify the target to scLocator.
            Mission complete...

            Comment


              #21
              Originally posted by elopio View Post
              Hello,

              I'm having a problem with the getTable function when I have sc user extensions loaded.

              This is a part of the interface that doesn't use smartclient, so I expect it to work just as it does without the user extensions. But with the user extensions it fails.

              I don't really know how to explain this better. Perhaps with code...

              This:
              selenium.getTable(xpath=//table[@id='tableX'].0.2)

              without the user extensions returns the text of the cell in row 0, column 2.

              with user extensions returns an empty string and this warning is sent to console:
              WARNING: getString(getTable) saw a bad result OK

              As I'm not using a scLocator, selenium should be using orig_getTable. But it is clearly not working.

              Any suggestion?

              thanks.
              I tool a look at the user-extensions.js file and it seems the method of locating a table by just its ID is broken. I've patched the getTable method in the extensions file as so:-

              Code:
              Selenium.prototype.orig_getTable = Selenium.prototype.getTable;
              
              Selenium.prototype.getTable = function(tableCellAddress) {
              /**
               * Gets the text from a cell of a table. The cellAddress syntax
               * tableLocator.row.column, where row and column start at 0.
               *
               * @param tableCellAddress a cell address, e.g. "foo.1.4"
               * @return string the text from the specified cell
               */
              
                  if(this.hasSC()) {
                      // This regular expression matches "tableName.row.column"
                      // For example, "mytable.3.4"
                      var pattern = /(.*)\.(\d+)\.(\d+)/;
              
                      if(!pattern.test(tableCellAddress)) {
                          throw new SeleniumError("Invalid target format. Correct format is tableLocator.rowNum.columnNum");
                      }
              
                      var pieces = tableCellAddress.match(pattern);
              
                      var tableName = pieces[1];
                      var row = pieces[2];
                      var col = pieces[3];
              
                      var element = this.browserbot.findElement(tableName);
              
                      var autWindow = this.getAutWindow();
              
                      var listGrid = autWindow.isc.AutoTest.locateCanvasFromDOMElement(element);
                      if(listGrid == null) {
                          return Selenium.prototype.orig_getTable.call(this, tableCellAddress);
                      }
                      //the locator can return a GridBody
                      if(listGrid.grid) {
                          listGrid = listGrid.grid;
                      }
                      
                      LOG.debug("Found ListGrid " + listGrid.getClassName());
                      
                      var record = listGrid.getRecord(Number(row));
                      LOG.debug("Record for row " + row + " is " + record);
              		
              		if(listGrid.getCellValue) {
              			return listGrid.getCellValue(record, row, col);
              		} else {
              			return Selenium.prototype.orig_getTable.call(this, tableCellAddress);
              		}
              		
                  } else {
                      return Selenium.prototype.orig_getTable.call(this, tableCellAddress);
                  }    
              };
              and it's working for me now. Basically if the type of object returned from SC doesn't have a getCellValue() method then go and get the table using native methods.
              Last edited by chris.melikian; 14 Nov 2012, 01:52. Reason: code formatting

              Comment


                #22
                OK, we'll update user-extensions.js as suggested. It looks like you (immediately above) posted code from 82, so we'll patch back to SC 8.2.

                Comment

                Working...
                X