WebDriver no hace clic de manera confiable en enlaces o botones

He estado tratando desesperadamente de hacer que WebDriver haga clic en un botón o enlace de manera confiable, pero simplemente no quiere cooperar. He intentado diferentes métodos, desde establecer un tiempo de espera implícito, hasta el siguiente código, que se supone que debe hacer clic y esperar a que aparezca el elemento.

El fragmento de código a continuación se encontró en algún lugar de Internet, y es lo más cerca que he estado de obtener de manera confiable un botón o enlace para hacer clic. Excepto que no funciona igual en modo de depuración que cuando se ejecuta durante mis pruebas de regresión nocturna.

¿Alguien sabe de otro método para hacer clic en un botón o enlace en un navegador? ¿O debería usar Selenium 1 y no WebDriver, ya que es demasiado nuevo para usarlo de manera confiable?

public void waitAndClick(WebDriver driver, By by) {
    WebDriverWait wait = new WebDriverWait(driver, 10000, 2000);
    Function<WebDriver, Boolean> waitForElement = new waitForElement(by);
    wait.until(waitForElement);

    Actions builder = new Actions(driver);
    builder.click(driver.findElement(by))
            .perform();
}

private class waitForElement implements Function<WebDriver, Boolean> {
    private final By by;

    private String text = null;

    public waitForElement(By by) {
        this.by = by;
    }

    public waitForElement(By by, String text) {
        this.by = by;
        this.text = text;
    }

    @Override
    public Boolean apply(WebDriver from) {
        if (this.text != null) {
            for (WebElement e : from.findElements(this.by)) {
                if (e.getText().equals(this.text)) {
                    return Boolean.TRUE;
                }
            }

            return Boolean.FALSE;
        } else {
            try {
                driver.switchTo().defaultContent().switchTo().frame("top");
                from.findElement(this.by);
            } catch (Exception e) {
                logger.error("Unable to find \"" + this.by.toString() + "\". Retrying....");
                return Boolean.FALSE;
            }
            logger.info("Found \"" + this.by.toString() + "\".");
            return Boolean.TRUE;
        }
    }
}

Console en modo de depuración de Eclipse:

16:07:08,109 INFO  WebDriverUtility: apply Found "By.linkText: Classes".
16:07:10,514 INFO  WebDriverUtility: apply Found "By.linkText: Reports".
16:07:17,028 ERROR WebDriverUtility: apply Unable to find "By.linkText: Users". Retrying....
16:07:26,369 INFO  WebDriverUtility: apply Found "By.linkText: Users".
16:07:38,272 ERROR WebDriverUtility: apply Unable to find "By.linkText: System". Retrying....
16:07:41,334 INFO  WebDriverUtility: apply Found "By.linkText: System".
16:07:47,722 ERROR WebDriverUtility: apply Unable to find "By.linkText: Schools". Retrying....
16:07:50,565 INFO  WebDriverUtility: apply Found "By.linkText: Schools".

Console fuera cuando se ejecuta desde Eclipse:

16:14:04,179 INFO  WebDriverUtility: apply Found "By.linkText: Classes".
16:14:04,726 INFO  WebDriverUtility: apply Found "By.linkText: Reports".
16:14:09,771 INFO  PageAPITesting: login org.openqa.selenium.NoSuchElementException: Unable to find element with link text == Reports (WARNING: The server did not provide any stacktrace information)
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.0rc3', revision: '12536', time: '2011-06-20 18:19:52'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_24'
Driver info: driver.version: RemoteWebDriver
16:14:09,865 INFO  PageAPITesting: login current tabs is Classes
16:14:09,958 INFO  WebDriverUtility: apply Found "By.linkText: Schools".
16:14:10,240 INFO  PageAPITesting: login java.lang.IllegalStateException: Unable to navigate to the ca.schoolspecialty.qa.api.pages.schools.MenuSchoolPage page

Respuestas a la pregunta(1)

Su respuesta a la pregunta