-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
element.feature
162 lines (148 loc) · 6.72 KB
/
element.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@api
Feature: Check that ElementTrait works
Scenario: Assert step definition "Then I should see the :selector element with the :attribute attribute set to :value" works as expected
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with the "dir" attribute set to "ltr"
@trait:ElementTrait
Scenario: Assert that an element with selector and attribute with a value exists.
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "#invalid-element" element with the "dir" attribute set to "ltr"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The "#invalid-element" element was not found on the page.
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see the :selector element with the :attribute attribute set to :value" fails as expected when the attribute is not found
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with the "no-existing-attribute" attribute set to "ltr"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The "no-existing-attribute" attribute was not found on the element "html".
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see the :selector element with the :attribute attribute set to :value" fails as expected when the attribute value does not match
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with the "dir" attribute set to "not-match-value"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The "dir" attribute was found on the element "html", but does not contain a value "not-match-value".
"""
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected with a specific value
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with a "dir" attribute containing "ltr"
Scenario: Assert step definition "I( should) see the :selector element with a(n) :attribute attribute containing :value" works as expected with a wildcard
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with a "dir" attribute containing "lt*"
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute is not found
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "#invalid-element" element with a "dir" attribute containing "ltr"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The "#invalid-element" element was not found on the page.
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute value does not match
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with a "no-existing-attribute" attribute containing "ltr"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The "no-existing-attribute" attribute was not found on the element "html".
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see the :selector element with a(n) :attribute attribute containing :value" fails as expected when the attribute value does not match; alternative step definition
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see the "html" element with a "dir" attribute containing "not-match-value"
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
No element with "dir" attribute matching the pattern "not-match-value" found.
"""
Scenario: Assert that an element with selector contains text using css.
Given I am an anonymous user
When I visit "/"
Then I should see an element ".site-branding__name" using "css" contains "Drush Site-Install" text
Scenario: Assert that an element with selector contains text using xpath.
Given I am an anonymous user
When I visit "/"
Then I should see an element "//div[@class='site-branding__name']" using "xpath" contains "Drush Site-Install" text
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the selector type is invalid
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see an element "//div[@class='site-branding__name']" using "invalid-selector-type" contains "Drush Site-Install" text
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
Selector type must be "css" or "xpath".
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the selector is not found
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see an element "//div[@class='site-branding__name_invalid']" using "xpath" contains "Drush Site-Install" text
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
Tag matching xpath "//div[@class='site-branding__name_invalid']" not found.
"""
@trait:ElementTrait
Scenario: Negative assertion for "Then I should see an element :selector using :selector_type contains :text text" fails as expected when the text is not found
Given some behat configuration
And scenario steps:
"""
Given I am an anonymous user
When I visit "/"
Then I should see an element "//div[@class='site-branding__name']" using "xpath" contains "Drush Site-Install Fail" text
"""
When I run "behat --no-colors"
Then it should fail with an error:
"""
The text "Drush Site-Install Fail" was not found in the element "//div[@class='site-branding__name']" using xpath.
"""