Announcement

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

    Htmlunit tests for ListGrid

    Hello all,

    I'm a beginner in SmartGWT and I started to work on automatic tests for SmartGWT GUI. I'm trying to simulate click on a row in a table which should take me to the other page:
    ...
    def xPathTable = "//table//*"
    myPage.getByXPath(xPathTable).each { elem ->
    def page = elem.click()
    synchronized (page) {
    page.wait(500) //ms
    }
    if (page?.asText()?.contains('myString')) {
    println elem
    }
    }

    But, nothing happens for none of the elements I got in xPathTable, click doesn't seem to work here.
    Can someone help?

    SmartClient version is SC_SNAPSHOT-2011-08-02/LGPL Development Only (built 2011-08-02)

    Additionally, what do you suggest as the best way to test ListGrid behaviour using htmlunit?

    Thanks in advance!

    #2
    I'm interested in this subject as well and have just seen that the subject has been mentioned earlier (http://tinyurl.com/7dks2em):

    "Sorry, we missed that you were trying to use GWTTestCase - this basically won't work, it's not a real browser" (Isomorphic)

    From this, it appears that htmlunit tests simply won't work with SmartGWT components. I'm a bit disappointed by this because htmlunit definitely behaves as a "real browser" in interaction with a large part of the web (so I would disagree with Isomorphic there), although its clear that Isomorphic has to allocate resources to each browser it decides to support.

    I understand SmartClient has some support for Selenium and it's better than no support for testing, but Selenium can't be controlled by Maven, can't run headless, requires that we support two web testing technologies instead of one (Selenium doesn't even attempt to try to replace htmlunit), might not be able to report results in a way easy for us to post-process...

    Would love to hear if Isomorphic still takes the same position on the subject.

    Comment


      #3
      Yes, we do still take this position, because all of your assertions about Selenium are incorrect - you need to learn about Selenium RC, which is how you can set up, for example, a full suite of Selenium tests to run automatically every time a change is committed to source control (which is what we do at HQ).

      Trying to create a test methodology around a synthetic browser whose bugs are different from real browsers is a good way to waste time chasing non-bugs while real bugs go undetected. Stick to Selenium.

      Comment


        #4
        Thank you for the quick and precise reply, my apologies for spreading misinformation.

        Indeed, Selenium RC seems to provide a high level of automation, but it comes at quite a price: starting what are effectively heavyweight browser processes to interact with tested apps, replacing the simplicity of a single library with quite a lot of infrastructure...

        At least now it's clearer where the trade-offs are.

        Comment


          #5
          Be sure to actually try it, the test runs don't take as long as you might guess.

          And of course there's no substitute for actually running a browser when you want to know if there's actually a bug :)

          See also SauceLabs.com for Selenium RC in the cloud.

          Comment


            #6
            By the way, it's been a long time since I first read this comparison between WebTest (based on htmlunit) and Selenium and some of the points have become moot, but a lot of it is still applicable and it doesn't favour Selenium:

            http://mguillem.wordpress.com/2007/10/29/webtest-vs-selenium-webtest-wins-13-5/

            As you said, we're going to give it a try and see how it fares: than we'll make the decision to go with SmartGWT + Selenium, other web frameworks + htmlunit or other alternatives...

            Comment


              #7
              Originally posted by Isomorphic
              And of course there's no substitute for actually running a browser when you want to know if there's actually a bug :)
              Of course. :)

              Comment


                #8
                Amazingly, every single one of the points raised in that article against Selenium is incorrect and several were incorrect at the time the article was written. This is predictable, as the source is a WebTest committer trying to explain why he thinks his approach is better than the de-facto standard.

                Picking some other UI technology in order to use HTMLUnit would not only be "the tail swinging the horse" it would also be a bad decision on test frameworks, considered in isolation.

                The more you learn, the more obvious this should become.

                Comment


                  #9
                  I took your advice and started to use Selenium, but i still have problems with some elements.

                  For example, I have 3 buttons on my page, all defined in the same way:

                  Code:
                  <td align="center" valign="center" nowrap="true" onfocus="isc_IButton_0_label.$47()" tabindex="-1" style="padding-top:0px;padding-bottom:0px;" class="buttonTitle">Filter</td>
                  
                  <td align="center" valign="center" nowrap="true" onfocus="isc_IButton_1_label.$47()" tabindex="-1" style="padding-top:0px;padding-bottom:0px;" class="buttonTitle">Reset</td>
                  
                  <td align="center" valign="center" nowrap="true" onfocus="isc_IButton_2_label.$47()" tabindex="-1" style="padding-top:0px;padding-bottom:0px;" class="buttonTitle">Create Project</td
                  I managed to execute 'click' command on Reset and Filter button without any problems, but 'click' on Create project button doesn't work. It should take me to the new page, but it just doesn't.
                  Here is Selenium code that was used. No errors are occured, but also no required action is done.

                  Code:
                  <tr>
                  	<td>waitForTextPresent</td>
                  	<td>Create Project</td>
                  	<td></td>
                  </tr>
                  <tr>
                  	<td>click</td>
                  	<td>xpath=(//td[@class='buttonTitle' and contains(.,'Create Project')])</td>
                  	<td></td>
                  </tr>
                  Second thing is that I still cannot click on a row in ListGrid table.

                  Code:
                  <td align="center" height="22" class="cellDark" style="padding-top: 0px; padding-bottom: 0px; width: 259px; overflow: hidden; font-weight: bold;"><div style="overflow:hidden;WIDTH:255px;" cellclipdiv="true" role="presentation"><nobr>PRJ_NAME_110</nobr></div></td>
                  Same problem - 'click' command passes ok, but it does not take me to the new page as it should.
                  Selenium:

                  Code:
                  <tr>
                  	<td>waitForTextPresent</td>
                  	<td>PRJ_NAME_110</td>
                  	<td></td>
                  </tr>
                  <tr>
                  	<td>click</td>
                  	<td>xpath=(//td[@class='cellDark' and contains(.,'PRJ_NAME_110')])</td>
                  	<td></td>
                  </tr>
                  What am I doing wrong?

                  Comment


                    #10
                    What you're doing wrong is not reading the docs :)

                    Start with the Automated Testing overview in the "docs" JavaDoc package. We include Selenium extensions with the product and your tests are not using them.
                    Last edited by Isomorphic; 27 Mar 2012, 10:58.

                    Comment

                    Working...
                    X