Announcement

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

    NoSuchMethodException on multiple commands when using SeleneseRunner

    I cannot convert the following test case with the lastest version of the SeleneseRunner from here http://www.smartclient.com/product/download.jsp.

    First of all the & in the url are not converted to &s when opening the URL.

    The bigger problem is that every time setSpeed, sendKeys and store are called I get NoSuchMethodExceptions
    java.lang.NoSuchMethodException: No match for: sendKeys(By.scLocator: //Window[ID='FeverchartSearchIncludingAlternativesWindow']/item[0][Class='VLayout']/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=simvastatin%3A101||index=0||Class=TextItem]/element/ByScLocator, ${KEY_ENTER}/String)
    at com.isomorphic.webdriver.Operation.execute(Operation.java:146)
    at com.isomorphic.webdriver.SeleneseTestCaseParser.visitTag(SeleneseTestCaseParser.java:74)
    at org.htmlparser.tags.CompositeTag.accept(CompositeTag.java:470)
    at org.htmlparser.tags.CompositeTag.accept(CompositeTag.java:479)
    at org.htmlparser.tags.CompositeTag.accept(CompositeTag.java:479)
    at org.htmlparser.tags.CompositeTag.accept(CompositeTag.java:479)
    at org.htmlparser.Parser.visitAllNodesWith(Parser.java:728)
    at com.isomorphic.webdriver.SeleneseRunner.parseEntry(SeleneseRunner.java:260)
    at com.isomorphic.webdriver.SeleneseRunner.main(SeleneseRunner.java:210)
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head profile="http://selenium-ide.openqa.org/profiles/test-case">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="selenium.base" href="http://wkhts100alt:9280/" />
    <title>testcase6</title>
    </head>
    <body>
    <table cellpadding="1" cellspacing="1" border="1">
    <thead>
    <tr><td rowspan="1" colspan="3">testcase6</td></tr>
    </thead><tbody>
    <tr>
        <td>setSpeed</td>
        <td>1000</td>
        <td></td>
    </tr>
    <tr>
        <td>store</td>
        <td>b_20160531_1</td>
        <td>az</td>
    </tr>
    <tr>
        <td>open</td>
        <td>/eMedicClient/residentialMedication.jsp?user=berger&amp;az=b_20160531_1&amp;isPilotMode=false&amp;showheader=true</td>
        <td></td>
    </tr>
    <tr>
        <td>waitForElementClickable</td>
        <td>scLocator=//ToolStripButton[ID=&quot;searchBtn&quot;]/icon</td>
        <td></td>
    </tr>
    <tr>
        <td>click</td>
        <td>scLocator=//ToolStripButton[ID=&quot;searchBtn&quot;]/icon</td>
        <td></td>
    </tr>
    <tr>
        <td>waitForElementClickable</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=simvastatin%3A101||index=0||Class=TextItem]/element</td>
        <td></td>
    </tr>
    <tr>
        <td>type</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=simvastatin%3A101||index=0||Class=TextItem]/element</td>
        <td>simvastatin:101</td>
    </tr>
    <tr>
        <td>waitForElementReadyForKeyPresses</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=simvastatin%3A101||index=0||Class=TextItem]/element</td>
        <td></td>
    </tr>
    <tr>
        <td>sendKeys</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=simvastatin%3A101||index=0||Class=TextItem]/element</td>
        <td>${KEY_ENTER}</td>
    </tr>
    <tr>
        <td>waitForElementClickable</td>
        <td>scLocator=//ListGrid[ID=&quot;FeverchartSearchIncludingAlternativesResultGrid&quot;]/body/row[medname=Simvastatin%20Rtp%20Ftbl%2020mg||add=add.png||1]/col[fieldName=add||5]</td>
        <td></td>
    </tr>
    <tr>
        <td>click</td>
        <td>scLocator=//ListGrid[ID=&quot;FeverchartSearchIncludingAlternativesResultGrid&quot;]/body/row[medname=Simvastatin%20Rtp%20Ftbl%2020mg||add=add.png||1]/col[fieldName=add||5]</td>
        <td></td>
    </tr>
    <tr>
        <td>waitForElementClickable</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=voltaren%3A111||index=0||Class=TextItem]/element</td>
        <td></td>
    </tr>
    <tr>
        <td>type</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=voltaren%3A111||index=0||Class=TextItem]/element</td>
        <td>voltaren:111</td>
    </tr>
    <tr>
        <td>sendKeys</td>
        <td>scLocator=//Window[ID=&quot;FeverchartSearchIncludingAlternativesWindow&quot;]/item[0][Class=&quot;VLayout&quot;]/member[Class=HLayout||index=0||length=3||classIndex=0||classLength=3]/member[Class=DynamicForm||index=0||length=2||classIndex=0||classLength=1]/item[name=searchTextItem||title=Suchtext||value=voltaren%3A111||index=0||Class=TextItem]/element</td>
        <td>${KEY_ENTER}</td>
    </tr>
    </tbody></table>
    </body>
    </html>

    #2
    We've fixed the issue with SeleneseRunner not being able to translate sendKeys(). However, the reason setSpeed() and store() aren't translated is that they don't have analogues in WebDriver. If you've written your original script properly, using waitForElementClickable(), waitForGridDone(), etc., there shouldn't be any issue with commands being processed too fast, and thus no need for setSpeed(). For store(), the obvious way to handle it is to just use a Java variable - we don't currently provide such translation in SeleneseRunner.

    The fixes that were made will be applied to SC 11.0p and newer, and will be in the nightly builds dated 2016-06-04. (You haven't stated which release you're using - please include that information.)

    Comment


      #3
      Thank you for your response. I'm now using the nightly build from yesterday.

      &amp; is now translated to & as expected.

      sendKeys is translated but special key characters like ${ENTER_KEY} are not translated. The placeholders for the keys like ${ENTER_KEY} are generated by SeleniumIDE, not me. It would be nice if SeleneseRunner could translate that too.

      I've found that contextMenu, a common command in SeleniumIDE, can not be translated either. I think the matching command in the WebDriver is contextClick but I'm not sure.

      Comment


        #4
        A few more things:
        • Unsuccessful click commands are not translated to Java code. WaitForElementClickable is written but click is not, not even as comment.
        • Typing only numbers is translated to type(ByScLocator(...), 111) instead of type(..., "111")
        • The open command is translated to the method "open". The driver's method is called get, not open.
        • keyPress(..., 13) is not translated to driver.keyPress(..., 13L);
        Last edited by stefan_berger; 6 Jun 2016, 04:04.

        Comment


          #5
          I've decompiled the JAR file and found that com.isomorphic.webdriver.Operation.toJavaString() writes this.operator to the file instead of convertSeleneseToWebDriver(operator). Either you could say this.operator = convertSeleneseToWebDriver(this.operator) or call the convert method in the toJavaString method.

          Code:
          private String toJavaString(Object operand)
            {
              if ((operand instanceof ByScLocator)) {
                return ((ByScLocator)operand).toJavaString();
              }
              if ((operand instanceof String)) {
                return "\"" + operand.toString() + "\"";
              }
              return operand.toString();
            }
          in the same class could be changed to
          Code:
          private String toJavaString(Object operand)
            {
              if ((operand instanceof ByScLocator)) {
                return ((ByScLocator)operand).toJavaString();
              }
              if ((operand instanceof String)) {
                return "\"" + operand.toString() + "\"";
              }
              if ((operand instanceof Long)) {
                  return operand.toString() + "L";
              }
              return operand.toString();
            }
          Last edited by stefan_berger; 6 Jun 2016, 06:21. Reason: Added a fix for Long parameters.

          Comment


            #6
            We've made substantial improvements to SeleneseRunner for SC 11.0p and newer. The changes will be in the nightly builds dated 2016-06-09 and beyond.

            Note that you can now generate WebDriver code without executing against a live WebDriver instance, but you'll obviously then not detect any runtime failures.

            Some limitations may be still be present. If there is a significant issue with the new behavior, follow up in this thread.

            Comment


              #7
              Thank you for your tip about not having to execute the test.

              I've tested with yesterday's nightly build and everything can be converted correctly. Longs and Keys are successfully parsed.

              Just one more thing: In SeleniumIDE commands like "verifyTable" can be generated with right clicks which can be executed in the Selenium IDE. There is no method verifyTable in the driver, though. Would it be possible to parse that command into a SmartClientWebDriver.verifyTable method?

              For example the following method which was generated as a comment:
              driver.verifyTable(ByScLocator.scLocator("//ListGrid[ID='NewFutureWorkOrdersGrid'].2.5"), "<span align='center' title='Noch nicht vorbereitet' class='dosageBoxXXL'><span style='font-weight:bold;'>1-1-1-P</span></span>");

              It would save us much time during the test generation if that command was available.
              Last edited by stefan_berger; 13 Jun 2016, 22:08.

              Comment


                #8
                By the way: Should I create new topics regarding Selenium in Technical Q&A or SmartGWT Technical Q&A? I'm not sure which one to use.

                Comment


                  #9
                  Unless it's the same issue, a separate thread should be created. These were closely related so it probably could have gone either way.

                  We've added verifyTable() and getTable() to SmartClientWebDriver and updated SeleneseRunner to be able to call these new APIs. Note that as in Selenium v1, verifyTable() verifies against the "text" or display value of the associated cell, rather than the "Framework value" used by getValue(). Thus in fact our implementation of verifyTable() ultimately calls getText() on the appropriate cell.

                  The change will be applied to SGWT 5.1p/SC 10.1p and newer, and will be in the nightly builds dated 2016-06-16 and beyond.

                  Comment


                    #10
                    Originally posted by Isomorphic View Post
                    Note that as in Selenium v1, verifyTable() verifies against the "text" or display value of the associated cell, rather than the "Framework value" used by getValue(). Thus in fact our implementation of verifyTable() ultimately calls getText() on the appropriate cell.
                    The thing is: The generated value for verifyTable in SeleniumIDE is usually not the text but the Framework value.

                    In our application there is a grid where I want to verify whether a certain image is present. verifyTable is generated with the value "<img src="signature_discharge.png" />". The AutoTest.getText called by SmartClientWebDriver.verifyTable returns signature_discharge.png instead.

                    The WebDriver's verifyTable should also use autWindow.isc.AutoTest.locateCanvasFromDOMElement(e).getCellValue(record, row, col).

                    It would be nice if there was an option for generating commands which check the DOM content of elements. Without that you can't even check if certain buttons are enabled or certain images are displayed and so on.

                    The workflow I want to have is:
                    • Record a test in SeleniumIDE with verifies on Text, Values and Selenium values
                    • Parse with SeleneseRunner to a WebDriver test method
                    • Replace some constants with dynamic values in scLocators
                    • Execute the test
                    Last edited by stefan_berger; 21 Jun 2016, 05:18.

                    Comment


                      #11
                      I have edited getTable so it would display the behaviour it should have.

                      Code:
                          public String getTable(final By scLocator, final long row, final long col) {
                              final WebElement element = this.findElement(scLocator);
                              if (element == null) {
                                  return null;
                              }
                              final String cellScLocator = (String)this.js.executeScript("return isc.AutoTest.getTableLocator(arguments[0],arguments[1],arguments[2])", new Object[] { element, row, col });
                              final String script = "var e = isc.AutoTest.getElement(arguments[0]);"
                                      + "grid = isc.AutoTest.locateCanvasFromDOMElement(e);"
                                      + "if (grid == null || !grid.isA(\"GridRenderer\")) "
                                      + "return \"a\";"
                                      + "var cellXY = grid.getCellFromDomElement(e);"
                                      + "if (cellXY == null) "
                                      + "return \"b\";"
                                      + "var row = Number(cellXY[0]),col = Number(cellXY[1]);"
                                      + "if (grid.grid) {"
                                      + "col  = grid.grid.getFieldNumFromLocal(col, grid);"
                                      + "grid = grid.grid;"
                                      + "}"
                                      + "var record = grid.getCellRecord(row, col),text = grid.getCellValue(record, row, col);"
                                      + "return text";
                              
                              
                              final String value = (String)this.js.executeScript(script, new Object[] { cellScLocator });
                              return value;
                          }
                      The Javascript is just a part of the user-extension-ide.js. You can find it in the second Command.builders.map(function (binding) {... .

                      Comment


                        #12
                        Originally posted by stefan_berger View Post

                        The thing is: The generated value for verifyTable in SeleniumIDE is usually not the text but the Framework value.
                        Then that's a bug, since as we mentioned, it's designed to verify the HTML content or "text" just as if the Selenium IDE getText() API were called targeting that cell.

                        Can you provide a way for us to reproduce this error?



                        Comment


                          #13
                          1. Go to http://www.smartclient.com/smartgwt/...id_header_span
                          2. Right click on any flag and select verifyTable
                          3. Take a look at the generated command
                          The check value for verifyTable in SeleniumIDE is <img src='http://www.smartclient.com/smartgwt/showcase/images/flags/16/US.png' width='16' height='16' align='TEXTTOP' border='0' suppress='TRUE' draggable='true'/> which can be executed without problems in SeleniumIDE. The WebDriver returns "US" instead.

                          What the WebDriver should return is grid.getCellValue(...), not the text.
                          Last edited by stefan_berger; 21 Jun 2016, 22:24.

                          Comment


                            #14
                            This should be fixed for SGWT 5.1p/SC 10.1p and newer in today's builds (dated 2016-06-23).

                            Comment


                              #15
                              When I call verifyTable it throws an Exception stating that isc.Autotest.getTableLocator is undefined.

                              I am using the latest build of SmartGWT 5.1p. Even on the Showcase sites like http://www.smartclient.com/smartgwt/...namic_grouping isc.AutoTest.getTableLocator is undefined.

                              Comment

                              Working...
                              X