Silk Central 16.5 - 带有 junit4 的 Selenium 脚本运行良好,但作业状态仍显示正在运行



我能够在 silk 中央服务器上运行 selenium 脚本(使用关键字库和 junit 4 构建),因为我看到下面的脚本打开浏览器,根据需要完成步骤并关闭浏览器,但我仍然看到作业/测试状态在 silk 中心上运行。

我将关键字库从 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 {
    }
}

关键字实用程序与之后的概念不同,可以在Silk Central中将其直接作为JUnit脚本运行。

您应该确保作为关键字测试脚本的一部分,仅定义了testSelenium关键字。

如果需要创建此脚本,则可以将清理脚本定义为执行计划的一部分。

如果这仍然处于相同的状态,我将检查执行服务器日志以验证执行期间发生的情况。

相关内容

最新更新