Blog do projektu Open Source JavaHotel

poniedziałek, 5 lipca 2010

Selenium

It is high time to start creating regression testing suite for my GWT application. The choice is Selenium, well known framework for testing web application. I decided also to use Python and PythonUnit together with my BoaTester as RC testing framework. For some mysterious reason NetBeans plugin for Python does not work with PythonUnit in debugging mode, cannot set breakpoint inside unittest classes. But a little ancient IDLE framework for Python behaves nicely, it is enough for a such small development.
As for every GUI application the main challenge is to locate GUI objects on the screen - a nightmare for every test automation engineer. Instead of fighting with constant changing object description on the screen I decided simply to tune my application that every "selectable" object should have it's distinct name or id.
It can be accomplished by setting proper value for every object. For instance: for buttons following command should be applied:
Button but;
.... 
but.getElement().setId(bId);
Another challenge is of course to synchronize test with RPC. For the time being this synchronization is accomplished by time.sleep(5) command (wait 5 seconds), but obviously more sophisticated method should be devised in near future.
Another challenge was the selecting rows in a table - I'm using Google Visualization Table. For some reason clicking on the row is not captured by Selenium IDE so I could not use it as an advice. But finally Selenium command :
s = "xpath=//table[@class='google-visualization-table-table']/tbody/tr[" + str(no) + "]/td"
sel.mouse_over(s)
resolved that issue.
I also found that preparing test case is very time consuming effort and can be accomplished mostly by method "try and fix". Preparing a test containing 10-15 steps and 3-4 verification points takes 2-3 hours and I don't have any idea how to make this task simpler.
May be the solution is to create a solution that will replace Python sequence like:
        sel.click(self.TESTOWYREJBUTTON)
        time.sleep(5);
        sel.click(self.ADDBUTTON)
       
        sel.type(self.TEXT1, "aa")
        sel.type(self.TEXT2, "aa")
        sel.type(self.KWOTA, "35")
        sel.click(self.ACCEPT);
        time.sleep(5)
        sel.mouse_over(self.TEXT1)
        mess = sel.get_text("xpath=/html/body/div[3]/div/div")
        print mess
        self.failUnless(mess.find("Obydwa napisy") != -1)
        sel.type(self.TEXT2, "a")
        sel.click(self.ACCEPT);
        time.sleep(5)
with a simple text file which will read all steps and verification points from flat text file thus avoiding this hard code Python programming.

Brak komentarzy:

Prześlij komentarz