I have managed to find the solution myself.
Basically, RemoteWebDriver has to be used instead of FirefoxDriver.
Steps:
- Change the initialization of FirefoxDriver to RemoteWebDriver as:
Change from
IWebDriver driver = new FirefoxDriver();
To
DesiredCapabilities capability = DesiredCapabilities.Firefox();
Uri url = new Uri("http://REMOTE_IP:4545/wd/hub");
IWebDriver driver = new RemoteWebDriver(url, capability);
2. Download Selenium Standalone server and initiate it via command prompt using ~
java -jar E:Softwareselenium-server-standalone-2.24.1.jar -interactive -port 4545
This approach has 2 benefits:
- One could use the local IIS for running the test.
Test could be run remotely. Refer Selenium RC documentation. One could see the screenshots remotely using
REMOTE_IP:4545/wd/hub/static/resource/hub.html
I am thinking to modify the code of hub.html and client.js file used within it to provide a better Remote feel.
I hope this can be useful for others as well.
FYI:
- IP address REMOTE_IP could be changed to any realtime IP address OR localhost. Use the above mentioned port while initiating the page request.
- Start/Stop code of Standalone Server could be fitted inside the test, so that it is automatically started/stopped via batch file.
- Keep the server running by not closing the command prompt.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…