Webdriver - 等待在Firefox中不工作 [英] Webdriver - waits not working in Firefox

查看:179
本文介绍了Webdriver - 等待在Firefox中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个显示在屏幕上的记录元素。所以在第一页上,会显示显示2100的1-10。这是该元素的CSS,它可以在所有浏览器中使用。

  span.GridPagingInfo 


当我改变页面时,那个元素的文本会改变。所以如果我去第二页,会显示显示2100的11-20。在继续我的测试之前,我正在等待文本改变。下面是我使用的代码

  //验证元素的文本
String actualText = driver.findElement(By .cssSelector( span.GridPagingInfo))的getText();
Assert.assertEquals(actualtext,显示2100的1-10);
//点击下一步按钮转到下一页
driver.findElement(By.cssSelector(th.GridPaging button.ViewMore))。click();
//等待元素的文本改变
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector(span.GridPagingInfo),Showing 2100 of 2100));

我也曾尝试过

  wait.until(ExpectedConditions.invisibilityOfElementWithText(By.cssSelector(span.GridPagingInfo),display 1-10 of 2100)); 

当我尝试这个功能时,它可以在除Firefox以外的所有浏览器中使用。当我在Firefox中运行我的测试时,测试将会等待,并等待一个错误,说它找不到文本。当我观看测试时,应用程序进入下一页,元素在那里,我想要的文本在那里,但是Selenium说它找不到它。我试着回滚到之前版本的Firefox,但是没有帮助。
$ b


  • Firefox版本 - 33

  • IE版本 - 11
    < Chrome浏览器驱动程序 - 2.11

  • Chrome浏览器版本 - 39

  • 2.44.0.jar

    解决方案

    我不知道为什么这样解决了这个问题,是我做的。我只是将超时从30更改为45,一切正常。在Firefox中,页面加载一秒钟,所以我不知道为什么它是在30之后超时。无论如何,改为45固定在Firefox的问题。

    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

    解决方案

    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.

    这篇关于Webdriver - 等待在Firefox中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆