jeudi 5 novembre 2015

HtmlUnitDriver is unable to interact with elements.

i'm trying to run a headless test but HtmlUnitDriver is unable to interact with elements properly. However if I run the same code with FirefoxDriver the test interacts perfectly with the elements on the web. Someone knows why?

It's just an example test to start working with HtmlUnitDriver, but i can't run a this simple test:

public class htmlunitdriver {

    public static void main(String[] args) {

        WebDriver driver = new HtmlUnitDriver(); 
        //WebDriver driver = new FirefoxDriver();

        driver.get("http://localhost:8888/WORK/sugarpro7521/");
        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.name("username")));
        driver.findElement(By.name("username")).sendKeys("example");
    }
}

I get TimeOutException in this case or NoSuchElementException if i write an implicit wait or a Thread.sleep() instead of the explicit wait.

Can someone help me with this? Thank you.

Aucun commentaire:

Enregistrer un commentaire