Driver does not wait for the page to load to proceed

1

Hello, I'm using Selenium to do some testing and then exporting the code to eclipse. I'm trying to get a getText on 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), I looked a lot in google and in StackOverflow, I found different solutions to the problem, I 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.

    
asked by anonymous 25.01.2017 / 19:01

0 answers