Based on the assumption that the most stable part of the web application to be tested is the human readable semantic elements. Write test scripts as if describing to a user (over the phone or in documentation) what to click, type etc. So your tests should not need altering if you move your HTML around or change to/from links to buttons etc.
robot.click("create user");
robot.set("Name", "Sam");
robot.click("Gender", "male");
robot.click("save");
robot.back();
assertEquals("Sam", robot.get("Name"));
assertTrue(robot.isSelected("Geek", "yes"));
Use
<dependency>
<groupId>com.redspr.redrobot</groupId>
<artifactId>redrobot-core</artifactId>
<version>0.2.21</version>
</dependency>
##Theory Your tests should only depend on the very simple com.redspr.redrobot.Robot interface which is based on the conversation you would have with your most stupid user. A simple algorithm is used to find the best match element based on one or more matching strings.
##Supported semantics
##Implementation Behind the simple Robot interface an implementation using WebDriver? is provided. There is legacy support for direct HtmlUnit? and Selenium 1 but this is being phased out.