Suppose you’ve written some selenium tests using Selenium IDE that target your local machine (http://localhost), but you’d like to repurpose the same tests for your QA, Staging or Production environment as part of your build process. The Selenium Toolkit for .NET makes this really easy to change the target environment without having to touch your tests.
In this post, I’ll show you how to configure the Selenium Toolkit for the following scenarios:
- Local Selenium RC / Local Web Server
- Local Selenium RC / Remote Web Server
- Remote Selenium RC / Remote Web Server
Running Locally
In this scenario, both the Selenium Remote Control Host (aka Selenium RC / Selenium Server) and the web site you want to test are running on your local machine. This is perhaps the most common scenario for developers who develop against a local environment, though it also applies to your build server if the web server you want to test is also on that machine.
Although this configuration is limited to running tests against the current operating system and installed browsers, it provides a few advantages to developers as they can watch the tests execute or set breakpoints on the server to assist in debugging.
This is the default configuration for the Selenium Toolkit for .NET – when the tests execute, the NUnit Addin will automatically start the Selenium RC process and shut it down when the tests complete.
Assuming you have installed the Selenium Toolkit for .NET, the only configuration setting you'll need to provide is the URL of the web site you want to test. In this example, we assume that http://mywebsite is running on the local web server.
<Selenium BrowserUrl="http://mywebsite" />
Running Tests against a Remote Web Server
In this scenario Selenium RC runs local, but web server is on a remote machine. You’ll still see the browser executing the tests locally, but because the web-server is physically located elsewhere it’s not as easy to debug server-side issues. From a configuration perspective, this scenario uses the same configuration settings as above, except the URL of the server is not local.
This scenario is typically used in a build server environment. For example, the build server compiles and deploys the web application to a target machine using rsync and then uses Selenium to validate the deployment using a few functional tests.
Executing Tests in a Remote Environment / Selenium Grid
In this scenario your local test-engine executes your tests against a remote Selenium RC process. While this could be a server where the selenium RC process is configured to run as a dedicated service, it’s more likely that you would use this configuration for executing your tests against a Selenium Grid. The Selenium Grid server exposes the same API as the Selenium RC, but it acts as a broker between your tests and multiple operating systems and different browser configurations.
To configure the Selenium Toolkit to use a Selenium Grid, you’ll need to specify the location of the Grid Server and turn off the automatic start/stop feature:
<Selenium server="grid-server-name" port="4444" BrowserUrl="http://mywebsite.com" /> <runtime autoStart="false" /> </Selenium>
0 comments:
Post a Comment