Skip to content

Commit 11d7602

Browse files
committed
bidi enhancement for wd
1 parent 15a288e commit 11d7602

File tree

6 files changed

+1276
-5
lines changed

6 files changed

+1276
-5
lines changed
Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
name: WebDriver BiDi Protocol Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 3.x
7+
paths:
8+
- 'lib/helper/WebDriver.js'
9+
- 'test/helper/WebDriver_bidi_test.js'
10+
- '.github/workflows/webdriver-bidi.yml'
11+
pull_request:
12+
branches:
13+
- '**'
14+
paths:
15+
- 'lib/helper/WebDriver.js'
16+
- 'test/helper/WebDriver_bidi_test.js'
17+
- '.github/workflows/webdriver-bidi.yml'
18+
19+
env:
20+
CI: true
21+
FORCE_COLOR: 1
22+
23+
jobs:
24+
bidi-tests:
25+
name: WebDriver BiDi Protocol Tests
26+
runs-on: ubuntu-latest
27+
strategy:
28+
matrix:
29+
node-version: [20.x]
30+
chrome-version: [latest]
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v5
35+
36+
- name: Setup Node.js ${{ matrix.node-version }}
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
41+
- name: Setup Chrome ${{ matrix.chrome-version }}
42+
uses: browser-actions/setup-chrome@v1
43+
with:
44+
chrome-version: ${{ matrix.chrome-version }}
45+
46+
- name: Setup ChromeDriver
47+
uses: nanasess/setup-chromedriver@v2
48+
with:
49+
chromedriver-version: 'LATEST'
50+
51+
- name: Start Selenium Server with BiDi support
52+
run: |
53+
# Download and start Selenium Grid with BiDi protocol support
54+
docker run -d --net=host --shm-size=2g \
55+
-e SE_ENABLE_BIDI=true \
56+
-e SE_SESSION_TIMEOUT=300 \
57+
-e SE_NODE_SESSION_TIMEOUT=300 \
58+
selenium/standalone-chrome:4.27
59+
60+
# Wait for Selenium to be ready
61+
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
62+
63+
- name: Setup PHP for test server
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: 8.0
67+
68+
- name: Install dependencies
69+
run: |
70+
npm ci
71+
env:
72+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
73+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
74+
75+
- name: Start test server
76+
run: |
77+
php -S 127.0.0.1:8000 -t test/data/app &
78+
sleep 3
79+
curl -f http://127.0.0.1:8000 || exit 1
80+
81+
- name: Verify BiDi protocol support
82+
run: |
83+
# Test if BiDi is available in the browser
84+
node -e "
85+
const { remote } = require('webdriverio');
86+
(async () => {
87+
try {
88+
const browser = await remote({
89+
capabilities: {
90+
browserName: 'chrome',
91+
'goog:chromeOptions': {
92+
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
93+
},
94+
webSocketUrl: true
95+
}
96+
});
97+
98+
console.log('BiDi WebSocket URL support:', !!browser.capabilities.webSocketUrl);
99+
await browser.deleteSession();
100+
console.log('✅ BiDi protocol verification passed');
101+
} catch (error) {
102+
console.error('❌ BiDi protocol verification failed:', error.message);
103+
process.exit(1);
104+
}
105+
})();
106+
"
107+
108+
- name: Run BiDi unit tests
109+
run: |
110+
./node_modules/.bin/mocha test/helper/WebDriver_bidi_test.js \
111+
--timeout 30000 \
112+
--reporter spec \
113+
--exit
114+
env:
115+
NODE_ENV: test
116+
DEBUG: codeceptjs:*
117+
118+
- name: Run WebDriver with BiDi integration tests
119+
run: |
120+
./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js \
121+
--grep "@bidi" \
122+
--reporter spec \
123+
--verbose
124+
continue-on-error: true
125+
126+
- name: Test BiDi configuration validation
127+
run: |
128+
node -e "
129+
const WebDriver = require('./lib/helper/WebDriver');
130+
131+
// Test BiDi enabled configuration
132+
const wdBidi = new WebDriver({
133+
url: 'http://localhost:8000',
134+
browser: 'chrome',
135+
bidiProtocol: true
136+
});
137+
138+
console.log('BiDi enabled:', wdBidi.bidiEnabled);
139+
console.log('BiDi arrays initialized:', {
140+
networkEvents: Array.isArray(wdBidi.bidiNetworkEvents),
141+
consoleMessages: Array.isArray(wdBidi.bidiConsoleMessages),
142+
navigationEvents: Array.isArray(wdBidi.bidiNavigationEvents),
143+
scriptExceptions: Array.isArray(wdBidi.bidiScriptExceptions),
144+
performanceMetrics: Array.isArray(wdBidi.bidiPerformanceMetrics)
145+
});
146+
147+
// Test BiDi disabled configuration
148+
const wdNoBidi = new WebDriver({
149+
url: 'http://localhost:8000',
150+
browser: 'chrome',
151+
bidiProtocol: false
152+
});
153+
154+
console.log('BiDi disabled correctly:', !wdNoBidi.bidiEnabled);
155+
console.log('✅ BiDi configuration validation passed');
156+
"
157+
158+
- name: Generate BiDi test report
159+
if: always()
160+
run: |
161+
echo "## WebDriver BiDi Protocol Test Report" > bidi-test-report.md
162+
echo "### Environment" >> bidi-test-report.md
163+
echo "- Node.js: ${{ matrix.node-version }}" >> bidi-test-report.md
164+
echo "- Chrome: ${{ matrix.chrome-version }}" >> bidi-test-report.md
165+
echo "- Date: $(date)" >> bidi-test-report.md
166+
echo "" >> bidi-test-report.md
167+
echo "### Test Results" >> bidi-test-report.md
168+
echo "BiDi protocol tests completed. Check the job logs for detailed results." >> bidi-test-report.md
169+
170+
- name: Upload test artifacts
171+
if: always()
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: bidi-test-report-node${{ matrix.node-version }}-chrome${{ matrix.chrome-version }}
175+
path: |
176+
bidi-test-report.md
177+
test_output/
178+
retention-days: 7
179+
180+
bidi-compatibility:
181+
name: BiDi Backward Compatibility Tests
182+
runs-on: ubuntu-latest
183+
needs: bidi-tests
184+
185+
steps:
186+
- name: Checkout code
187+
uses: actions/checkout@v5
188+
189+
- name: Setup Node.js
190+
uses: actions/setup-node@v4
191+
with:
192+
node-version: 20.x
193+
194+
- name: Setup Chrome
195+
uses: browser-actions/setup-chrome@v1
196+
197+
- name: Start Selenium Server
198+
run: |
199+
docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.27
200+
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
201+
202+
- name: Setup PHP
203+
uses: shivammathur/setup-php@v2
204+
with:
205+
php-version: 8.0
206+
207+
- name: Install dependencies
208+
run: npm ci
209+
env:
210+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
211+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
212+
213+
- name: Start test server
214+
run: |
215+
php -S 127.0.0.1:8000 -t test/data/app &
216+
sleep 3
217+
218+
- name: Test backward compatibility (BiDi disabled)
219+
run: |
220+
./node_modules/.bin/mocha test/helper/WebDriver_test.js \
221+
--timeout 30000 \
222+
--grep "should work with BiDi disabled" \
223+
--reporter spec \
224+
--exit
225+
226+
- name: Test existing WebDriver functionality with BiDi enabled
227+
run: |
228+
./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js \
229+
--grep "@WebDriver" \
230+
--reporter spec \
231+
--verbose
232+
env:
233+
WEBDRIVER_BIDI_ENABLED: true
234+
235+
bidi-performance:
236+
name: BiDi Performance Impact Analysis
237+
runs-on: ubuntu-latest
238+
needs: bidi-tests
239+
240+
steps:
241+
- name: Checkout code
242+
uses: actions/checkout@v5
243+
244+
- name: Setup Node.js
245+
uses: actions/setup-node@v4
246+
with:
247+
node-version: 20.x
248+
249+
- name: Setup Chrome
250+
uses: browser-actions/setup-chrome@v1
251+
252+
- name: Start Selenium Server
253+
run: |
254+
docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.27
255+
timeout 60 bash -c 'until curl -s http://localhost:4444/wd/hub/status > /dev/null; do sleep 1; done'
256+
257+
- name: Setup PHP
258+
uses: shivammathur/setup-php@v2
259+
with:
260+
php-version: 8.0
261+
262+
- name: Install dependencies
263+
run: npm ci
264+
env:
265+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
266+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
267+
268+
- name: Start test server
269+
run: |
270+
php -S 127.0.0.1:8000 -t test/data/app &
271+
sleep 3
272+
273+
- name: Performance benchmark - BiDi disabled
274+
run: |
275+
node -e "
276+
const WebDriver = require('./lib/helper/WebDriver');
277+
const { performance } = require('perf_hooks');
278+
279+
(async () => {
280+
const wd = new WebDriver({
281+
url: 'http://localhost:8000',
282+
browser: 'chrome',
283+
bidiProtocol: false,
284+
capabilities: {
285+
'goog:chromeOptions': {
286+
args: ['--headless', '--no-sandbox']
287+
}
288+
}
289+
});
290+
291+
const start = performance.now();
292+
await wd._startBrowser();
293+
await wd.amOnPage('/form/example1');
294+
await wd.see('Example1');
295+
await wd._stopBrowser();
296+
const end = performance.now();
297+
298+
console.log('BiDi Disabled Time:', (end - start).toFixed(2), 'ms');
299+
})();
300+
" > performance-without-bidi.txt
301+
302+
- name: Performance benchmark - BiDi enabled
303+
run: |
304+
node -e "
305+
const WebDriver = require('./lib/helper/WebDriver');
306+
const { performance } = require('perf_hooks');
307+
308+
(async () => {
309+
const wd = new WebDriver({
310+
url: 'http://localhost:8000',
311+
browser: 'chrome',
312+
bidiProtocol: true,
313+
capabilities: {
314+
'goog:chromeOptions': {
315+
args: ['--headless', '--no-sandbox']
316+
}
317+
}
318+
});
319+
320+
const start = performance.now();
321+
await wd._startBrowser();
322+
await wd.amOnPage('/form/example1');
323+
await wd.see('Example1');
324+
await wd._stopBrowser();
325+
const end = performance.now();
326+
327+
console.log('BiDi Enabled Time:', (end - start).toFixed(2), 'ms');
328+
})();
329+
" > performance-with-bidi.txt
330+
331+
- name: Generate performance report
332+
run: |
333+
echo "## BiDi Performance Impact Report" > performance-report.md
334+
echo "### Without BiDi Protocol" >> performance-report.md
335+
cat performance-without-bidi.txt >> performance-report.md
336+
echo "" >> performance-report.md
337+
echo "### With BiDi Protocol" >> performance-report.md
338+
cat performance-with-bidi.txt >> performance-report.md
339+
echo "" >> performance-report.md
340+
echo "### Analysis" >> performance-report.md
341+
echo "Performance comparison completed. Review the execution times above." >> performance-report.md
342+
343+
- name: Upload performance artifacts
344+
uses: actions/upload-artifact@v4
345+
with:
346+
name: bidi-performance-report
347+
path: |
348+
performance-report.md
349+
performance-*.txt
350+
retention-days: 7

.github/workflows/webdriver.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,10 @@ jobs:
4242
run: './bin/codecept.js check -c test/acceptance/codecept.WebDriver.js'
4343
- name: run unit tests
4444
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit
45+
- name: run BiDi protocol unit tests
46+
run: ./node_modules/.bin/mocha test/helper/WebDriver_bidi_test.js --timeout 30000 --exit
4547
- name: run tests
4648
run: './bin/codecept.js run -c test/acceptance/codecept.WebDriver.js --grep @WebDriver --debug'
49+
- name: run BiDi integration tests
50+
run: './bin/codecept.js run -c test/acceptance/codecept.WebDriver.js --grep @bidi --debug'
51+
continue-on-error: true

0 commit comments

Comments
 (0)