Driver does not wait for page to load to proceed

Asked

Viewed 66 times

1

Hi, I’m using Selenium to run some tests and then export the code to the eclipse. I’m trying to gettext a page that uses ajax using xpath, and then I’m trying to authenticate with assertTrue, but I’m not getting the page to fully load before proceeding to these steps (gettext and assertTrue), searched a lot on google and stackoverflow, found different solutions to the problem, tried many but none worked.

@Test
public void a1_testAuthenticationFailureWhenProvidingBadCredentials() throws InterruptedException{
    driver.findElement(By.name("_58_login")).sendKeys("adma");
    driver.findElement(By.name("_58_password")).sendKeys("Password");
    driver.findElement(By.xpath("//button")).click();

    WebDriverWait wait = new WebDriverWait(driver, 240);
    //waitForJStoLoad();

    //WebDriverWait wait = new WebDriverWait(driver, 240);
    //wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//form[@id='_58_fm']/fieldset/div/div[3]")));

    String ggg = driver.findElement(By.xpath("//form[@id='_58_fm']/fieldset/div/div[3]")).getText();


    assertTrue(driver.findElement(By.xpath("//form[@id='_58_fm']/fieldset/div/div[3]")).equals("Authentication failed. Please try again."));
}

NOTE: it returns error in assertTrue.

  • Try using Wait.until but you have to put until the element is visible and not present

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.