3我正在使用 selenium-server-standalone-2.33.0.jar 来启动 selenium 测试套件。我有一个在 Firefox 和 Internet Explorer 中运行良好的测试套件。当我尝试在 Google Chrome 中运行它时,它对当前用户运行良好。当我尝试从本地系统用户运行测试(打开以本地系统用户身份运行的命令窗口)时,测试失败,给我一个 windows 注册表异常。这是我要运行的命令:
java -jar selenium-server-standalone-2.33.0.jar -port 5885 -htmlsuite "*googlechrome" "http://www.google.com" "TestSuite.html" "results.html"
这是我得到的例外:
HTML suite exception seen:
java.lang.RuntimeException: org.openqa.selenium.os.WindowsRegistryException: Problem while managing
the registry, OS Version '6.1', regVersion1 = false
Build info: version: '2.33.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_38'
Driver info: driver.version: unknown
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(
BrowserLauncherFactory.java:175)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(Bro
wserLauncherFactory.java:109)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.getBrowserLauncher(HTMLLauncher.java:7
9)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:139)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:198)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:630)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)
Caused by: org.openqa.selenium.os.WindowsRegistryException: Problem while managing the registry, OS
Version '6.1', regVersion1 = false
Build info: version: '2.33.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_38'
Driver info: driver.version: unknown
at org.openqa.selenium.os.WindowsUtils.executeCommand(WindowsUtils.java:558)
at org.openqa.selenium.os.WindowsUtils.runRegQuery(WindowsUtils.java:627)
at org.openqa.selenium.os.WindowsUtils.readStringRegistryValue(WindowsUtils.java:447)
at org.openqa.selenium.os.WindowsUtils.getLocalAppDataPath(WindowsUtils.java:274)
at org.openqa.selenium.browserlaunchers.locators.GoogleChromeLocator.usualWindowsLauncherLoc
ations(GoogleChromeLocator.java:64)
at org.openqa.selenium.browserlaunchers.locators.GoogleChromeLocator.usualLauncherLocations(
GoogleChromeLocator.java:50)
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.browserDefaultPath(Sin
gleBrowserLocator.java:93)
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.findAtADefaultLocation
(SingleBrowserLocator.java:81)
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.findBrowserLocation(Si
ngleBrowserLocator.java:50)
at org.openqa.selenium.browserlaunchers.locators.SingleBrowserLocator.findBrowserLocationOrF
ail(SingleBrowserLocator.java:38)
at org.openqa.selenium.server.browserlaunchers.BrowserInstallationCache.locateBrowserInstall
ation(BrowserInstallationCache.java:46)
at org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.<init>(GoogleChromeLaunc
her.java:67)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(
BrowserLauncherFactory.java:164)
... 8 more
Caused by: java.lang.RuntimeException: exec return code 1:
ERROR: The system was unable to find the specified registry key or value.
at org.openqa.selenium.os.WindowsRegistryException.<init>(WindowsRegistryException.java:35)
... 25 more
最终我想允许 selenium 作为服务运行,所以我需要 Chrome 在本地系统帐户下工作。据我了解,selenium 独立 jar 文件应该已经包含一个 google chrome 驱动程序,所以我应该没有理由需要下载它。
此外,在运行测试套件时出现错误之前,我需要将 Google Chrome 添加到我的路径变量中。我这样做了,但我得到了上述错误,所以似乎 selenium 可以找到 chrome.exe,它只是在获取一些不存在的注册表项或在找到 chrome 后无法启动 chrome 时遇到问题。我为所有用户安装了 chrome,因此 Google chrome 安装在 Program Files (x86) 中。同样,当从我当前的帐户(我用来安装 chrome 的那个)以管理员权限运行时,chrome 测试通过。在这个问题上的任何帮助都会很棒!