To start using Winium, there are specific steps to be followed.
Step 1: Add Maven Dependency to your POM.xml
Create a maven project and copy-paste the below repository into the pom.xml. Check latest dependency here
<!-- https://mvnrepository.com/artifact/com.github.2gis.winium/winium-webdriver -->
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-webdriver</artifactId>
<version>0.1.0-1</version>
</dependency>
Step 2: Download The Driver.exe File
Download the Winium driver exe (Winium.Desktop.Driver.zip) file from here
- Once finished, extract the zip folder and copy the exe file to your desired directory.
- So commonly, by default, it opens with port 9999, and this port acts as the server.
- Consider it the bridge.
- This bridge communicates through the JSON Wireless protocol.
Step 3: Add below code to your class
public class SimpleTest
{
DesktopOptions options;
WiniumDriverService service;
WiniumDriver driver;
@BeforeTest
public void bt()
{
//Instantiate Winium Desktop Options
options = new DesktopOptions();
// Path of application you want to run and test
options.setApplicationPath("C:\\Windows\\System32\\calc.exe");
//Path for Winium Desktop Driver
File driverPath = new File(System.getProperty("user.dir")+File.separator+"drivers"+File.separator+"Winium.Desktop.Driver.exe");
//Port is 9999, you can change it
service = new WiniumDriverService.Builder().usingDriverExecutable(driverPath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
try
{
service.start();
}
catch (IOException e)
{
System.out.println("Exception while starting WINIUM service");
e.printStackTrace();
}
driver = new WiniumDriver(service,options);
}
@AfterTest
public void at()
{
service.stop();
}
}