Skip to content

Windows

To do Windows application automation, you need to:

  • Download windows driver
  • Enable developers mode for Windows
  • Start Appium or WinAppDriver
  • Set carina's configuration
#path to your Appium/WinAppDriver server
selenium_url=http://localhost:4723/wd/hub

#Should be set to specify windows automation session
capabilities.platformName=Windows
capabilities.automationName=Windows

#path to application you want to test   
capabilities.app=C:/Windows/system32/win32calc.exe

That's all. To get access to the driver use getDriver(). Write and run tests as usual. If you want to pass specific parameters to WindowsDriver refer to Appium documentation.

Code example:

//page.class example
public class CalculatorHomePage extends AbstractPage {
    @FindBy(xpath = "/Window/Pane/Button[10]")
    ExtendedWebElement fiveButton;

    @FindBy(xpath = "/Window/Pane/Button[5]")
    ExtendedWebElement oneButton;

    @FindBy(xpath = "/Window/Pane/Button[23]")
    ExtendedWebElement plusButton;

    @FindBy(xpath = "/Window/Pane/Button[28]")
    ExtendedWebElement resultButton;

    @FindBy(xpath = "/Window/Pane/Text[3]")
    ExtendedWebElement resultField;

    public CalculatorHomePage(WebDriver driver) {
        super(driver);
    }

    public void sumOneAndFive(){
        fiveButton.click();
        plusButton.click();
        oneButton.click();
        resultButton.click();
    }

    public String getResult(){
        return resultField.getText();
    }
}
//test.class example
public class CalculatorTest implements IAbstractTest {
    @Test
    public void calculatorSumTest(){
        CalculatorHomePage calculator = new CalculatorHomePage(getDriver());
        calculator.sumOneAndFive();
        Assert.assertEquals(calculator.getResult().trim(), "6");
    }
}