javainternet-explorer-8selenium-webdriverinternet-explorer-9

Webdriver Assertions fails in IE


I have ~50 automated test cases that works like a charm in both Chrome and Firefox, but IE just won't do it (too bad IE is required).

IE fails at assertions (not all assertions, but a vast majority of them) because (I think) it tries to assert too quickly, e.g. the page is not rendered fast enough.

Here is a piece of code that works in Chrome and FF, but not IE:

driver.manage().timeouts().implicityWait(30, TimeUnit.SECONDS);
driver.navigate().to(targetAdminServer());
Assert.assertTrue("The startpage is displayed", driver.getTitle().startsWith("Admin Portal -"));
driver.findElement(By.id("loginForm:j_id4:username")).sendKeys(loginSAUsername());
driver.findElement(By.id("loginForm:j_id6:password")).sendKeys(loginSAPassword());
driver.findElement(By.id("loginForm:login")).click();
Assert.assertTrue("Login successful", driver.getTitle().contains("Welcome,"));

Where I get the following error:

java.lang.AssertionError: Login successful
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at first.example.project.webdriver.AddUser.I_am_logged_in_as_a_administrator(AddUser.java:36)
at ✽.Given I am logged in as a "administrator"(C:\path\cucumberfeature1.feature:5)

What I can see during execution is that webdriver fills the fields with username and password and then dies right after clicking the login button.

UPDATE: I may add that if I add a Thread.sleep(1000) before the Assertion that fails it works just fine.

UPDATE2: A friend asked me if it might be because that IE usually runs at 32-bit while the rest of the browsers runs at 64-bit (since I have a 64-bit OS), could this have anything to do with it?

UPDATE3: Tried with both 64-bit and 32-bit IEDriverServer, but none of them asserted in time.


Solution

  • After login click you need some wait for element.
    When title will be changed you could check, but not before that event.