ZK + Selenium + JUnit = AJAX Unit Testing

Discussions

News: ZK + Selenium + JUnit = AJAX Unit Testing

  1. ZK + Selenium + JUnit = AJAX Unit Testing (5 messages)

    Running automated test against application is an essential part in development of enterprise applications. In this article Luca introduce an easy way to unit testing ZK application using Selenium>/a> and JUnit. As an example Luca will test the ZK Demo Application. Selenium is a unit testing suite composed by a unit test runner Selenium Remote Control, some client library for different languages , a firefox plugin to record macro and an eclipse plugin for visual building test. Selenium Remote Control is a server that waits for command from a client and control a browser to perform action against a target web application. In this small talk, Luca will explain how start up the Selenium Remote Control and write a simple client in java to test some feature of the Zk demo application. Selenium IDE for Firefox is an useful plugin to test step-by-step your macros. Read the full text.

    Threaded Messages (5)

  2. I am not sure - why this article mentions that you have to "configure" browser proxy settings yourself. At least on windows - Selenium RC will automatically do it for you. Also the "selenium java" code will be automatically generated by "recording tool" - Selenium IDE (which you can tweak) You can check my blog at http://www.jroller.com/selenium
  3. Not at all specific to ZK[ Go to top ]

    There's nothing really specific to ZK here, which is disappointing. The example code has lots of redundancy and looks to be a potentially brittle test. Right from the start, there are currently 2 divs in the demo with the text "Paging": one under "Listboxes" and one under "Trees". While this seems to work due to Selenium picking the first result from the XPath query, this would break if the sections were rearranged. The XPath query should be written to find the div containing "Paging" contained in or following the div containing "Listboxes". Probably the most obvious problem, though, is how the text input for the onChanging event test is located: find the element with the label text, walk back 3 levels, then find any contained input. This could easily break given a modest change to the page layout, or potentially even an update to ZK. Why not just use the id of the text input? Probably because the id looks something like "z_hb_465", which is arbitrary at best, and looks like it could vary from run to run. This makes Selenium tests difficult to write. I'm not very familiar with ZK. I've only briefly looked at it due to the volume of news here (though I did file a bug about the onChanging event demo page). What I was hoping to see was the ability to query for components based on the ids given to them when they're defined in the source. Finally, it would be nice to be able to tie more directly into the ZK event model rather than coding timeouts using Thread.sleep(). Again, the technique presented is not specific to ZK, which is disappointing. I think for Selenium testing of a ZK application to be "easy", there would need to be a ZK-aware layer between the test code and Selenium.
  4. Re: Not at all specific to ZK[ Go to top ]

    There's nothing really specific to ZK here, which is disappointing. The example code has lots of redundancy and looks to be a potentially brittle test.
    Yes, I think the title was not good, I think the purpose was to show using Selenium to test an ZK Application
    Why not just use the id of the text input? Probably because the id looks something like "z_hb_465", which is arbitrary at best, and looks like it could vary from run to run. This makes Selenium tests difficult to write.
    You could set id so there will not be an vary from run to run in name, in addition there is an way to tell ZK to "Customize the Generation of UUIDs".
  5. Re: Not at all specific to ZK[ Go to top ]

    Hi, I'm the one who write the small talk. The article want to introduce Selenium as tool to test Zk.In our company we have used selenium + zk with two different strategies: 1 - As described in the Grinder article, we wrote our Id generator, but we found that it was hard to maintain. Inserting somethin before the textbox you want to fill in can change the id. 2 - We modify dsp: In our applications we use only customized components. In the dsp we add z.id="#{self.id}" so that every component has an attribute called z.id that is unique. Then we modify Selenium ide: in locatorBuilders.js and we added a new locator: LocatorBuilders.add('z.id', function(e) { if (e.hasAttribute('z.id')) { if (e.getAttribute("z.id")) { return '//' + e.nodeName + '[@z.id=\'' + e.getAttribute("z.id") + '\']'; } } return null; }); and changed the order of locators in the end of file to first use z.id locator. With this mods we were able to record test without having to modify before running. The problem is that this require a rebuild of zk or the creation of a lot of custom components. The code in the article looks so redundant because is generated automatically by selenium ide.
  6. By coincidence there is very similar article on Ext-js blog posted just a couple of weeks before. http://extjs.com/blog/2008/11/03/testing-ext-js-ext-gwt-applications-with-selenium/ lol