이것은 제가 연극 연습을 위해했던 것입니다. 사용하실 수 있습니다.
String[] location = new String[] {
"Los Angeles",
"Santa Barbara",
"San Jose"
};
// Some code
@Test
public void testSelServerDiceTest() throws Exception {
for (int i = 0; i < location.length; i++) { // manually added for loop
selenium.open("/");
selenium.type("id=FREE_TEXT", "selenium RC JUnit");
selenium.type("id=WHERE", location[i].concat(" CA"));
selenium.click("xpath=//*[@id=\"searchSubmit\"]");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("Search results:"));
verifyTrue(selenium.isTextPresent("Search job title only"));
verifyEquals("JUnit", selenium.getText("css=div.undoLabel"));
verifyTrue(selenium.isTextPresent("selenium"));
verifyTrue(selenium.isTextPresent("Search results: 1 - 1 of 1"));
assertTrue(selenium.isTextPresent("Search results:"));
}
}
//Some more code
편집
// webdriver code snippet
@Test
public void testRemoteWebDriverDiceTest() throws Exception {
for (int i = 0; i < location.length; i++) {
driver.get(baseUrl + "/");
driver.findElement(By.id("FREE_TEXT")).clear();
driver.findElement(By.id("FREE_TEXT"))
.sendKeys("selenium RC JUnit");
driver.findElement(By.id("WHERE")).clear();
driver.findElement(By.id("WHERE")).sendKeys(
location[i].concat(" CA"));
driver.findElement(By.xpath("//*[@id=\"searchSubmit\"]")).click();
try {
assertEquals("JUnit",
driver.findElement(By.cssSelector("div.undoLabel"))
.getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
}
당신은 오랜 기간 동안 그것을 할 수 있지만이를 수동으로 스크립트 릴 비트를 변경해야합니다. – Smit
그것은 단지 예일 뿐이므로 다른 작업을 위해 드라이버를 계속 사용하고 싶습니다. –
어떤 브라우저입니까? 해당 브라우저의 버전은 무엇입니까? – Arran