1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package dev.aherscu.qa.testing.example.scenarios.tutorial3;
18
19 import static dev.aherscu.qa.testing.utils.StreamMatchersExtensions.*;
20 import static dev.aherscu.qa.testing.utils.StringUtilsExtensions.*;
21 import static org.apache.commons.lang3.RandomStringUtils.*;
22 import static org.hamcrest.Matchers.*;
23 import static org.hamcrest.Matchers.equalTo;
24
25 import java.util.stream.*;
26
27 import org.hamcrest.*;
28 import org.testng.annotations.*;
29
30 import dev.aherscu.qa.jgiven.commons.model.*;
31 import dev.aherscu.qa.jgiven.commons.tags.*;
32 import dev.aherscu.qa.jgiven.webdriver.*;
33 import dev.aherscu.qa.testing.example.*;
34 import dev.aherscu.qa.testing.example.steps.tutorial.*;
35 import lombok.*;
36
37 @Ignore("https://github.com/QA-Automation-Starter/qa-automation/issues/255")
38 public class TestingWebWithJGiven
39 extends ApplicationPerMethodWebSessionTest<TestConfiguration, GoogleFixtures<?>, GoogleActions<?>, GoogleVerifications<?>> {
40
41 protected TestingWebWithJGiven() {
42 super(TestConfiguration.class);
43 }
44
45 @DataProvider
46 private Object[][] data() {
47 return new Object[][] {
48 { new QuotedText(randomAlphanumeric(40)),
49 counts(equalTo(0L)) },
50 { new QuotedText("testng"),
51 anyMatch(containsStringIgnoringCase("testng")) }
52 };
53 }
54
55 @Reference("68")
56 @Test(dataProvider = INTERNAL_DATA_PROVIDER)
57 public void shouldFind(
58 final Text textToSearch,
59 final Matcher<Stream<String>> titleRule) {
60 given()
61 .google(webDriver.get());
62
63 when()
64 .searching_for(textToSearch);
65
66 then()
67 .the_results(
68 adaptedStream(googleResult -> googleResult.title.value,
69 titleRule));
70 }
71
72 @BeforeMethod
73 @SneakyThrows
74 @Override
75 public void beforeMethodOpenWebDriver() {
76 super.beforeMethodOpenWebDriver();
77 webDriver.get().asRemote().manage().window().maximize();
78 }
79
80 private static class QuotedText extends Text {
81 public QuotedText(final String value) {
82 super(wrap(value, DOUBLE_QUOTE));
83 }
84 }
85 }