我可以在 Silk 中央服务器上运行 selenium 脚本(使用关键字库和 junit 4 构建),因为我看到下面的脚本打开了浏览器,根据需要完成了步骤并关闭了浏览器,但我仍然看到了作业/测试状态为在丝绸中央运行。
我把关键字库从eclipse上传到了silk中央服务器。
如果我遗漏了有关junit版本的任何内容,或者我遗漏了任何步骤,您能否指导我?
public class LaunchSelenium{
private static final String propertiesFile ="\\....\\props.txt";
private WebDriver driver=null;;
String url = null;
@Keyword(value = "testSelenium")
@Test
public void testSelenium(String env,String testid) {
// Load Propeties
PropertyService properties = new PropertyServiceImpl();
try {
properties.loadProperties(propertiesFile);
} catch (IOException e) {
e.printStackTrace();
}
// Go to ENV specific login page
switch (environment) {
case "DEV":
url = properties.getValue("DEV.URL");
break;
case "SIT":
url = properties.getValue("SIT.URL");
break;
case "LOCAL":
url = properties.getValue("LOCAL.URL");
break;
default:
url = properties.getValue("DEV.URL");
break;
}
final File file = new File("//..//..Properties/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver = (WebDriver) new ChromeDriver();
driver.get(url);
driver.findElement(By.id("UserID")).clear();
driver.findElement(By.id("UserID")).sendKey("uname");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys("upwd");
driver.findElement(By.id("terms")).click();
driver.findElement(By.id("loginSubmit")).click();
driver.findElement(By.id("testid")).sendKeys(test id);
driver.findElement(By.id("find")).click();
driver.findElement(By.id("t2")).click();
driver.findElement(By.id("Edit")).click();
driver.findElement(By.id("rOver")).click();
driver.findElement(By.id("submit")).click();
driver.close();
}
@Keyword(value = "tearDown")
@After
public void tearDown() throws Exception {
}
}