|
4 | 4 |
|
5 | 5 | use Pest\Browser\Playwright\Element; |
6 | 6 |
|
7 | | -describe('Frame', function () { |
8 | | - beforeEach(function () { |
| 7 | +describe('Frame', function (): void { |
| 8 | + beforeEach(function (): void { |
9 | 9 | $this->page = $this->page(playgroundUrl('/test/selector-tests')); |
10 | 10 | }); |
11 | 11 |
|
12 | | - describe('getByTestId', function () { |
13 | | - it('finds an element by test ID', function () { |
| 12 | + describe('getByTestId', function (): void { |
| 13 | + it('finds an element by test ID', function (): void { |
14 | 14 | $element = $this->page->getByTestId('profile-section'); |
15 | 15 |
|
16 | 16 | expect($element)->toBeInstanceOf(Element::class); |
17 | 17 | expect($element->isVisible())->toBeTrue(); |
18 | 18 | }); |
19 | 19 |
|
20 | | - it('finds a nested element by test ID', function () { |
| 20 | + it('finds a nested element by test ID', function (): void { |
21 | 21 | $element = $this->page->getByTestId('user-email'); |
22 | 22 |
|
23 | 23 | expect($element)->toBeInstanceOf(Element::class); |
24 | 24 | expect($element->isVisible())->toBeTrue(); |
25 | 25 | }); |
26 | 26 |
|
27 | | - it('returns null for non-existent test ID', function () { |
| 27 | + it('returns null for non-existent test ID', function (): void { |
28 | 28 | $element = $this->page->getByTestId('non-existent-id'); |
29 | 29 |
|
30 | 30 | expect($element)->toBeNull(); |
31 | 31 | }); |
32 | 32 | }); |
33 | 33 |
|
34 | | - describe('getByRole', function () { |
35 | | - it('finds an element by role with name option', function () { |
| 34 | + describe('getByRole', function (): void { |
| 35 | + it('finds an element by role with name option', function (): void { |
36 | 36 | $element = $this->page->getByRole('button', ['name' => 'Save']); |
37 | 37 |
|
38 | 38 | expect($element)->toBeInstanceOf(Element::class); |
39 | 39 | expect($element->isVisible())->toBeTrue(); |
40 | 40 | }); |
41 | 41 |
|
42 | | - it('finds a checkbox by role with name option', function () { |
| 42 | + it('finds a checkbox by role with name option', function (): void { |
43 | 43 | $element = $this->page->getByRole('checkbox', ['name' => 'Remember Me']); |
44 | 44 |
|
45 | 45 | expect($element)->toBeInstanceOf(Element::class); |
46 | 46 | }); |
47 | 47 |
|
48 | | - it('returns null for non-existent role', function () { |
| 48 | + it('returns null for non-existent role', function (): void { |
49 | 49 | $element = $this->page->getByRole('tab', ['name' => 'Non-existent']); |
50 | 50 |
|
51 | 51 | expect($element)->toBeNull(); |
52 | 52 | }); |
53 | 53 | }); |
54 | 54 |
|
55 | | - describe('getByLabel', function () { |
56 | | - it('finds an input element by its associated label', function () { |
| 55 | + describe('getByLabel', function (): void { |
| 56 | + it('finds an input element by its associated label', function (): void { |
57 | 57 | $element = $this->page->getByLabel('Username'); |
58 | 58 |
|
59 | 59 | expect($element)->toBeInstanceOf(Element::class); |
60 | 60 | expect($element->getAttribute('value'))->toBe('johndoe'); |
61 | 61 | }); |
62 | 62 |
|
63 | | - it('finds a password input by its label', function () { |
| 63 | + it('finds a password input by its label', function (): void { |
64 | 64 | $element = $this->page->getByLabel('Password'); |
65 | 65 |
|
66 | 66 | expect($element)->toBeInstanceOf(Element::class); |
67 | 67 | expect($element->getAttribute('type'))->toBe('password'); |
68 | 68 | }); |
69 | 69 |
|
70 | | - it('returns null for non-existent label', function () { |
| 70 | + it('returns null for non-existent label', function (): void { |
71 | 71 | $element = $this->page->getByLabel('Non-existent Label'); |
72 | 72 |
|
73 | 73 | expect($element)->toBeNull(); |
74 | 74 | }); |
75 | 75 | }); |
76 | 76 |
|
77 | | - describe('getByPlaceholder', function () { |
78 | | - it('finds an input element by placeholder text', function () { |
| 77 | + describe('getByPlaceholder', function (): void { |
| 78 | + it('finds an input element by placeholder text', function (): void { |
79 | 79 | $element = $this->page->getByPlaceholder('Search...'); |
80 | 80 |
|
81 | 81 | expect($element)->toBeInstanceOf(Element::class); |
82 | 82 | expect($element->getAttribute('type'))->toBe('text'); |
83 | 83 | }); |
84 | 84 |
|
85 | | - it('finds a textarea by placeholder text', function () { |
| 85 | + it('finds a textarea by placeholder text', function (): void { |
86 | 86 | $element = $this->page->getByPlaceholder('Enter your comments here'); |
87 | 87 |
|
88 | 88 | expect($element)->toBeInstanceOf(Element::class); |
89 | 89 | expect($element->isVisible())->toBeTrue(); |
90 | 90 | }); |
91 | 91 |
|
92 | | - it('returns null for non-existent placeholder', function () { |
| 92 | + it('returns null for non-existent placeholder', function (): void { |
93 | 93 | $element = $this->page->getByPlaceholder('Non-existent Placeholder'); |
94 | 94 |
|
95 | 95 | expect($element)->toBeNull(); |
96 | 96 | }); |
97 | 97 |
|
98 | | - it('finds an element with exact matching', function () { |
| 98 | + it('finds an element with exact matching', function (): void { |
99 | 99 | $element = $this->page->getByPlaceholder('Search...', true); |
100 | 100 |
|
101 | 101 | expect($element)->toBeInstanceOf(Element::class); |
102 | 102 | }); |
103 | 103 | }); |
104 | 104 |
|
105 | | - describe('getByText', function () { |
106 | | - it('finds an element by its text content', function () { |
| 105 | + describe('getByText', function (): void { |
| 106 | + it('finds an element by its text content', function (): void { |
107 | 107 | $element = $this->page->getByText('This is a simple paragraph'); |
108 | 108 |
|
109 | 109 | expect($element)->toBeInstanceOf(Element::class); |
110 | 110 | expect($element->isVisible())->toBeTrue(); |
111 | 111 | }); |
112 | 112 |
|
113 | | - it('finds a button by its text content', function () { |
| 113 | + it('finds a button by its text content', function (): void { |
114 | 114 | $element = $this->page->getByText('Click Me Button'); |
115 | 115 |
|
116 | 116 | expect($element)->toBeInstanceOf(Element::class); |
117 | 117 | }); |
118 | 118 |
|
119 | | - it('returns null for non-existent text', function () { |
| 119 | + it('returns null for non-existent text', function (): void { |
120 | 120 | $element = $this->page->getByText('Non-existent Text Content'); |
121 | 121 |
|
122 | 122 | expect($element)->toBeNull(); |
123 | 123 | }); |
124 | 124 |
|
125 | | - it('finds an element with exact matching', function () { |
| 125 | + it('finds an element with exact matching', function (): void { |
126 | 126 | $element = $this->page->getByText('This is a special span element', true); |
127 | 127 |
|
128 | 128 | expect($element)->toBeInstanceOf(Element::class); |
129 | 129 | }); |
130 | 130 |
|
131 | | - it('finds partial text without exact matching', function () { |
| 131 | + it('finds partial text without exact matching', function (): void { |
132 | 132 | $element = $this->page->getByText('special span'); |
133 | 133 |
|
134 | 134 | expect($element)->toBeInstanceOf(Element::class); |
135 | 135 | }); |
136 | 136 | }); |
137 | 137 |
|
138 | | - describe('getByAltText', function () { |
139 | | - it('finds an image by its alt text', function () { |
| 138 | + describe('getByAltText', function (): void { |
| 139 | + it('finds an image by its alt text', function (): void { |
140 | 140 | $element = $this->page->getByAltText('Pest Logo'); |
141 | 141 |
|
142 | 142 | expect($element)->toBeInstanceOf(Element::class); |
143 | 143 | expect($element->isVisible())->toBeTrue(); |
144 | 144 | }); |
145 | 145 |
|
146 | | - it('finds another image by its alt text', function () { |
| 146 | + it('finds another image by its alt text', function (): void { |
147 | 147 | $element = $this->page->getByAltText('Another Image'); |
148 | 148 |
|
149 | 149 | expect($element)->toBeInstanceOf(Element::class); |
150 | 150 | }); |
151 | 151 |
|
152 | | - it('returns null for non-existent alt text', function () { |
| 152 | + it('returns null for non-existent alt text', function (): void { |
153 | 153 | $element = $this->page->getByAltText('Non-existent Alt Text'); |
154 | 154 |
|
155 | 155 | expect($element)->toBeNull(); |
156 | 156 | }); |
157 | 157 |
|
158 | | - it('finds an element with exact matching', function () { |
| 158 | + it('finds an element with exact matching', function (): void { |
159 | 159 | $element = $this->page->getByAltText('Profile Picture', true); |
160 | 160 |
|
161 | 161 | expect($element)->toBeInstanceOf(Element::class); |
162 | 162 | }); |
163 | 163 | }); |
164 | 164 |
|
165 | | - describe('getByTitle', function () { |
166 | | - it('finds an element by its title attribute', function () { |
| 165 | + describe('getByTitle', function (): void { |
| 166 | + it('finds an element by its title attribute', function (): void { |
167 | 167 | $element = $this->page->getByTitle('Info Button'); |
168 | 168 |
|
169 | 169 | expect($element)->toBeInstanceOf(Element::class); |
170 | 170 | expect($element->isVisible())->toBeTrue(); |
171 | 171 | }); |
172 | 172 |
|
173 | | - it('finds a link by its title attribute', function () { |
| 173 | + it('finds a link by its title attribute', function (): void { |
174 | 174 | $element = $this->page->getByTitle('Help Link'); |
175 | 175 |
|
176 | 176 | expect($element)->toBeInstanceOf(Element::class); |
177 | 177 | }); |
178 | 178 |
|
179 | | - it('returns null for non-existent title', function () { |
| 179 | + it('returns null for non-existent title', function (): void { |
180 | 180 | $element = $this->page->getByTitle('Non-existent Title'); |
181 | 181 |
|
182 | 182 | expect($element)->toBeNull(); |
183 | 183 | }); |
184 | 184 |
|
185 | | - it('finds an element with exact matching', function () { |
| 185 | + it('finds an element with exact matching', function (): void { |
186 | 186 | $element = $this->page->getByTitle('User\'s Name', true); |
187 | 187 |
|
188 | 188 | expect($element)->toBeInstanceOf(Element::class); |
189 | 189 | }); |
190 | 190 | }); |
191 | 191 |
|
192 | | - describe('combining selectors', function () { |
193 | | - it('can find elements using multiple methods in sequence', function () { |
| 192 | + describe('combining selectors', function (): void { |
| 193 | + it('can find elements using multiple methods in sequence', function (): void { |
194 | 194 | // First get the profile section by testId |
195 | 195 | $profileSection = $this->page->getByTestId('user-profile'); |
196 | 196 | expect($profileSection)->toBeInstanceOf(Element::class); |
|
0 commit comments