I'm using the Selenium IDE add on in Firefox to generate automated tests of my wicket application. All I have to do is browse my website and it will generate Java code that I can use as a starting point for a test. Such as

   selenium.open("/customersSearch.html");
   selenium.type("customerName13", "smith");
   selenium.click("searchButton14");
   selenium.waitForPageToLoad("30000");
   verifyTrue(selenium.isTextPresent("No Customer Exists With That Name"));

The customerName13 and searchButton14 are ids of a TextField and IndicatingAjaxButton on my HTML page. These IDs are both generated by wicket based off of the original component ids. The main issue that I'm running into is that since wicket generates unique IDs based off of a counter the test is very fragile. If I add a component at the top of the page (or as of wicket 1.4 on a previous page) then the IDs all change and my test breaks. Selenium does have the ability to search based off of an elements name attribute so I could go through and manually change the generated code to use it but it's a bit of a pain. Also, if I have an AjaxButton in a repeater (such as a list of customers) then there is no easy way of selecting it other then off of the ID. I thought about calling setMarkupId() for all of my components but it's a bit of a pain to have to do it for every component that might get tested and doesn't work in things like repeaters.

I was wondering if there would be a problem with changing the generated IDs so that the first instance of a component with an ID of "customerName" on a page would have a generated ID of "customerName", the second would be "customerName2" and so on. This would make the IDs consistent enough that they could be used for testing.

John

Reply via email to