title: Selenium Testing of GWT 2.0
body: <p>How can I make a selenium click() work the same as a manual mouse click?</p>
  
  <p>I have recently upgraded GWT from 1.7.1 to 2.0. Some selenium tests (SeleniumRC v1.0.1, IE7) are now failing. It seems that the Selenium.click() method is not selecting a GWT TreeItem. A manual click will make the TreeItem go blue (ie. look selected and have "gwt-TreeItem-selected" class attribute in the DOM), but the selenium test doesn't. </p>
  
  <p>I'm convinced that selenium is actually finding the right element, just not clicking on it. If you change the string parameter in the click method you can check that selenium throws an exception when the element isn't found.</p>
  
  <p>The sample code below uses the GWT Showcase website. It tries to click on the word "Beethoven". If you click on that word with your mouse, you'll see the TreeItem go blue. However when you run the selenium test, it won't.</p>
  
  <pre><code>package test;
  
  import org.junit.Before;
  import org.junit.Test;
  
  import com.thoughtworks.selenium.DefaultSelenium;
  import com.thoughtworks.selenium.Selenium;
  
  public class TestTreeClick {
      static Selenium selenium = null;
  
      @Before
      public void setUp() throws Exception {
          if (selenium == null) {
              selenium = new DefaultSelenium("localhost", 4444, "*iexplore",
                      "http://gwt.google.com/samples/Showcase/Showcase.html#CwTree");
              selenium.start();
          }
      }
  
      @Test
      public void testingClicking() {
          selenium.open("http://gwt.google.com/samples/Showcase/Showcase.html#CwTree");
          selenium.click("gwt-debug-cwTree-staticTree-root-child0-content");
      }
  }
  </code></pre>
  
  <p>I have tried some other methods (Selenium.clickAt(), Selenium.fireEvent(), Selenium.mouseOver()/Down()/Up() ) - but none reproduce the manual behaviour.</p>