-
-
Notifications
You must be signed in to change notification settings - Fork 750
350 lines (299 loc) · 11.1 KB
/
webdriver-bidi.yml
File metadata and controls
350 lines (299 loc) · 11.1 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: WebDriver BiDi Protocol Tests
on:
push:
branches:
- 3.x
paths:
- 'lib/helper/WebDriver.js'
- 'test/helper/WebDriver_bidi_test.js'
- '.github/workflows/webdriver-bidi.yml'
pull_request:
branches:
- '**'
paths:
- 'lib/helper/WebDriver.js'
- 'test/helper/WebDriver_bidi_test.js'
- '.github/workflows/webdriver-bidi.yml'
env:
CI: true
FORCE_COLOR: 1
jobs:
bidi-tests:
name: WebDriver BiDi Protocol Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
chrome-version: [latest]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup Chrome ${{ matrix.chrome-version }}
uses: browser-actions/setup-chrome@v1
with:
chrome-version: ${{ matrix.chrome-version }}
- name: Setup ChromeDriver
uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: 'LATEST'
- name: Start Selenium Server with BiDi support
run: |
# Download and start Selenium Grid with BiDi protocol support
docker run -d --net=host --shm-size=2g \
-e SE_ENABLE_BIDI=true \
-e SE_SESSION_TIMEOUT=300 \
-e SE_NODE_SESSION_TIMEOUT=300 \
selenium/standalone-chrome:4.27
# Wait for Selenium to be ready
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
- name: Setup PHP for test server
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: Install dependencies
run: |
npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: Start test server
run: |
php -S 127.0.0.1:8000 -t test/data/app &
sleep 3
curl -f http://127.0.0.1:8000 || exit 1
- name: Verify BiDi protocol support
run: |
# Test if BiDi is available in the browser
node -e "
const { remote } = require('webdriverio');
(async () => {
try {
const browser = await remote({
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
},
webSocketUrl: true
}
});
console.log('BiDi WebSocket URL support:', !!browser.capabilities.webSocketUrl);
await browser.deleteSession();
console.log('✅ BiDi protocol verification passed');
} catch (error) {
console.error('❌ BiDi protocol verification failed:', error.message);
process.exit(1);
}
})();
"
- name: Run BiDi unit tests
run: |
./node_modules/.bin/mocha test/helper/WebDriver_bidi_test.js \
--timeout 30000 \
--reporter spec \
--exit
env:
NODE_ENV: test
DEBUG: codeceptjs:*
- name: Run WebDriver with BiDi integration tests
run: |
./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js \
--grep "@bidi" \
--reporter spec \
--verbose
continue-on-error: true
- name: Test BiDi configuration validation
run: |
node -e "
const WebDriver = require('./lib/helper/WebDriver');
// Test BiDi enabled configuration
const wdBidi = new WebDriver({
url: 'http://localhost:8000',
browser: 'chrome',
bidiProtocol: true
});
console.log('BiDi enabled:', wdBidi.bidiEnabled);
console.log('BiDi arrays initialized:', {
networkEvents: Array.isArray(wdBidi.bidiNetworkEvents),
consoleMessages: Array.isArray(wdBidi.bidiConsoleMessages),
navigationEvents: Array.isArray(wdBidi.bidiNavigationEvents),
scriptExceptions: Array.isArray(wdBidi.bidiScriptExceptions),
performanceMetrics: Array.isArray(wdBidi.bidiPerformanceMetrics)
});
// Test BiDi disabled configuration
const wdNoBidi = new WebDriver({
url: 'http://localhost:8000',
browser: 'chrome',
bidiProtocol: false
});
console.log('BiDi disabled correctly:', !wdNoBidi.bidiEnabled);
console.log('✅ BiDi configuration validation passed');
"
- name: Generate BiDi test report
if: always()
run: |
echo "## WebDriver BiDi Protocol Test Report" > bidi-test-report.md
echo "### Environment" >> bidi-test-report.md
echo "- Node.js: ${{ matrix.node-version }}" >> bidi-test-report.md
echo "- Chrome: ${{ matrix.chrome-version }}" >> bidi-test-report.md
echo "- Date: $(date)" >> bidi-test-report.md
echo "" >> bidi-test-report.md
echo "### Test Results" >> bidi-test-report.md
echo "BiDi protocol tests completed. Check the job logs for detailed results." >> bidi-test-report.md
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: bidi-test-report-node${{ matrix.node-version }}-chrome${{ matrix.chrome-version }}
path: |
bidi-test-report.md
test_output/
retention-days: 7
bidi-compatibility:
name: BiDi Backward Compatibility Tests
runs-on: ubuntu-latest
needs: bidi-tests
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1
- name: Start Selenium Server
run: |
docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.27
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: Install dependencies
run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: Start test server
run: |
php -S 127.0.0.1:8000 -t test/data/app &
sleep 3
- name: Test backward compatibility (BiDi disabled)
run: |
./node_modules/.bin/mocha test/helper/WebDriver_test.js \
--timeout 30000 \
--grep "should work with BiDi disabled" \
--reporter spec \
--exit
- name: Test existing WebDriver functionality with BiDi enabled
run: |
./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js \
--grep "@WebDriver" \
--reporter spec \
--verbose
env:
WEBDRIVER_BIDI_ENABLED: true
bidi-performance:
name: BiDi Performance Impact Analysis
runs-on: ubuntu-latest
needs: bidi-tests
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1
- name: Start Selenium Server
run: |
docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.27
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: Install dependencies
run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: Start test server
run: |
php -S 127.0.0.1:8000 -t test/data/app &
sleep 3
- name: Performance benchmark - BiDi disabled
run: |
node -e "
const WebDriver = require('./lib/helper/WebDriver');
const { performance } = require('perf_hooks');
(async () => {
const wd = new WebDriver({
url: 'http://localhost:8000',
browser: 'chrome',
bidiProtocol: false,
capabilities: {
'goog:chromeOptions': {
args: ['--headless', '--no-sandbox']
}
}
});
const start = performance.now();
await wd._startBrowser();
await wd.amOnPage('/form/example1');
await wd.see('Example1');
await wd._stopBrowser();
const end = performance.now();
console.log('BiDi Disabled Time:', (end - start).toFixed(2), 'ms');
})();
" > performance-without-bidi.txt
- name: Performance benchmark - BiDi enabled
run: |
node -e "
const WebDriver = require('./lib/helper/WebDriver');
const { performance } = require('perf_hooks');
(async () => {
const wd = new WebDriver({
url: 'http://localhost:8000',
browser: 'chrome',
bidiProtocol: true,
capabilities: {
'goog:chromeOptions': {
args: ['--headless', '--no-sandbox']
}
}
});
const start = performance.now();
await wd._startBrowser();
await wd.amOnPage('/form/example1');
await wd.see('Example1');
await wd._stopBrowser();
const end = performance.now();
console.log('BiDi Enabled Time:', (end - start).toFixed(2), 'ms');
})();
" > performance-with-bidi.txt
- name: Generate performance report
run: |
echo "## BiDi Performance Impact Report" > performance-report.md
echo "### Without BiDi Protocol" >> performance-report.md
cat performance-without-bidi.txt >> performance-report.md
echo "" >> performance-report.md
echo "### With BiDi Protocol" >> performance-report.md
cat performance-with-bidi.txt >> performance-report.md
echo "" >> performance-report.md
echo "### Analysis" >> performance-report.md
echo "Performance comparison completed. Review the execution times above." >> performance-report.md
- name: Upload performance artifacts
uses: actions/upload-artifact@v4
with:
name: bidi-performance-report
path: |
performance-report.md
performance-*.txt
retention-days: 7