Hi there!
As you’ve noticed, Selenium doesn’t work “as-is” with Vaadin. The biggest problem is the lack of wide enough support for ajax in Selenium. When you click on something, it waits unti the page has finished loading in the traditional web fashion (“loading…” text in the bottom corner of most browsers) before doing the next step of the test. With vaadin, all of the loading happens in javascript after the initial load. Thus, Selenium doesn’t understand when something is still loading, and will think that it is always ready. This means that it will perform all the actions in the test way too fast, and it will fail because the application doesn’t keep up. I guess this is a problem when using ajax frameworks with Selenium.
Luckily, Vaadin has a fix for this. It has a own version, extension, out of Selenium called TestBench, where code has been coded in both Vaadin and Selenium, making them understand each others. Testbench’s UI is identical to Selenium IDE, and it also has an extension to Selenium RC.
Another feature is that Testbench has a better handling of the DOM tree than Selenium, which will make it more robust to changes. Selenium produces DOM paths like this:
//div[@id='sampler-1864843272']
/div/div[2]
/div/div[2]
/div/div/div/div[1]
/div/div/div[1]
/div/div/div/div[2]
/div/div/div/div[1]
/div[2]
/div/div[2]
/div/table/tbody/tr[18]
/td[2]
/div
while Testbench does this:
vaadin=sampler::/VVerticalLayout[0]
/ChildComponentContainer[1]
/VSplitPanelHorizontal[0]
/VPanel[0]
/VGridLayout[0]
/AbsolutePanel[0]
/ChildComponentContainer[1]
/VButton[0]
on the same UI component. Let’s say I change the page by adding a new label at top of the page. This will cause one more div somewhere in the Selenium path and the test will break. In Testbench, it would produce a VLabel between ChildComponentContainer and VButton. As the test does not look for a label, it looks for a button, it will work even if there is something new somewhere in between. You can take this even one step longer and put into java button.setDebugId(“theButtonIWantToPress”); and the Testbench url would look something like:
vaadin=sampler::/theButtonIWantToPress
. That’ll work what ever changes you do around the components your testing. No need to re-record.
The third benefit with Testbench is a jar file for your project. You can save your tests in html, save them into your project. and you have the ability to translate them into Java on the fly with Testbench for jUnit integration. Thus, you can give them to some testing server, like cruiseControl for daily testing. You can do the html->java conversion in Selenium IDE as well, but you can’t change them back to html and modify the test after you have converted it.
There was the good news. Here comes the ‘not as good as that’-news. Testbench is not licenced under Apache Licence and open source, like Vaadin. One of the benefits of getting the support package from the company behind Vaadin is getting Testbench, along with many others.You can find more information about Testbench from
here.
Contact us on this forum or contact me directly if you wish to know more.
Best regards,
Jens.