Silk Central 16.5 - 使用junit4的Selenium脚本运行正常,但作业的状态仍然表示正在运行

时间:2017-11-06 16:25:11

标签: junit4 silk-central

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

我将关键字库从eclipse上传到丝绸中央服务器。

如果我错过任何有关junit版本的内容或者我错过任何一步,请指导我吗?

public class LaunchSelenium{

    private static final String propertiesFile ="\\\\emedslkalb902\\SCTMWorking\\Properties\\MeipassProperties.txt";

    private WebDriver driver=null;;
    String url = null;

    @Keyword(value = "testSelenium")
    @Test
    public void testSelenium(String environment,String nlrRegNum) {

        // Load Propeties       
        PropertyService properties = new PropertyServiceImpl();
        try {
            properties.loadProperties(propertiesFile);
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Go to ENV specific login page 
        switch (environment) {
        case "DEVA":
            url = properties.getValue("DEVA.URL");
            break;
        case "DEVB":
            url = properties.getValue("DEVB.URL");
            break;
        case "SITA":
            url = properties.getValue("SITA.URL");
            break;
        case "SITB":
            url = properties.getValue("SITB.URL");
            break;
        case "LOCAL":
            url = properties.getValue("LOCAL.URL");
            break;
        default:
            url = properties.getValue("DEVB.URL");
            break;
        }

        final File file = new File("//emedslkalb902/SCTMWorking/Properties/chromedriver.exe");
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
        driver = (WebDriver) new ChromeDriver();


        driver.get(url);
        driver.findElement(By.id("ehrUserID")).clear();
        driver.findElement(By.id("ehrUserID")).sendKeys("RPARIH11");
        driver.findElement(By.id("password")).clear();
        driver.findElement(By.id("password")).sendKeys("RPARIH11");
        driver.findElement(By.id("terms")).click();
        driver.findElement(By.id("loginSubmit")).click();
        driver.findElement(By.id("nlrRegNum")).sendKeys(nlrRegNum);
        driver.findElement(By.id("find")).click();
        driver.findElement(By.id("btnEpYr2")).click();
        driver.findElement(By.id("epEligibilityEdit")).click();
        driver.findElement(By.id("ehrOver50:0")).click();
        driver.findElement(By.id("ehrIncl80PctInd:0")).click();
        driver.close();

    }

    @Keyword(value = "tearDown")
    @After
    public void tearDown() throws Exception {
    }

}

1 个答案:

答案 0 :(得分:0)

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

您应确保在关键字测试脚本中仅定义了testSelenium关键字。

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

如果它保持相同状态,我会检查执行服务器日志以验证执行期间发生的情况。