1

I am able to run the selenium script (built using keyword library and junit 4) on the silk central server as I see the below script opens up the browser, finished the steps as needed and closed the browser but I still sees the job/test status as running on the silk central.

I uploaded the keyword library to the silk central server from eclipse.

Could you please guide me if I am missing anything in regards to the junit version or am I missing any step?

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 {
    }

}
anonymous
  • 11
  • 3

1 Answers1

0

The keyword utility does not have the same concept as after which is possible running this directly as a JUnit script in Silk Central.

You should ensure that as part of your keyword test script that only the testSelenium keyword is defined.

If you need to create this you can define a cleanup script as part of the execution plan.

If this remains in the same state I would check the execution server log to verify what is happening during the execution.