UNPKG

3.45 kBMarkdownView Raw
1* [the "\_\_\_" should have the placeholder text "\_\_\_"](the-"\_\_\_"-should-have-the-placeholder-text-"\_\_\_")
2 * [regex](regex)
3 * [timing](timing)
4 * [with the "should" expectation](with-the-"should"-expectation)
5 * [with the "should not" expectation](with-the-"should-not"-expectation)
6 * [execution](execution)
7# the "\_\_\_" should have the placeholder text "\_\_\_"
8## regex
9 regex should match a step starting with "the..."
10
11```
12verifyStepMatch('the "Username Field" should have the placeholder text "Enter Username"');
13```
14
15
16 regex should match a step that does not start with "the..."
17
18```
19verifyStepMatch('"Username Field" should have the placeholder text "Enter Username"');
20```
21
22
23 regex should match "...should have the placeholder text..."
24
25```
26verifyStepMatch('the "Username Field" should have the placeholder text "Enter Username"');
27```
28
29
30 regex should match "...should contain the placeholder text..."
31
32```
33verifyStepMatch('the "Username Field" should contain the placeholder text "Enter Username"');
34```
35
36
37 regex should capture the element name, element type, expectation, and placeholder text
38
39```
40verifyStepCaptures('the "Username" field should have the placeholder text "Enter Username"', 'Username', ' field', 'should', 'Enter Username');
41```
42
43
44 regex should capture the element name, placeholder text, expectation, and a blank string if no element type is provided
45
46```
47verifyStepCaptures('the "Username Field" should have the placeholder text "Enter Username"', 'Username Field', '', 'should', 'Enter Username');
48```
49
50
51 regex should not capture "the" or "have"
52
53```
54verifyStepDoesNotCapture('the "Username Field" should have the placeholder text "Enter Username"', 'the', 'have');
55```
56
57
58## timing
59### with the "should" expectation
60 with the "should" expectation should succeed if the element contains the expected placeholder text
61
62```
63return executeStep('the "Test Input" should have the placeholder text "Test Placeholder"', function() {
64 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
65});
66```
67
68
69 with the "should" expectation should fail if the element does not contain the expected placeholder text
70
71```
72return executeStep('the "Test Input" should have the placeholder text "Fake Placeholder"', function() {
73 expect(currentStepResult.status).to.equal(Cucumber.Status.FAILED);
74});
75```
76
77
78### with the "should not" expectation
79 with the "should not" expectation should succeed if the element contains the expected placeholder text
80
81```
82return executeStep('the "Test Input" should not have the placeholder text "Test Placeholder"', function() {
83 expect(currentStepResult.status).to.equal(Cucumber.Status.FAILED);
84});
85```
86
87
88 with the "should not" expectation should fail if the element does not contain the expected placeholder text
89
90```
91return executeStep('the "Test Input" should not have the placeholder text "Fake Placeholder"', function() {
92 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
93});
94```
95
96
97## execution
98 execution should wait for the element to be displayed before verifying
99
100```
101return browser.driver.executeScript("setTimeout( function() { $('div#test').append('<input id=\"testInput\" placeholder=\"Test Placeholder\" />'); }, 200 )").then(() => {
102 return executeStep('the "Test Input" should have the placeholder text "Test Placeholder"', function() {
103 expect(currentStepResult.status).to.equal(Cucumber.Status.PASSED);
104 });
105});
106```