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.
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/.
The test suite, seleniumtest.cfc extends testbox.system.BaseSpec, and its beforeAll() and afterAll() functions instantiate selenium, start it, and tear it down:
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( "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
For all other url or browser versions I pass to selenium.start() (I've tried '*chrome', '*firefox', '*iexplore', '*iexploreproxy'), I get the following error:
The Response of the Selenium RC is invalid: Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser
From the stack trace, I can see that it fails at 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
Netstat –an | find “4444”
After again running the test suite, running netstat with the same command showed
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:
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'}
Is there supposed to be a selenium-server folder under wwwroot? Is that the 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:
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.
super.beforeAll(‘siteUnderTest',. And where did you getcfselenium.BaseSpecthat you are extending from the cfc? I don't see that as part of the project on GitHub. - Miguel-F