WebDriver 无法在 Firefox 4 及更高版本上运行测试

发布于 2024-12-22 11:10:20 字数 2742 浏览 5 评论 0原文

最近我面临一个奇怪的问题。我正在使用 WebDriver 进行 GWT Web 应用程序的测试自动化。 (这是 Maven 3 项目)我只对 Firefox 浏览器执行测试。只要我使用 Firefox 3.6,一切都会正常工作

。每当我尝试使用从 FF4 到 FF8 的较新版本的 Firefox 运行测试时,就会出现问题。每当我运行测试时,我得到的都是元素未找到异常,对于我尝试查找、单击、读取等的所有内容。 使用不同类型的定位器(id、类名、名称)进行任何类型的搜索都会导致:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"SOME_ID"}; duration or timeout: 31 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
...
Driver info: driver.version: RemoteWebDriver

更重要的是,它只发生在我的应用程序中,因为当我编写一个访问 google.com 的快速测试并搜索一些内容时,一切都运行良好。

有人遇到过类似的问题吗?我的网络应用程序有问题吗?也许我应该在某个地方改变一些东西?我只是不知道什么以及在哪里?也许较新的 Firefox 需要一些 gwt 应用程序配置文件? 如果有任何帮助的话,这是我的 POM 文件:

 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>WebTests</groupId>
<artifactId>WebTests</artifactId>
<version>1.0</version>

<!--START:repositories -->
<repositories>
    <repository>
        <id>selenium-repository</id>
        <url>http://selenium.googlecode.com/svn/repository/</url>
    </repository>
</repositories>
<!--END:repositories -->

<!--START:dependencies -->
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.13.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-parent</artifactId>
        <version>2.13.0</version>
        <type>POM</type>
    </dependency>

    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion</artifactId>
        <version>1.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion-extensions</artifactId>
        <version>1.0.1</version>
    </dependency>

</dependencies>
<!--END:dependencies -->

Recently I am facing a strange problem. I am using WebDriver for test automation for GWT web application. (It's Maven 3 project) I am performing tests only for Firefox browser. Everything works fine as long as I use Firefox 3.6

Problems start whenever I try to run tests with newer version of Firefox starting from FF4 to FF8. Whenever i run my tests all I get is element not found exception for everything I try to locate, click, read etc.
Any kind of searching using different kinds of locators (id, classname, name) results in:

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"SOME_ID"}; duration or timeout: 31 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
...
Driver info: driver.version: RemoteWebDriver

What is more it happens just with my application because when I wrote a quick test that goes to google.com and searches for some stuff everything worked well.

Has anyone faced similar problem? Is there something wrong with my webapp? Maybe I should change something somewhere? I just don't know what and where? Maybe some gwt app profile is needed for newer firefox?
If it is any help here's my POM file:

 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>WebTests</groupId>
<artifactId>WebTests</artifactId>
<version>1.0</version>

<!--START:repositories -->
<repositories>
    <repository>
        <id>selenium-repository</id>
        <url>http://selenium.googlecode.com/svn/repository/</url>
    </repository>
</repositories>
<!--END:repositories -->

<!--START:dependencies -->
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.13.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-parent</artifactId>
        <version>2.13.0</version>
        <type>POM</type>
    </dependency>

    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion</artifactId>
        <version>1.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion-extensions</artifactId>
        <version>1.0.1</version>
    </dependency>

</dependencies>
<!--END:dependencies -->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

柠檬 2024-12-29 11:10:20

我们在项目中遇到了同样的问题,也像您一样使用 Maven 等。

我尝试了几个 Firefox 版本,但似乎即使是最新版本的 selenium 也不支持 3.x 版本以上的 Firefox

我们刚刚在集成服务器上安装了 3.x 版本,并且可以接受它。

We had the same problem in our project, also using Maven etc as you are.

I tried several Firefox versions, but it seems even the latest version of selenium does not support Firefox beyond version 3.x

We just installed version 3.x on our integration server and we live with it.

一花一树开 2024-12-29 11:10:20

当您更新 Firefox 时,可能您忘记更改的函数或类的名称发生了更改。

你在谷歌浏览器上尝试过你的代码吗?

When you update firefox, maybe there was a change in names of functions or classes which you forgot to change.

Did you try your code on google Chrome?

属性 2024-12-29 11:10:20

我建议更新到较新的 Selenium - 因为浏览器集成紧密,WebDriver 对 ABI 的更改很敏感。

I would recommend to update to newer Selenium - because of tight browser integration WebDriver is sensitive to changes in ABI.

甜妞爱困 2024-12-29 11:10:20

我再次尝试了一些不同的方法。但它仍然是一样的,页面启动得很好,每当我尝试定位任何元素时,它都会失败并出现 nosuchelementException 。在 Firefox 4.0 及更高版本上是相同的,在 IE 7,8 上也是相同的。

好吧,我想我会回到 3.6 并接受它:)

I tried again a little bit different approach. Yet still it is the same, page gets launched just fine and whenever i try to locate any element it fails with nosuchelementexception. It is the same on Firefox 4.0 and higher and also the same on IE 7,8.

Well I guess that I'll just go back to 3.6 and live with it :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文