In my application, I have an element for records displayed on the screen. So on the first page, it will say something like "displaying 1-10 of 2100". This is the CSS for that element, and it works in all browsers.
span.GridPagingInfo
In my application, which is in an iframe, I need to change pages and wait for the page to be loaded before continuing. The element that I previously mentioned is the last element on the page, so I am using that for my waits. Since its on the bottom, if it is displayed, then the information I need to continue my tests is loaded.
When I am changing pages, the text of that element changes. So if I go to the 2nd page, it will say "displaying 11-20 of 2100". I am waiting for the text to change before continuing my tests. Below is the code I am using
//verify text of the element
String actualText = driver.findElement(By.cssSelector("span.GridPagingInfo")).getText();
Assert.assertEquals(actualtext, "displaying 1-10 of 2100");
//Go to next page by clicking the Next button
driver.findElement(By.cssSelector("th.GridPaging button.ViewMore")).click();
//wait for text of the element to change
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("span.GridPagingInfo"), "displaying 11-20 of 2100"));
I have also tried
wait.until(ExpectedConditions.invisibilityOfElementWithText(By.cssSelector("span.GridPagingInfo"), "displaying 1-10 of 2100"));
When I try this, it works in every browser except Firefox. When I run my tests in Firefox, the test will time out on the wait with an error saying that it could not find the text. When I watch the test, the application goes to the next page, the element is there, the text I want is there, but Selenium says it cannot find it. I have tried rolling back to previous versions of Firefox, but that did not help.
- Firefox version - 33
- IE version - 11
- IE Driver - 2.44
- Chrome version - 39
- Chrome Driver - 2.11
- Selenium Server - 2.44.0.jar