Payal Sharma
Payal Sharma

Reputation: 11

C# How to initiate the winium driver

like in java we have the following code.I need the same code in c#.

To initiate the winium driver

public WiniumDriver setupEnvironment() throws IOException {

String outlookApplicationPath = "C:\\ProgramfileS|\...\..\outlook.exe";
String winiumDriverPath = "C:\Progra...\..\winium.desktop.exe";

options = new DesktopOptions(); //Initiate Winium Desktop Options
options.setApplicationPath(outlookApplicationPath); //Set outlook application path

File drivePath = new File(winiumDriverPath); //Set winium driver path

service = new WiniumDriverService.Builder().usingDriverExecutable(drivePath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
service.start(); //Build and Start a Winium Driver service
driver = new WiniumDriver(service, options); //Start a winium driver

return driver;

}

Upvotes: 1

Views: 6399

Answers (1)

Robin Bennett
Robin Bennett

Reputation: 3231

There's some sample code here: https://github.com/2gis/Winium.Desktop/wiki/Magic-Samples The relevant section is:

        var dc = new DesiredCapabilities();
        dc.SetCapability("app", @"C:/windows/system32/calc.exe");
        var driver = new RemoteWebDriver(new Uri("http://localhost:9999"), dc);

It assumes you start Winium.Desktop.Driver.exe manually, but you can leave that running between tests.

Upvotes: 1

Related Questions