既に持っている webdriver コードを使用してセレン グリッド 2 をセットアップしようとしています。Google で見つけたいくつかのチュートリアルを試していますが、同じ問題に遭遇しました。すべてのテスト ケースが次々と開始されます。私が望むのは、それらすべてが同時に起動することです (すべて IE8 を使用)。ハブとノードをhttp://localhost:4444/grid/console
起動しました。そして、これは私のコードです。今は、Google にアクセスするだけです。これについて何か助けてください。ありがとうございました!
public class CodesIntegrationTestCase {
private static String SELENIUM_HUB_URL;
private static String TARGET_SERVER_URL;
@BeforeClass
public static void initEnvironment() {
SELENIUM_HUB_URL = getConfigurationProperty(
"SELENIUM_HUB_URL",
"test.selenium.hub.url",
"http://localhost:4444/wd/hub");
System.out.println("using Selenium hub at: " + SELENIUM_HUB_URL);
TARGET_SERVER_URL = getConfigurationProperty(
"TARGET_SERVER_URL",
"test.target.server.url",
"http://google.com");
System.out.println("using target at: " + TARGET_SERVER_URL);
}
private static String getConfigurationProperty(
String envKey, String sysKey, String defValue) {
String retValue = defValue;
String envValue = System.getenv(envKey);
String sysValue = System.getProperty(sysKey);
// system property prevails over environment variable
if (sysValue != null) {
retValue = sysValue;
} else if (envValue != null) {
retValue = envValue;
}
return retValue;
}
@Test
public void testIE()
throws MalformedURLException, IOException {
DesiredCapabilities browser = DesiredCapabilities.internetExplorer();
testCodesCrud(browser);
}
@Test
public void testIE2()
throws MalformedURLException, IOException {
DesiredCapabilities browser = DesiredCapabilities.internetExplorer();
testCodesCrud(browser);
}
public void testCodesCrud(DesiredCapabilities browser)
throws MalformedURLException, IOException {
WebDriver driver = null;
try {
driver = new RemoteWebDriver(
new URL(SELENIUM_HUB_URL), browser);
// test starts in Codes entity list page
driver.get(TARGET_SERVER_URL + "/CodesView.do");
// rest of test commands come here
} finally {
if (driver != null) {
driver.quit();
}
}
}
}