views:

34

answers:

1

I'm using webdriver to test a site. Event delegation is being used across a number of links to load data via ajax:

     jQuery("body").delegate("a",
                             "click",
                             function adjustHref(event) {
                                // callback
                             });

In the test I'm then clicking on links with webdriver:

     WebElement anchor = headlines.get(0).findElement(By.tagName("a"));
     anchor.click();
     WebElement articleHeader = wait.until(new VisibilityOfElementLocated(By.tagName("h1")));

Now this will work as expected in Chrome and IE but in Firefox it will sometimes fail. Whereas in other browsers anchor.click() will navigate to a new page but in firefox it will sometimes work and sometimes fail. No exception is thrown so the element anchor has been found but webdriver clicking on it nothing happens. This is only a problem with webdriver, using the site manually works fine. Does webdriver have any limitations with event delegation in firefox?

A: 

I found the problem was that my link text was wrapping onto two lines and the anchor.click was clicking in the wrong location. By making the browser larger the text didn't wrap and the click was correctly located.

slashnick