26
Jun

starting a Winium server and test execute sample application

public class myfirstClass {

public static void main(String[] args) throws IOException, InterruptedException {
WiniumDriver driver = null;
DesktopOptions options = null;
WiniumDriverService service = null;
WebDriverWait wait = null;

options = new DesktopOptions();
options.setApplicationPath(“C:\\Pathto\\ExecutableApplication.exe”);

File driverPath = new File(“C:\\Sheetal\\bus\\Winium\\Winium.Desktop.Driver.exe”);
System.setProperty(“webdriver.winium.desktop.driver”, “C:\\Pathto\\Winium.Desktop.Driver.exe”);
service = new WiniumDriverService.Builder().usingDriverExecutable(driverPath).usingPort(12311).withVerbose(true).withSilent(false).buildDesktopService();
try {
service.start();
driver = new WiniumDriver(service, options);
} catch (IOException e) {
System.out.println(“Exception while starting WINIUM server”);
e.printStackTrace();
}

Thread.sleep(1000);

// Enter user name
WebElement xWL = driver.findElement(By.name(“Windows title”));
Actions xAct = new Actions(driver);
xAct.moveToElement(xWL).build().perform();
driver.findElementByName(“User name :”).sendKeys(“user”);

// Enter password
List<WebElement> list = driver.findElementsByClassName(“Edit”);
for (WebElement element : list) {
if (element.getAttribute(“Name”).equalsIgnoreCase(“password”)) {
element.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END), “password”);

}
}

driver.quit();

}
}