0

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
TestRaptor
  • 1,305
  • 8
  • 24
  • 42
  • Your code should work. It's a mystery as why it isn't. Nevertheless, please try one thing. The "span tag" must be coming under a "div" or "a" tag, which is in fact its parent. So, formulate the code so that you retrieve innerHTML/text from the parent, and then check for the invisibility of the text **"displaying 1-10 of 2100"** in it. – Subh Nov 25 '14 at 17:00
  • Why does this question have a downvote. If you just downvote a question without any explanation, the person asking the question doesn't know what to fix. – TestRaptor Dec 02 '14 at 16:19

1 Answers1

0

I have no idea why this fixed the issue, but here is what I did. I just changed the timeout from 30 to 45 and everything worked fine. In Firefox, the page loads in a second, so I don't know why it was timing out after 30. Anyway, changing to 45 fixed the issue in Firefox.

TestRaptor
  • 1,305
  • 8
  • 24
  • 42