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.Matchers.*;
20
21 import org.testng.annotations.*;
22
23 import dev.aherscu.qa.jgiven.commons.utils.*;
24 import dev.aherscu.qa.jgiven.webdriver.*;
25 import dev.aherscu.qa.testing.example.*;
26 import dev.aherscu.qa.testing.example.model.tutorial.*;
27 import dev.aherscu.qa.testing.example.steps.tutorial.*;
28 import lombok.*;
29 import lombok.extern.slf4j.*;
30
31 @Slf4j
32 public class TestingWindowsWithJGiven
33 extends ApplicationPerClassWebSessionTest<TestConfiguration, CalculatorFixtures<?>, CalculatorActions<?>, CalculatorVerifications<?>> {
34
35 protected TestingWindowsWithJGiven() {
36 super(TestConfiguration.class);
37 }
38
39 @DataProvider
40 static Object[][] data() {
41 return new Object[][] {
42 { Calculation.builder().expression("7+8").result("15").build() },
43 { Calculation.builder().expression("2*5").result("10").build() },
44 { Calculation.builder().expression("333/111").result("3").build() },
45 { Calculation.builder().expression("7-8").result("-1").build() },
46 };
47 }
48
49 @BeforeClass
50 @SneakyThrows
51 @Override
52 protected void beforeClassOpenWebDriver() {
53 log.debug("before class opening WinAppDriver");
54 webDriver.set(WebDriverEx.from(configuration()
55 .capabilitiesFor("provider.local.windows")));
56 }
57
58 @Test
59 public void shouldOpenCalculator() {
60 given()
61 .a_calculator(webDriver.get());
62
63 then()
64 .the_title(is(equalTo("Calculator")));
65 }
66
67 @Test(dataProvider = INTERNAL_DATA_PROVIDER)
68 public void shouldCalculate(final Calculation calculation) {
69 given()
70 .a_calculator(webDriver.get());
71
72 when()
73 .typing(calculation.expression + "=");
74
75 then()
76 .the_result(is(
77 stringContainsInOrder("Display is", calculation.result)));
78 }
79 }