java - Firefox 32 或 33 预计可以与 Selenium RC 一起使用吗?

标签 java firefox selenium selenium-rc

只是想问为什么 Selenium RC 无法与最新的 Firefox 版本一起使用?

这是代码(groovy):

import org.openqa.selenium.server.*;
import com.thoughtworks.selenium.DefaultSelenium
import com.thoughtworks.selenium.Selenium
import com.thoughtworks.selenium.SeleniumException
import com.thoughtworks.selenium.Wait
import java.util.concurrent.TimeUnit


RemoteControlConfiguration rcc = new RemoteControlConfiguration()
System.out.println("Using firefox launcher")
File ffp = new File("C:\\Work\\ff_custom_profile")
rcc.setFirefoxProfileTemplate(ffp)
rcc.setPort(4444)

seleniumServer = new SeleniumServer(rcc)
seleniumServer.start()

System.out.println("Server started")

Selenium seleniumInstance = new DefaultSelenium("localhost", 4444, "firefox", "https://url/")
seleniumInstance.start()

System.out.println("Driver started");

当我使用 Firefox 28 (Windows 7 x86) 运行此代码时,它工作正常:

Using firefox launcher
20:46:35.692 INFO - Java: Sun Microsystems Inc. 20.14-b01
20:46:35.692 INFO - OS: Windows 7 6.1 x86
20:46:35.723 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
20:46:36.020 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
20:46:36.020 INFO - Version Jetty/5.1.x
20:46:36.020 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
20:46:36.035 INFO - Started HttpContext[/selenium-server,/selenium-server]
20:46:36.035 INFO - Started HttpContext[/,/]
20:46:36.067 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1114460
20:46:36.067 INFO - Started HttpContext[/wd,/wd]
20:46:36.067 INFO - Started SocketListener on 0.0.0.0:4444
20:46:36.067 INFO - Started org.openqa.jetty.jetty.Server@15e0873
Server started
20:46:36.160 INFO - Checking Resource aliases
20:46:36.191 INFO - Command request: getNewBrowserSession[firefox, https://url/, ] on session null
20:46:36.207 INFO - creating new remote session
20:46:36.238 INFO - Allocated session 640d3bf362ab4840ad7c3f3ac2b5695d for https://url/, launching...
jar:file:/C:/Work/TMP/selenium-server-standalone-2.43.1.jar!/customProfileDirCUSTFFCHROME
20:46:36.925 INFO - Preparing Firefox profile...
20:46:38.127 INFO - Launching Firefox...
20:46:41.537 INFO - Got result: OK,640d3bf362ab4840ad7c3f3ac2b5695d on session 640d3bf362ab4840ad7c3f3ac2b5695d
Driver started

但是当我使用 Firefox 32 或 33 (Windows 7 x86) 运行此代码时,我得到以下结果:

Using firefox launcher
20:49:26.467 INFO - Java: Sun Microsystems Inc. 20.14-b01
20:49:26.467 INFO - OS: Windows 7 6.1 x86
20:49:26.467 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
20:49:26.576 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
20:49:26.576 INFO - Version Jetty/5.1.x
20:49:26.591 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
20:49:26.591 INFO - Started HttpContext[/selenium-server,/selenium-server]
20:49:26.591 INFO - Started HttpContext[/,/]
20:49:26.607 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@1114460
20:49:26.607 INFO - Started HttpContext[/wd,/wd]
20:49:26.623 INFO - Started SocketListener on 0.0.0.0:4444
20:49:26.623 INFO - Started org.openqa.jetty.jetty.Server@15e0873
Server started
20:49:26.669 INFO - Checking Resource aliases
20:49:26.669 INFO - Command request: getNewBrowserSession[firefox, https://url/, ] on session null
20:49:26.669 INFO - creating new remote session
20:49:26.685 INFO - Allocated session 740dfe19fd58418db02be166c420516d for https://url/, launching...
jar:file:/C:/Work/TMP/selenium-server-standalone-2.43.1.jar!/customProfileDirCUSTFFCHROME
20:49:27.247 INFO - Preparing Firefox profile...
20:49:28.386 INFO - Launching Firefox...

请注意输出中的差异:使用 Firefox 28,Selenium 客户端成功启动...

20:46:41.537 INFO - Got result: OK,640d3bf362ab4840ad7c3f3ac2b5695d on session 640d3bf362ab4840ad7c3f3ac2b5695d

...在 Firefox 32 或 33 中失败。

我进行了一些实验,发现通过更改 Firefox 配置文件 (prefs.js) 中的以下设置,可以使其在 FF 32 或 33 中工作:

user_pref("browser.startup.homepage_override.mstone", "33.1.1");

如果我将其更改为我的 FF 28 配置文件 (16.0.2) 中的值:

user_pref("browser.startup.homepage_override.mstone", "16.0.2");

然后,就可以正常工作了。但我不喜欢这个 hack 有两个原因:

  1. 当我使用脚本进行此更改后打开 Firefox 时,它会打开 Whatsnew 页面 ( https://www.mozilla.org/en-US/firefox/33.1.1/whatsnew/?oldversion=16.0.2 ),这对于自动化来说非常烦人。

  2. 当我手动进行此更改后打开 Firefox 时,此设置将返回到之前的值 (33.1.1),并且故事从头开始。

我尝试了不同的 Selenium RC 版本(2.41、2.42、2.43),结果相同。

使用 Firefox 32 和 33 以及 Selenium RC 2.44,我收到以下错误:无法启动新的浏览器 session :java.lang.RuntimeException:java.lang.RuntimeException:在路径中找不到 Firefox!请将包含“firefox.exe”的目录添加到您的 PATH 环境中。

好吧,我将代码更改为...

Selenium seleniumInstance = new DefaultSelenium("localhost", 4444, "*firefox C:\Program Files\Mozilla Firefox\firefox.exe", "https://url/"

...并遇到与上述 Selenium 2.42 和 2.43.1 相同的失败。

问题来了:为什么 Firefox 32 或 33 不能与 Selenium RC 一起使用,以及如何让它工作?

注意:我确实意识到迁移到 Selenium 2 (WebDriver) 是有意义的,但由于某些原因,我需要在当前状态下支持此遗留代码。

最佳答案

通常,selenium 会在浏览器更新后不久发布更新版本的客户端。关注the downloads page .

关于java - Firefox 32 或 33 预计可以与 Selenium RC 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27175898/

相关文章:

c# - Selenium 网络驱动程序 : Specify filepath for Firefox exe

java - 如何向 Axis2 服务添加基本身份验证?

c# - Firefox Selenium 驱动程序

javascript - 在 Firefox 插件中模拟击键

javascript - 如何使用 Web Crypto 生成 key 对并在 Firefox AddOn 中访问其 key ?

c# - 使用 selenium 和 NUnit 在多个浏览器上测试框架

java - 如何在 Java 中调用一些带有超时的阻塞方法?

java - 删除随机生成的 UUID 中的 "-"有多安全?

java - 警告 : [rawtypes] found raw type: DefaultListModel

java - Selenium Webdriver (Java) 无法单击 AJAX 按钮