DEV Community

Cover image for Selenium Testautomation on Windows Desctop App with Winium (Java)
Anne Quinkenstein
Anne Quinkenstein

Posted on • Updated on

Selenium Testautomation on Windows Desctop App with Winium (Java)

https://github.com/2gis/Winium

Winium = Windows + Selenium
open source
works with all WebDriver compatible languages (Java, Python, ..)
only for client-based applications on Windows (not IOS or Linux)

Prerequisites

Microsoft .NET Framework 4.5.1
Winium.Desktop.Driver.exe

Some other dependencies that are downloaded using the Maven file, as mentioned in the POM file below:

add dependencies to pom-file

download winuiumDriver from github
appPath:put it somewhere in the windows explorer

Code

By initiating the Winium driver using the Winiumdriver class, we are passing the Winium server URL and the path of our desktop application on which automation is intended to be carried out.

The server URL is obtained by clicking on the Winium.desktop.driver.exe that was downloaded.

... throws MalformedURLException

DesktopOptions desktopOptions = new DesktopOptions();
desktopOptions.setApplicationPath(configFileReader.getAppPath());   desktopOptions.setKeyboardSimulator(KeyboardSimulatorType.BasedOnWindowsFormsSendKeysClass);
//winiumDriver with URL:: localhost:9999, every call we make goes through this driver .... 
winiumDriver = new WiniumDriver(new URL("http://localhost:9999"), desktopOptions);

Enter fullscreen mode Exit fullscreen mode

By initiating the Winium driver using the Winiumdriver class, we are passing the Winium server URL and the path of our desktop application on which automation is intended to be carried out.

3 conditions

path to winium driver and setup
start winium driver (dobbleclick)
run tests

how to inspect the Desctop Desctop Elements (or Java Forms based)?

inspect.exe to identify the element locators in Windows applications.
https://kb.froglogic.com/squish/howto/getting-information-toolkits-gui-controls-windows/
We can identify the element using the name, ID and xpath.

all in all:
The main difference between Selenium and Winium is that selenium automatically creates its session on localhost with a unique port, but in Winium, we have to create sessions manually through its exe file. Besides this, running an automation service through Winium needs the user to run a local server that supports the script, i.e., Winium server, whereas automating windows applications using Selenium does not require such efforts. The driver it will open by default with port 9999 which acts as a server.

Internally this server will communicate through JSON Wireless Protocol

Winium Way to Webside

Top comments (0)