I’m having problems getting going with CFSelenium/TestBox. I’m developing on a Windows 7 VM, Coldfusion 10. I’ve downloaded a fresh copy of cfselenium from https://github.com/teamcfadvance/CFSelenium/archive/master.zip.
我在使用CFSelenium / TestBox时遇到了问题。我正在开发一个Windows 7 VM,Coldfusion 10.我从https://github.com/teamcfadvance/CFSelenium/archive/master.zip下载了一份新的cfselenium副本。
My file structure is
我的文件结构是
wwwroot |
cfselenium |
Selenium-RC |
Selenium-server-standalone-2.46.0.jar
Selenium.cfc
Server.cfc
Testbox |
… various testbox files
MySite |
Tests|
Specs |
… my test files
seleniumtest.cfc
Application.cfc
Index.cfm
MySite/Test/Application.cfc includes mappings for both testbox/ and cfselenium/.
MySite / Test / Application.cfc包括testbox /和cfselenium /的映射。
The test suite, seleniumtest.cfc extends testbox.system.BaseSpec, and its beforeAll() and afterAll() functions instantiate selenium, start it, and tear it down:
测试套件seleniumtest.cfc扩展了testbox.system.BaseSpec,它的beforeAll()和afterAll()函数实例化了selenium,启动它并将其拆除:
component extends="testbox.system.BaseSpec" {
function beforeAll( ){
// create Selenium class
selenium = new cfselenium.Selenium();
// Start it up.
selenium.start( "mysite", "*chrome" );
}
// executes after all suites+specs in the run() method
function afterAll(){
selenium.stop();
selenium.stopServer();
}
function run( testResults, testBox ){
describe('selenium', function(){
// hello world equivalent
describe('equality', function(){
it('true should be true', function(){
expect( true ).toBe(true);
});
});
});
}
}
New behavior: when passing the following to selenium.start():
新行为:将以下内容传递给selenium.start()时:
selenium.start( "https://www.google.com", "*googlechrome" );
I get the following error:
我收到以下错误:
The Response of the Selenium RC is invalid: Failed to start new browser session: java.lang.RuntimeException: org.openqa.selenium.os.WindowsRegistryException: Problem while managing the registry, OS Version '6.1', regVersion1 = false Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03' System info: host: 'myhostname', ip: 'myvm_ip_address', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_67' Driver info: driver.version: unknown
Selenium RC的响应无效:无法启动新的浏览器会话:java.lang.RuntimeException:org.openqa.selenium.os.WindowsRegistryException:管理注册表时出现问题,操作系统版本'6.1',regVersion1 = false构建信息:版本:'2.42.2',修订版:'6a6995d',时间:'2014-06-03 17:42:03'系统信息:主机:'myhostname',ip:'myvm_ip_address',os.name:'Windows 7 ',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_67'驱动程序信息:driver.version:unknown
For all other url or browser versions I pass to selenium.start() (I've tried '*chrome', '*firefox', '*iexplore', '*iexploreproxy'), I get the following error:
对于我传递给selenium.start()的所有其他网址或浏览器版本(我试过'* chrome','* firefox','* iexplore','* iexploreproxy'),我收到以下错误:
The Response of the Selenium RC is invalid: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser
Selenium RC的响应无效:无法启动新的浏览器会话:org.openqa.selenium.server.RemoteCommandException:启动浏览器时出错
From the stack trace, I can see that it fails at selenium.DoCommand().
从堆栈跟踪中,我可以看到它在selenium.DoCommand()失败。
From another SO post, it was suggested that if port 4444 was currently in use, it could interfere with the selenium-RC server. I restarted my VM and verified that port 4444 was not in use by running
从另一篇SO帖子中可以看出,如果当前正在使用4444端口,它可能会干扰selenium-RC服务器。我重新启动了我的VM并通过运行验证了端口4444没有被使用
Netstat –an | find “4444”
After again running the test suite, running netstat with the same command showed
再次运行测试套件后,运行带有相同命令的netstat显示
TCP 0.0.0.0:4444 0.0.0.0:0 LISTENING
TCP 127.0.0.1:4444 127.0.0.1:49209 ESTABLISHED
TCP 127.0.0.1:49209 127.0.0.1:4444 ESTABLISHED
TCP [::]:4444 [::]:0 LISTENING
TCP [::1]:4444 [::1]:49208 ESTABLISHED
TCP [::1]:49208 [::1]:4444 ESTABLISHED
From looking at cf logs, I see the following:
从查看cf日志,我看到以下内容:
Apr 29, 2016 09:44:23 AM Information [ajp-bio-8012-exec-3] - Starting HTTP request {URL='http://localhost:4444/selenium-server/driver/', method='POST'}
2016年4月29日上午09:44:23信息[ajp-bio-8012-exec-3] - 启动HTTP请求{URL ='http:// localhost:4444 / selenium-server / driver /',method ='POST “}
Is there supposed to be a selenium-server folder under wwwroot? Is that the webdriver?
在wwwroot下应该有一个selenium-server文件夹吗?那是webdriver吗?
EDIT: Per Dan's answer, I've downloaded chromedriver_win32 from http://chromedriver.storage.googleapis.com/index.html?path=2.21/, extracted to C:\Program Files (x86)\chromedriver, added that to my PATH, and rebooted the VM. After changing the driver from '*googlechrome' to '*chrome', it seems to work... I was able to run the following test successfully:
编辑:Per Dan的回答,我从http://chromedriver.storage.googleapis.com/index.html?path=2.21/下载了chromedriver_win32,解压缩到C:\ Program Files(x86)\ chromedriver,添加到我的PATH,并重新启动VM。将驱动程序从'* googlechrome'更改为'* chrome'后,它似乎正常工作......我能够成功运行以下测试:
function testIncludes(){
selenium.open("https://www.google.com");
$assert.isEqual("Google", selenium.getTitle());
}
So I think we're on our way here.
所以我想我们正在这里。
Seem to have IE driver working as well.
似乎IE驱动程序也可以运行。
1 个解决方案
#1
3
Selenium can't launch Chrome without Chrome Driver (as Chrome is no longer part of webkit) and Selenium can only launch webkit browsers by default. You should be able to launch Firefox (if it's installed) without needing any additional binaries.
如果没有Chrome驱动程序,Selenium无法启动Chrome(因为Chrome不再是webkit的一部分),Selenium默认只能启动webkit浏览器。您应该能够启动Firefox(如果已安装),而无需任何其他二进制文件。
To get Chrome working you will need to do the following:
要让Chrome正常运行,您需要执行以下操作:
- Download the chrome driver bin.
- 下载chrome驱动程序bin。
- Add it to your path.
- 将其添加到您的路径中。
- Selenium should be able to launch the browser.
- Selenium应该能够启动浏览器。
There may be some other issues in the code, but I feel like the comments have provided enough feedback in that regard.
代码中可能还有其他一些问题,但我觉得这些意见在这方面提供了足够的反馈。
You can download the driver from: https://sites.google.com/a/chromium.org/chromedriver/downloads
您可以从以下网址下载该驱动程序:https://sites.google.com/a/chromium.org/chromedriver/downloads
UPDATED
更新
IE requires a driver as well:
IE也需要一个驱动程序:
The Internet Explorer Driver Server This is required if you want to make use of the latest and greatest features of the WebDriver InternetExplorerDriver. Please make sure that this is available on your $PATH (or %PATH% on Windows) in order for the IE Driver to work as expected.
Internet Explorer驱动程序服务器如果要使用WebDriver InternetExplorerDriver的最新和最强大的功能,则必须执行此操作。请确保在$ PATH(或Windows上的%PATH%)上可以使用此选项,以便IE驱动程序按预期工作。
Download version 2.53.0 for (recommended) 32 Bit Windows IE or 64 bit Windows IE
下载2.53.0版(推荐)32位Windows IE或64位Windows IE
The above was from: http://www.seleniumhq.org/download/ in regards to driving windows. It seems that the host with the browser needs to run a Selenium Web Driver specifically for IE
以上内容来自:http://www.seleniumhq.org/download/,关于驾驶窗户。看来带浏览器的主机需要专门为IE运行Selenium Web Driver
Firefox also publishes their own driver:
Firefox还发布了自己的驱动程序:
Firefox driver is included in the selenium-server-stanalone.jar available in the downloads. The driver comes in the form of an xpi (firefox extension) which is added to the firefox profile when you start a new instance of FirefoxDriver.
Firefox驱动程序包含在下载中提供的selenium-server-stanalone.jar中。驱动程序以xpi(firefox扩展名)的形式出现,当你启动FirefoxDriver的新实例时,它会添加到firefox配置文件中。
More details can be found here. It operates similar to the Chrome and IE drivers. The important thing to realize is that because the tests are run in the on one host and browsers are remote to where the tests are executed from you may want to look at Selenium Grid as well.
更多详细信息可以在这里找到。它的操作类似于Chrome和IE驱动程序。要意识到的重要一点是,因为测试是在一台主机上运行而浏览器远程执行测试的地方,所以您可能也希望查看Selenium Grid。
#1
3
Selenium can't launch Chrome without Chrome Driver (as Chrome is no longer part of webkit) and Selenium can only launch webkit browsers by default. You should be able to launch Firefox (if it's installed) without needing any additional binaries.
如果没有Chrome驱动程序,Selenium无法启动Chrome(因为Chrome不再是webkit的一部分),Selenium默认只能启动webkit浏览器。您应该能够启动Firefox(如果已安装),而无需任何其他二进制文件。
To get Chrome working you will need to do the following:
要让Chrome正常运行,您需要执行以下操作:
- Download the chrome driver bin.
- 下载chrome驱动程序bin。
- Add it to your path.
- 将其添加到您的路径中。
- Selenium should be able to launch the browser.
- Selenium应该能够启动浏览器。
There may be some other issues in the code, but I feel like the comments have provided enough feedback in that regard.
代码中可能还有其他一些问题,但我觉得这些意见在这方面提供了足够的反馈。
You can download the driver from: https://sites.google.com/a/chromium.org/chromedriver/downloads
您可以从以下网址下载该驱动程序:https://sites.google.com/a/chromium.org/chromedriver/downloads
UPDATED
更新
IE requires a driver as well:
IE也需要一个驱动程序:
The Internet Explorer Driver Server This is required if you want to make use of the latest and greatest features of the WebDriver InternetExplorerDriver. Please make sure that this is available on your $PATH (or %PATH% on Windows) in order for the IE Driver to work as expected.
Internet Explorer驱动程序服务器如果要使用WebDriver InternetExplorerDriver的最新和最强大的功能,则必须执行此操作。请确保在$ PATH(或Windows上的%PATH%)上可以使用此选项,以便IE驱动程序按预期工作。
Download version 2.53.0 for (recommended) 32 Bit Windows IE or 64 bit Windows IE
下载2.53.0版(推荐)32位Windows IE或64位Windows IE
The above was from: http://www.seleniumhq.org/download/ in regards to driving windows. It seems that the host with the browser needs to run a Selenium Web Driver specifically for IE
以上内容来自:http://www.seleniumhq.org/download/,关于驾驶窗户。看来带浏览器的主机需要专门为IE运行Selenium Web Driver
Firefox also publishes their own driver:
Firefox还发布了自己的驱动程序:
Firefox driver is included in the selenium-server-stanalone.jar available in the downloads. The driver comes in the form of an xpi (firefox extension) which is added to the firefox profile when you start a new instance of FirefoxDriver.
Firefox驱动程序包含在下载中提供的selenium-server-stanalone.jar中。驱动程序以xpi(firefox扩展名)的形式出现,当你启动FirefoxDriver的新实例时,它会添加到firefox配置文件中。
More details can be found here. It operates similar to the Chrome and IE drivers. The important thing to realize is that because the tests are run in the on one host and browsers are remote to where the tests are executed from you may want to look at Selenium Grid as well.
更多详细信息可以在这里找到。它的操作类似于Chrome和IE驱动程序。要意识到的重要一点是,因为测试是在一台主机上运行而浏览器远程执行测试的地方,所以您可能也希望查看Selenium Grid。