How to pass webSite parameter to SeleniumGrid instances
I am using C#, MBunit and selenium Grid and I need to run the same scripts for 3 different environments Dev, QA and PROD. I launch 3 different remote controls in Selenium grid, but how can I pass diff开发者_运维问答erent website url to those instances? I need one instance to Dev site, another to QA and another to PROD.
This is an example using TestNG. In your unit test file / script, you'll have something that looks like this:
public class LoginTest {
private static final HUB_URL = "http://theGridHubServer/wd/hub";
@Parameters({ "appUrl" })
public void loginTest(@Optional("http://theTestServer/login/") final String appUrl) {
// ... create RemoteWebDriver object / connections / capabilities here and execute test
}
To execute them in parallel, you'll need to configure a TestNG XML configuration file that will look something like this:
<suite name="Login Test Suite" parallel="tests" verbose="1" thread-count="8">
<test name="Dev">
<parameter name="appUrl" value="http://theDevServer/login"></parameter>
<classes>
<class name="package.to.your.test.class.LoginTest" />
</classes>
</test>
<test name="QA">
<parameter name="appUrl" value="http://theTestServer/login"></parameter>
<classes>
<class name="package.to.your.test.class.LoginTest" />
</classes>
</test>
</test>
<test name="Prod">
<parameter name="appUrl" value="http://theProdServer/login"></parameter>
<classes>
<class name="package.to.your.test.class.LoginTest" />
</classes>
</test>
</suite>
Then you run the XML file as a TestNG test, and assuming you have at least three Webdriver client nodes with the capabilities that match your defined WebDriver, these three tests will be sent to the hub, which will then send them out in parallel to the client nodes, which will use a different URL for each test execution.
Hope this helps!
精彩评论