I finally found some time to get back up to speed on Selenium and MXUnit today. MXUnit I got running quickly which hasn't been the case in the past so I must be learning something, or the gang at MXUnit is making things easier.
Selenium proved a bit more difficult mainly due to my development environment...
Problem 1
I have VirtualBox setup running ColdFusion, Apache and MySQL. Using a shared directory I have Apache pointing at my Eclipse workspace which lives on my 'host'.
Setting up a very simple Selenium test using the new CFSelenium, I just wanted to see if I could get a browser window to pop open...
selenium = new selenium("http://www.google.com/", "localhost", 4444, "*googlechrome");
selenium.start();
selenium.open("/");
This failed with a "The Response of the Selenium RC is invalid: Connection Failure " error.
The issue is the "localhost" in the Selenium setup. The test, running on my guest VM can't communicate with the Selenium RC server running on my host.
What I needed to do was direct things to my host IP which is 192.168.2.2...
selenium = new selenium("http://www.google.com/", "192.168.2.2", 4444, "*googlechrome");
This correctly kicked off a Google Chrome. But what about Firefox?
Problem 2
Trying to run tests in Firefox introduced another issue:
The Response of the Selenium RC is invalid: Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path! Please add the directory containing ''firefox.exe'' to your PATH environment variable, or explicitly specify a path to Firefox 3 like this: *firefox3c:\blah\firefox.exe
I tried explicitly defining the path, using the example from the error, as well as adding my Firefox directory to the path.
selenium = new selenium("http://www.google.com/", "192.168.2.2", 4444, "*firefox3C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
No luck. After a bit of Googling it turns out the correct syntax is:
selenium = new selenium("http://www.google.com/", "192.168.2.2", 4444, "*firefox C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
Notice the space between "*firefox" and the path. That is important. :)
Now things work!
Conclusion
It seems like you could easily configure a powerful testing environment by simply loading up several VMs with various flavors of operating systems and browsers and then pointing one set of tests at them all.
- VM 1 = Windows XP with old flavors of IE and Firefox
- VM 2 = Windows 7 with IE9, Chrome and Firefox 4
- Linux, etc...