forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathadd_intercept_parameters_test.js
More file actions
106 lines (93 loc) · 3.82 KB
/
Copy pathadd_intercept_parameters_test.js
File metadata and controls
106 lines (93 loc) · 3.82 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
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
'use strict'
const assert = require('node:assert')
const { Browser } = require('selenium-webdriver')
const { suite } = require('../../lib/test')
const Network = require('selenium-webdriver/bidi/network')
const { AddInterceptParameters } = require('selenium-webdriver/bidi/addInterceptParameters')
const { InterceptPhase } = require('selenium-webdriver/bidi/interceptPhase')
const { UrlPattern } = require('selenium-webdriver/bidi/urlPattern')
suite(
function (env) {
let driver
let network
beforeEach(async function () {
driver = await env.builder().build()
network = await Network(driver)
})
afterEach(async function () {
await network.close()
await driver.quit()
})
describe('Add Intercept parameters test', function () {
it('can add intercept phase', async function () {
const intercept = await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT))
assert.notEqual(intercept, null)
})
it('can add intercept phases', async function () {
const intercept = await network.addIntercept(
new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED, InterceptPhase.BEFORE_REQUEST_SENT),
)
assert.notEqual(intercept, null)
})
it('can add string url pattern', async function () {
const intercept = await network.addIntercept(
new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT).urlStringPattern(
'http://localhost:4444/basicAuth',
),
)
assert.notEqual(intercept, null)
})
it('can add string url patterns', async function () {
const intercept = await network.addIntercept(
new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT).urlStringPatterns([
'http://localhost:4444/basicAuth',
'http://localhost:4445/logEntryAdded',
]),
)
assert.notEqual(intercept, null)
})
it('can add url pattern', async function () {
const urlPattern = new UrlPattern().protocol('http').hostname('localhost').port(4444).pathname('basicAuth')
const intercept = await network.addIntercept(
new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT).urlPattern(urlPattern),
)
assert.notEqual(intercept, null)
})
it('can add url patterns', async function () {
const urlPattern1 = new UrlPattern()
.protocol('http')
.hostname('localhost')
.port(4444)
.pathname('logEntryAdded')
.search('')
const urlPattern2 = new UrlPattern()
.protocol('https')
.hostname('localhost')
.port(4445)
.pathname('basicAuth')
.search('auth')
const intercept = await network.addIntercept(
new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT).urlPatterns([urlPattern1, urlPattern2]),
)
assert.notEqual(intercept, null)
})
})
},
{ browsers: [Browser.FIREFOX, Browser.CHROME, Browser.EDGE] },
)