1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package dev.aherscu.qa.testing.example.scenarios.tutorial5;
18
19 import static org.hamcrest.MatcherAssert.*;
20 import static org.hamcrest.Matchers.*;
21
22 import java.net.*;
23
24 import org.openqa.selenium.*;
25 import org.openqa.selenium.remote.*;
26 import org.testng.annotations.*;
27
28 import edu.umd.cs.findbugs.annotations.*;
29 import io.appium.java_client.windows.*;
30 import lombok.*;
31
32 public class TestingWindowsApplication {
33
34 private WindowsDriver driver;
35
36 @Test
37 public void shouldOpenCalculator() {
38 assertThat(driver.getTitle(), equalTo("Calculator"));
39 }
40
41 @Test
42 public void shouldCalculate() {
43 driver.findElement(By.id("CalculatorResults"))
44 .sendKeys("8+7=");
45 assertThat(driver.findElement(By.id("CalculatorResults"))
46 .getText(),
47 stringContainsInOrder("Display is", "15"));
48 }
49
50 @SuppressFBWarnings(
51 value = "UPM_UNCALLED_PRIVATE_METHOD",
52 justification = "called by testng framework")
53 @AfterClass(alwaysRun = true)
54 private void afterClassCloseWebDriver() {
55 driver.quit();
56 }
57
58 @SuppressFBWarnings(
59 value = "UPM_UNCALLED_PRIVATE_METHOD",
60 justification = "called by testng framework")
61 @BeforeClass
62 @SneakyThrows
63 private void beforeClassOpenWebDriver() {
64
65
66 val capabilities = new DesiredCapabilities();
67 capabilities.setCapability("app",
68 "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
69 driver = new WindowsDriver(new URL("http://127.0.0.1:4723"),
70 capabilities);
71
72
73
74 }
75 }