Sunday, March 1, 2009

Selenium: setting an ID on GWT widgets

Selenium is an automated testing tool for web applications. If you are using Selenium test cases for GWT (Google web Toolkit), you need to set the ID's on UI widgets. Each clickable HTML element should have an ID set using the ensureDebugId("my_id"); method. Make sure to use this ID once ONLY:

Label userName = new Label("User Name:");
userNameInput = new TextBox();
userNameInput.setStyleName("textbox");
userNameInput.ensureDebugId("userNameID");


In your gwt.xml file, include:

com.google.gwt.user.Debug