Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 1 | import {browser, by, element, protractor} from 'protractor'; |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 2 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 3 | const EC = protractor.ExpectedConditions; |
| 4 | |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 5 | // Loads the page (or reloads it) and deals with the "Are you sure you want to |
| 6 | // leave this page" popup. |
| 7 | async function loadPage() { |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 8 | await disableAlerts(); |
| 9 | await browser.navigate().refresh(); |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 10 | expect(await browser.getTitle()).toEqual('FRC971 Scouting Application'); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 11 | await disableAlerts(); |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 12 | } |
| 13 | |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 14 | // Disables alert popups. They are extremely tedious to deal with in |
| 15 | // Protractor since they're not angular elements. We achieve this by checking |
| 16 | // an invisible checkbox that's off-screen. |
| 17 | async function disableAlerts() { |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 18 | await browser.executeAsyncScript(function (callback) { |
| 19 | let block_alerts = document.getElementById( |
| 20 | 'block_alerts' |
| 21 | ) as HTMLInputElement; |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 22 | block_alerts.checked = true; |
| 23 | callback(); |
| 24 | }); |
| 25 | } |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 26 | // Returns the contents of the header that displays the "Auto", "TeleOp", and |
| 27 | // "Climb" labels etc. |
| 28 | function getHeadingText() { |
| 29 | return element(by.css('.header')).getText(); |
| 30 | } |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 31 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 32 | // Returns the currently displayed progress message on the screen. This only |
| 33 | // exists on screens where the web page interacts with the web server. |
| 34 | function getProgressMessage() { |
| 35 | return element(by.css('.progress_message')).getText(); |
| 36 | } |
| 37 | |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 38 | // Returns the currently displayed error message on the screen. This only |
| 39 | // exists on screens where the web page interacts with the web server. |
| 40 | function getErrorMessage() { |
| 41 | return element(by.css('.error_message')).getText(); |
| 42 | } |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 43 | |
Philipp Schrader | 8aeb14f | 2022-04-08 21:23:18 -0700 | [diff] [blame^] | 44 | // Returns the currently displayed error message on the screen. This only |
| 45 | // exists on screens where the web page interacts with the web server. |
| 46 | function getValueOfInputById(id: string) { |
| 47 | return element(by.id(id)).getAttribute('value'); |
| 48 | } |
| 49 | |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 50 | // Asserts that the field on the "Submit and Review" screen has a specific |
| 51 | // value. |
| 52 | function expectReviewFieldToBe(fieldName: string, expectedValue: string) { |
| 53 | return expectNthReviewFieldToBe(fieldName, 0, expectedValue); |
| 54 | } |
| 55 | |
| 56 | // Asserts that the n'th instance of a field on the "Submit and Review" |
| 57 | // screen has a specific value. |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 58 | async function expectNthReviewFieldToBe( |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 59 | fieldName: string, |
| 60 | n: number, |
| 61 | expectedValue: string |
| 62 | ) { |
| 63 | expect( |
| 64 | await element |
| 65 | .all(by.cssContainingText('li', `${fieldName}:`)) |
| 66 | .get(n) |
| 67 | .getText() |
| 68 | ).toEqual(`${fieldName}: ${expectedValue}`); |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 69 | } |
| 70 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 71 | // Sets a text field to the specified value. |
| 72 | function setTextboxByIdTo(id: string, value: string) { |
| 73 | // Just sending "value" to the input fields is insufficient. We need to |
| 74 | // overwrite the text that is there. If we didn't hit CTRL-A to select all |
| 75 | // the text, we'd be appending to whatever is there already. |
| 76 | return element(by.id(id)).sendKeys( |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 77 | protractor.Key.CONTROL, |
| 78 | 'a', |
| 79 | protractor.Key.NULL, |
| 80 | value |
| 81 | ); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Philipp Schrader | fa45d74 | 2022-03-18 19:29:05 -0700 | [diff] [blame] | 84 | // Moves the nth slider left or right. A positive "adjustBy" value moves the |
| 85 | // slider to the right. A negative value moves the slider to the left. |
| 86 | // |
| 87 | // negative/left <--- 0 ---> positive/right |
| 88 | async function adjustNthSliderBy(n: number, adjustBy: number) { |
Philipp Schrader | 5079fa1 | 2022-03-19 15:40:12 -0700 | [diff] [blame] | 89 | const slider = element.all(by.css('input[type=range]')).get(n); |
| 90 | const key = |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 91 | adjustBy > 0 ? protractor.Key.ARROW_RIGHT : protractor.Key.ARROW_LEFT; |
Philipp Schrader | fa45d74 | 2022-03-18 19:29:05 -0700 | [diff] [blame] | 92 | for (let i = 0; i < Math.abs(adjustBy); i++) { |
| 93 | await slider.sendKeys(key); |
| 94 | } |
| 95 | } |
| 96 | |
Philipp Schrader | b99a8cc | 2022-03-18 21:00:02 -0700 | [diff] [blame] | 97 | function getNthMatchLabel(n: number) { |
| 98 | return element.all(by.css('.badge')).get(n).getText(); |
| 99 | } |
| 100 | |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 101 | describe('The scouting web page', () => { |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 102 | beforeAll(async () => { |
| 103 | await browser.get(browser.baseUrl); |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 104 | expect(await browser.getTitle()).toEqual('FRC971 Scouting Application'); |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 105 | await disableAlerts(); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 106 | |
| 107 | // Import the match list before running any tests. Ideally this should be |
| 108 | // run in beforeEach(), but it's not worth doing that at this time. Our |
| 109 | // tests are basic enough not to require this. |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 110 | await element( |
| 111 | by.cssContainingText('.nav-link', 'Import Match List') |
| 112 | ).click(); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 113 | expect(await getHeadingText()).toEqual('Import Match List'); |
| 114 | await setTextboxByIdTo('year', '2016'); |
| 115 | await setTextboxByIdTo('event_code', 'nytr'); |
| 116 | await element(by.buttonText('Import')).click(); |
| 117 | |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 118 | await browser.wait( |
| 119 | EC.textToBePresentInElement( |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 120 | element(by.css('.progress_message')), |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 121 | 'Successfully imported match list.' |
| 122 | ) |
| 123 | ); |
Philipp Schrader | cf91546 | 2022-03-16 23:42:22 -0700 | [diff] [blame] | 124 | }); |
| 125 | |
Philipp Schrader | b99a8cc | 2022-03-18 21:00:02 -0700 | [diff] [blame] | 126 | it('should: show matches in chronological order.', async () => { |
| 127 | await loadPage(); |
| 128 | |
Philipp Schrader | 8aeb14f | 2022-04-08 21:23:18 -0700 | [diff] [blame^] | 129 | expect(await getNthMatchLabel(0)).toEqual('Quals Match 1'); |
| 130 | expect(await getNthMatchLabel(1)).toEqual('Quals Match 2'); |
| 131 | expect(await getNthMatchLabel(2)).toEqual('Quals Match 3'); |
| 132 | expect(await getNthMatchLabel(9)).toEqual('Quals Match 10'); |
| 133 | expect(await getNthMatchLabel(72)).toEqual('Quarter Final 1 Match 1'); |
| 134 | expect(await getNthMatchLabel(73)).toEqual('Quarter Final 2 Match 1'); |
| 135 | expect(await getNthMatchLabel(74)).toEqual('Quarter Final 3 Match 1'); |
| 136 | expect(await getNthMatchLabel(75)).toEqual('Quarter Final 4 Match 1'); |
| 137 | expect(await getNthMatchLabel(76)).toEqual('Quarter Final 1 Match 2'); |
| 138 | expect(await getNthMatchLabel(82)).toEqual('Semi Final 1 Match 1'); |
| 139 | expect(await getNthMatchLabel(83)).toEqual('Semi Final 2 Match 1'); |
| 140 | expect(await getNthMatchLabel(84)).toEqual('Semi Final 1 Match 2'); |
| 141 | expect(await getNthMatchLabel(85)).toEqual('Semi Final 2 Match 2'); |
| 142 | expect(await getNthMatchLabel(89)).toEqual('Final 1 Match 3'); |
| 143 | }); |
| 144 | |
| 145 | it('should: prefill the match information.', async () => { |
| 146 | await loadPage(); |
| 147 | |
| 148 | expect(await getHeadingText()).toEqual('Matches'); |
| 149 | |
| 150 | // On the 87th row of matches (index 86) click on the second team |
| 151 | // (index 1) which resolves to team 5254 in semi final 2 match 3. |
| 152 | await element |
| 153 | .all(by.css('button.match-item')) |
| 154 | .get(86 * 6 + 1) |
| 155 | .click(); |
| 156 | |
| 157 | expect(await getHeadingText()).toEqual('Team Selection'); |
| 158 | expect(await getValueOfInputById('match_number')).toEqual('3'); |
| 159 | expect(await getValueOfInputById('team_number')).toEqual('5254'); |
| 160 | expect(await getValueOfInputById('round')).toEqual('2'); |
| 161 | expect(await getValueOfInputById('comp_level')).toEqual('3: sf'); |
Philipp Schrader | b99a8cc | 2022-03-18 21:00:02 -0700 | [diff] [blame] | 162 | }); |
| 163 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 164 | it('should: error on unknown match.', async () => { |
| 165 | await loadPage(); |
| 166 | |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 167 | await element(by.cssContainingText('.nav-link', 'Data Entry')).click(); |
| 168 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 169 | // Pick a match that doesn't exist in the 2016nytr match list. |
| 170 | await setTextboxByIdTo('match_number', '3'); |
| 171 | await setTextboxByIdTo('team_number', '971'); |
| 172 | |
| 173 | // Click Next until we get to the submit screen. |
| 174 | for (let i = 0; i < 5; i++) { |
| 175 | await element(by.buttonText('Next')).click(); |
| 176 | } |
| 177 | expect(await getHeadingText()).toEqual('Review and Submit'); |
| 178 | |
| 179 | // Attempt to submit and validate the error. |
| 180 | await element(by.buttonText('Submit')).click(); |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 181 | expect(await getErrorMessage()).toContain( |
| 182 | 'Failed to find team 971 in match 3 in the schedule.' |
| 183 | ); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 184 | }); |
| 185 | |
Philipp Schrader | 5079fa1 | 2022-03-19 15:40:12 -0700 | [diff] [blame] | 186 | // Make sure that each page on the Entry tab has both "Next" and "Back" |
| 187 | // buttons. The only screens exempted from this are the first page and the |
| 188 | // last page. |
| 189 | it('should: have forwards and backwards buttons.', async () => { |
| 190 | await loadPage(); |
| 191 | |
| 192 | await element(by.cssContainingText('.nav-link', 'Data Entry')).click(); |
| 193 | |
| 194 | const expectedOrder = [ |
| 195 | 'Team Selection', |
| 196 | 'Auto', |
| 197 | 'TeleOp', |
| 198 | 'Climb', |
| 199 | 'Other', |
| 200 | 'Review and Submit', |
| 201 | ]; |
| 202 | |
| 203 | // Go forward through the screens. |
| 204 | for (let i = 0; i < expectedOrder.length; i++) { |
| 205 | expect(await getHeadingText()).toEqual(expectedOrder[i]); |
| 206 | if (i != expectedOrder.length - 1) { |
| 207 | await element(by.buttonText('Next')).click(); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | // Go backwards through the screens. |
| 212 | for (let i = 0; i < expectedOrder.length; i++) { |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 213 | expect(await getHeadingText()).toEqual( |
| 214 | expectedOrder[expectedOrder.length - i - 1] |
| 215 | ); |
Philipp Schrader | 5079fa1 | 2022-03-19 15:40:12 -0700 | [diff] [blame] | 216 | if (i != expectedOrder.length - 1) { |
| 217 | await element(by.buttonText('Back')).click(); |
| 218 | } |
| 219 | } |
| 220 | }); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 221 | |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 222 | it('should: review and submit correct data.', async () => { |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 223 | await loadPage(); |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 224 | |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 225 | await element(by.cssContainingText('.nav-link', 'Data Entry')).click(); |
| 226 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 227 | // Submit scouting data for a random team that attended 2016nytr. |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 228 | expect(await getHeadingText()).toEqual('Team Selection'); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 229 | await setTextboxByIdTo('match_number', '2'); |
| 230 | await setTextboxByIdTo('team_number', '5254'); |
Philipp Schrader | 8aeb14f | 2022-04-08 21:23:18 -0700 | [diff] [blame^] | 231 | await setTextboxByIdTo('round', '42'); |
| 232 | await element(by.cssContainingText('option', 'Semi Finals')).click(); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 233 | await element(by.buttonText('Next')).click(); |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 234 | |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 235 | expect(await getHeadingText()).toEqual('Auto'); |
Philipp Schrader | e7c252d | 2022-03-17 21:13:47 -0700 | [diff] [blame] | 236 | await element(by.id('quadrant3')).click(); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 237 | await element(by.buttonText('Next')).click(); |
| 238 | |
| 239 | expect(await getHeadingText()).toEqual('TeleOp'); |
| 240 | await element(by.buttonText('Next')).click(); |
| 241 | |
| 242 | expect(await getHeadingText()).toEqual('Climb'); |
Philipp Schrader | 5990fd3 | 2022-03-15 21:49:58 -0700 | [diff] [blame] | 243 | await element(by.id('high')).click(); |
Philipp Schrader | 5079fa1 | 2022-03-19 15:40:12 -0700 | [diff] [blame] | 244 | await setTextboxByIdTo('comment', 'A very useful comment here.'); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 245 | await element(by.buttonText('Next')).click(); |
| 246 | |
Philipp Schrader | e279e1a | 2022-03-15 22:20:10 -0700 | [diff] [blame] | 247 | expect(await getHeadingText()).toEqual('Other'); |
Philipp Schrader | fa45d74 | 2022-03-18 19:29:05 -0700 | [diff] [blame] | 248 | await adjustNthSliderBy(0, 3); |
| 249 | await adjustNthSliderBy(1, 1); |
Philipp Schrader | e279e1a | 2022-03-15 22:20:10 -0700 | [diff] [blame] | 250 | await element(by.id('no_show')).click(); |
| 251 | await element(by.id('mechanically_broke')).click(); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 252 | await element(by.buttonText('Next')).click(); |
| 253 | |
| 254 | expect(await getHeadingText()).toEqual('Review and Submit'); |
| 255 | expect(await getErrorMessage()).toEqual(''); |
| 256 | |
| 257 | // Validate Team Selection. |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 258 | await expectReviewFieldToBe('Match number', '2'); |
| 259 | await expectReviewFieldToBe('Team number', '5254'); |
Philipp Schrader | 8aeb14f | 2022-04-08 21:23:18 -0700 | [diff] [blame^] | 260 | await expectReviewFieldToBe('Round', '42'); |
| 261 | await expectReviewFieldToBe('Comp Level', 'Semi Finals'); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 262 | |
| 263 | // Validate Auto. |
| 264 | await expectNthReviewFieldToBe('Upper Shots Made', 0, '0'); |
| 265 | await expectNthReviewFieldToBe('Lower Shots Made', 0, '0'); |
| 266 | await expectNthReviewFieldToBe('Missed Shots', 0, '0'); |
Philipp Schrader | e7c252d | 2022-03-17 21:13:47 -0700 | [diff] [blame] | 267 | await expectReviewFieldToBe('Quadrant', '3'); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 268 | |
| 269 | // Validate TeleOp. |
| 270 | await expectNthReviewFieldToBe('Upper Shots Made', 1, '0'); |
| 271 | await expectNthReviewFieldToBe('Lower Shots Made', 1, '0'); |
| 272 | await expectNthReviewFieldToBe('Missed Shots', 1, '0'); |
| 273 | |
| 274 | // Validate Climb. |
Philipp Schrader | 8aeb14f | 2022-04-08 21:23:18 -0700 | [diff] [blame^] | 275 | await expectReviewFieldToBe('Climb Level', 'High'); |
Philipp Schrader | fa45d74 | 2022-03-18 19:29:05 -0700 | [diff] [blame] | 276 | await expectReviewFieldToBe('Comments', 'A very useful comment here.'); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 277 | |
Philipp Schrader | e279e1a | 2022-03-15 22:20:10 -0700 | [diff] [blame] | 278 | // Validate Other. |
Philipp Schrader | fa45d74 | 2022-03-18 19:29:05 -0700 | [diff] [blame] | 279 | await expectReviewFieldToBe('Defense Played On Rating', '3'); |
| 280 | await expectReviewFieldToBe('Defense Played Rating', '1'); |
Philipp Schrader | e279e1a | 2022-03-15 22:20:10 -0700 | [diff] [blame] | 281 | await expectReviewFieldToBe('No show', 'true'); |
| 282 | await expectReviewFieldToBe('Never moved', 'false'); |
| 283 | await expectReviewFieldToBe('Battery died', 'false'); |
| 284 | await expectReviewFieldToBe('Broke (mechanically)', 'true'); |
Philipp Schrader | fa09693 | 2022-03-05 20:07:10 -0800 | [diff] [blame] | 285 | |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 286 | await element(by.buttonText('Submit')).click(); |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 287 | await browser.wait( |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 288 | EC.textToBePresentInElement(element(by.css('.header')), 'Success') |
| 289 | ); |
Philipp Schrader | 5f19001 | 2022-03-15 23:29:09 -0700 | [diff] [blame] | 290 | |
| 291 | // TODO(phil): Make sure the data made its way to the database correctly. |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 292 | }); |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 293 | |
| 294 | it('should: load all images successfully.', async () => { |
| 295 | await loadPage(); |
| 296 | |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 297 | await element(by.cssContainingText('.nav-link', 'Data Entry')).click(); |
| 298 | |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 299 | // Get to the Auto display with the field pictures. |
| 300 | expect(await getHeadingText()).toEqual('Team Selection'); |
| 301 | await element(by.buttonText('Next')).click(); |
| 302 | expect(await getHeadingText()).toEqual('Auto'); |
| 303 | |
| 304 | // We expect 2 fully loaded images. |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 305 | browser |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 306 | .executeAsyncScript(function (callback) { |
| 307 | let images = document.getElementsByTagName('img'); |
| 308 | let numLoaded = 0; |
| 309 | for (let i = 0; i < images.length; i += 1) { |
| 310 | if (images[i].naturalWidth > 0) { |
| 311 | numLoaded += 1; |
Ravago Jones | 2813c03 | 2022-03-16 23:44:11 -0700 | [diff] [blame] | 312 | } |
Philipp Schrader | 817cce3 | 2022-03-26 15:00:00 -0700 | [diff] [blame] | 313 | } |
| 314 | callback(numLoaded); |
| 315 | }) |
| 316 | .then(function (numLoaded) { |
| 317 | expect(numLoaded).toBe(2); |
| 318 | }); |
Philipp Schrader | 577befe | 2022-03-15 00:00:49 -0700 | [diff] [blame] | 319 | }); |
Philipp Schrader | d999c9f | 2022-02-27 15:48:58 -0800 | [diff] [blame] | 320 | }); |