selenium-webdriver 4.28.0 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +8 -0
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/webdriver/bidi/network/cookies.rb +38 -0
- data/lib/selenium/webdriver/bidi/network/credentials.rb +43 -0
- data/lib/selenium/webdriver/bidi/network/headers.rb +38 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_auth.rb +38 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_item.rb +37 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_request.rb +69 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_response.rb +81 -0
- data/lib/selenium/webdriver/bidi/network/url_pattern.rb +65 -0
- data/lib/selenium/webdriver/bidi/network.rb +73 -16
- data/lib/selenium/webdriver/bidi.rb +4 -0
- data/lib/selenium/webdriver/common/network.rb +61 -23
- data/lib/selenium/webdriver/firefox/driver.rb +0 -18
- data/lib/selenium/webdriver/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7bd6340cd61180fd4c0c8753b7dd74972781b016492a8ef9f8c57ade61d26ea
|
4
|
+
data.tar.gz: 0f44ea455592315221ba1e994f353b7d6d359fe88a093e25bf558bb7f286258f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bc2ad2827460f67b298abc21740300382957d1dddc97f5708f89571d68ba9f479d21d8131c838b8430a291dc0bb0eaef02f961f83186603540967f01bf8749d
|
7
|
+
data.tar.gz: 1b532269414d71bad4c262bb2fb4a34b084bac4fa39b341f16305265fffb1c2f9e47fc399bf8e97f06212d37d15fec9f6361df4d5d4a480896a61ecc126e7a3b
|
data/CHANGES
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
4.29.0 (2025-02-17)
|
2
|
+
=========================
|
3
|
+
* Add CDP for Chrome 133 and remove 130
|
4
|
+
* [rb] Add Bidi Network Response Handler (#14900)
|
5
|
+
* [rb] Remove Firefox CDP (#15200)
|
6
|
+
* [rb][BiDi] Add support for provide response command (#15080)
|
7
|
+
* [rb][BiDi] Add set cache behaviour (#15114)
|
8
|
+
|
1
9
|
4.28.0 (2025-01-16)
|
2
10
|
=========================
|
3
11
|
* Add CDP for Chrome 132 and remove 129
|
data/bin/linux/selenium-manager
CHANGED
Binary file
|
data/bin/macos/selenium-manager
CHANGED
Binary file
|
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class Cookies < Hash
|
24
|
+
def initialize(cookies = {})
|
25
|
+
super()
|
26
|
+
merge!(cookies)
|
27
|
+
end
|
28
|
+
|
29
|
+
def as_json
|
30
|
+
self[:name] = self[:name].to_s
|
31
|
+
self[:value] = {type: 'string', value: self[:value].to_s}
|
32
|
+
|
33
|
+
[compact]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end # BiDi
|
37
|
+
end # WebDriver
|
38
|
+
end # Selenium
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class Credentials
|
24
|
+
attr_accessor :username, :password
|
25
|
+
|
26
|
+
def initialize(username: nil, password: nil)
|
27
|
+
@username = username
|
28
|
+
@password = password
|
29
|
+
end
|
30
|
+
|
31
|
+
def as_json
|
32
|
+
return nil unless username && password
|
33
|
+
|
34
|
+
{
|
35
|
+
type: 'password',
|
36
|
+
username: username,
|
37
|
+
password: password
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end # BiDi
|
42
|
+
end # WebDriver
|
43
|
+
end # Selenium
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class Headers < Hash
|
24
|
+
def as_json
|
25
|
+
map do |name, val|
|
26
|
+
{
|
27
|
+
name: name.to_s,
|
28
|
+
value: {
|
29
|
+
type: 'string',
|
30
|
+
value: val.to_s
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end # BiDi
|
37
|
+
end # WebDriver
|
38
|
+
end # Selenium
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class InterceptedAuth < InterceptedItem
|
24
|
+
def authenticate(username, password)
|
25
|
+
network.continue_with_auth(id, username, password)
|
26
|
+
end
|
27
|
+
|
28
|
+
def skip
|
29
|
+
network.continue_without_auth(id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def cancel
|
33
|
+
network.cancel_auth(id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end # BiDi
|
37
|
+
end # WebDriver
|
38
|
+
end # Selenium
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class InterceptedItem
|
24
|
+
attr_reader :network, :request
|
25
|
+
|
26
|
+
def initialize(network, request)
|
27
|
+
@network = network
|
28
|
+
@request = request
|
29
|
+
end
|
30
|
+
|
31
|
+
def id
|
32
|
+
@id ||= @request['request']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end # BiDi
|
36
|
+
end # WebDriver
|
37
|
+
end # Selenium
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
require_relative 'cookies'
|
21
|
+
require_relative 'headers'
|
22
|
+
|
23
|
+
module Selenium
|
24
|
+
module WebDriver
|
25
|
+
class BiDi
|
26
|
+
class InterceptedRequest < InterceptedItem
|
27
|
+
attr_accessor :method, :url
|
28
|
+
attr_reader :body
|
29
|
+
|
30
|
+
def initialize(network, request)
|
31
|
+
super
|
32
|
+
@method = nil
|
33
|
+
@url = nil
|
34
|
+
@body = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def continue
|
38
|
+
network.continue_request(
|
39
|
+
id: id,
|
40
|
+
body: body,
|
41
|
+
cookies: cookies.as_json,
|
42
|
+
headers: headers.as_json,
|
43
|
+
method: method,
|
44
|
+
url: url
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def fail
|
49
|
+
network.fail_request(id)
|
50
|
+
end
|
51
|
+
|
52
|
+
def body=(value)
|
53
|
+
@body = {
|
54
|
+
type: 'string',
|
55
|
+
value: value.to_json
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def headers
|
60
|
+
@headers ||= Headers.new
|
61
|
+
end
|
62
|
+
|
63
|
+
def cookies(cookies = {})
|
64
|
+
@cookies ||= Cookies.new(cookies)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end # BiDi
|
68
|
+
end # WebDriver
|
69
|
+
end # Selenium
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
require_relative 'credentials'
|
21
|
+
require_relative 'headers'
|
22
|
+
require_relative 'cookies'
|
23
|
+
|
24
|
+
module Selenium
|
25
|
+
module WebDriver
|
26
|
+
class BiDi
|
27
|
+
class InterceptedResponse < InterceptedItem
|
28
|
+
attr_accessor :reason, :status
|
29
|
+
attr_reader :body
|
30
|
+
|
31
|
+
def initialize(network, request)
|
32
|
+
super
|
33
|
+
@reason = nil
|
34
|
+
@status = nil
|
35
|
+
@body = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def continue
|
39
|
+
network.continue_response(
|
40
|
+
id: id,
|
41
|
+
cookies: cookies.as_json,
|
42
|
+
headers: headers.as_json,
|
43
|
+
credentials: credentials.as_json,
|
44
|
+
reason: reason,
|
45
|
+
status: status
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def provide_response
|
50
|
+
network.provide_response(
|
51
|
+
id: id,
|
52
|
+
cookies: cookies.as_json,
|
53
|
+
headers: headers.as_json,
|
54
|
+
body: body,
|
55
|
+
reason: reason,
|
56
|
+
status: status
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def credentials(username: nil, password: nil)
|
61
|
+
@credentials ||= Credentials.new(username: username, password: password)
|
62
|
+
end
|
63
|
+
|
64
|
+
def headers
|
65
|
+
@headers ||= Headers.new
|
66
|
+
end
|
67
|
+
|
68
|
+
def cookies(cookies = {})
|
69
|
+
@cookies ||= Cookies.new(cookies)
|
70
|
+
end
|
71
|
+
|
72
|
+
def body=(value)
|
73
|
+
@body = {
|
74
|
+
type: 'string',
|
75
|
+
value: value.to_json
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end # BiDi
|
80
|
+
end # WebDriver
|
81
|
+
end # Selenium
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
require 'uri'
|
21
|
+
|
22
|
+
module Selenium
|
23
|
+
module WebDriver
|
24
|
+
class BiDi
|
25
|
+
module UrlPattern
|
26
|
+
module_function
|
27
|
+
|
28
|
+
def format_pattern(url_patterns, pattern_type)
|
29
|
+
case pattern_type
|
30
|
+
when :string
|
31
|
+
to_url_string_pattern(url_patterns)
|
32
|
+
when :url
|
33
|
+
to_url_pattern(url_patterns)
|
34
|
+
else
|
35
|
+
raise ArgumentError, "Unknown pattern type: #{pattern_type}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_url_pattern(*url_patterns)
|
40
|
+
url_patterns.flatten.map do |url_pattern|
|
41
|
+
uri = URI.parse(url_pattern)
|
42
|
+
|
43
|
+
{
|
44
|
+
type: 'pattern',
|
45
|
+
protocol: uri.scheme || '',
|
46
|
+
hostname: uri.host || '',
|
47
|
+
port: uri.port.to_s || '',
|
48
|
+
pathname: uri.path || '',
|
49
|
+
search: uri.query || ''
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_url_string_pattern(*url_patterns)
|
55
|
+
url_patterns.flatten.map do |url_pattern|
|
56
|
+
{
|
57
|
+
type: 'string',
|
58
|
+
pattern: url_pattern
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end # BiDi
|
64
|
+
end # WebDriver
|
65
|
+
end # Selenium
|
@@ -16,6 +16,7 @@
|
|
16
16
|
# KIND, either express or implied. See the License for the
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
|
+
require_relative 'network/url_pattern'
|
19
20
|
|
20
21
|
module Selenium
|
21
22
|
module WebDriver
|
@@ -39,8 +40,12 @@ module Selenium
|
|
39
40
|
@bidi = bidi
|
40
41
|
end
|
41
42
|
|
42
|
-
def add_intercept(phases: [], contexts: nil, url_patterns: nil)
|
43
|
-
|
43
|
+
def add_intercept(phases: [], contexts: nil, url_patterns: nil, pattern_type: :string)
|
44
|
+
url_patterns = url_patterns && pattern_type ? UrlPattern.format_pattern(url_patterns, pattern_type) : nil
|
45
|
+
@bidi.send_cmd('network.addIntercept',
|
46
|
+
phases: phases,
|
47
|
+
contexts: contexts,
|
48
|
+
urlPatterns: url_patterns)
|
44
49
|
end
|
45
50
|
|
46
51
|
def remove_intercept(intercept)
|
@@ -50,31 +55,83 @@ module Selenium
|
|
50
55
|
def continue_with_auth(request_id, username, password)
|
51
56
|
@bidi.send_cmd(
|
52
57
|
'network.continueWithAuth',
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
request: request_id,
|
59
|
+
action: 'provideCredentials',
|
60
|
+
credentials: {
|
61
|
+
type: 'password',
|
62
|
+
username: username,
|
63
|
+
password: password
|
59
64
|
}
|
60
65
|
)
|
61
66
|
end
|
62
67
|
|
63
|
-
def
|
68
|
+
def continue_without_auth(request_id)
|
64
69
|
@bidi.send_cmd(
|
65
|
-
'network.
|
66
|
-
request:
|
67
|
-
'
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
'network.continueWithAuth',
|
71
|
+
request: request_id,
|
72
|
+
action: 'default'
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def cancel_auth(request_id)
|
77
|
+
@bidi.send_cmd(
|
78
|
+
'network.continueWithAuth',
|
79
|
+
request: request_id,
|
80
|
+
action: 'cancel'
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def continue_request(**args)
|
85
|
+
@bidi.send_cmd(
|
86
|
+
'network.continueRequest',
|
87
|
+
request: args[:id],
|
88
|
+
body: args[:body],
|
89
|
+
cookies: args[:cookies],
|
90
|
+
headers: args[:headers],
|
91
|
+
method: args[:method],
|
92
|
+
url: args[:url]
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
def fail_request(request_id)
|
97
|
+
@bidi.send_cmd(
|
98
|
+
'network.failRequest',
|
99
|
+
request: request_id
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def continue_response(**args)
|
104
|
+
@bidi.send_cmd(
|
105
|
+
'network.continueResponse',
|
106
|
+
request: args[:id],
|
107
|
+
cookies: args[:cookies],
|
108
|
+
credentials: args[:credentials],
|
109
|
+
headers: args[:headers],
|
110
|
+
reasonPhrase: args[:reason],
|
111
|
+
statusCode: args[:status]
|
72
112
|
)
|
73
113
|
end
|
74
114
|
|
115
|
+
def provide_response(**args)
|
116
|
+
@bidi.send_cmd(
|
117
|
+
'network.provideResponse',
|
118
|
+
request: args[:id],
|
119
|
+
body: args[:body],
|
120
|
+
cookies: args[:cookies],
|
121
|
+
headers: args[:headers],
|
122
|
+
reasonPhrase: args[:reason],
|
123
|
+
statusCode: args[:status]
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_cache_behavior(behavior, *contexts)
|
128
|
+
@bidi.send_cmd('network.setCacheBehavior', cacheBehavior: behavior, contexts: contexts)
|
129
|
+
end
|
130
|
+
|
75
131
|
def on(event, &)
|
76
132
|
event = EVENTS[event] if event.is_a?(Symbol)
|
77
133
|
@bidi.add_callback(event, &)
|
134
|
+
@bidi.session.subscribe(event)
|
78
135
|
end
|
79
136
|
end # Network
|
80
137
|
end # BiDi
|
@@ -26,6 +26,10 @@ module Selenium
|
|
26
26
|
autoload :BrowsingContext, 'selenium/webdriver/bidi/browsing_context'
|
27
27
|
autoload :Struct, 'selenium/webdriver/bidi/struct'
|
28
28
|
autoload :Network, 'selenium/webdriver/bidi/network'
|
29
|
+
autoload :InterceptedRequest, 'selenium/webdriver/bidi/network/intercepted_request'
|
30
|
+
autoload :InterceptedResponse, 'selenium/webdriver/bidi/network/intercepted_response'
|
31
|
+
autoload :InterceptedAuth, 'selenium/webdriver/bidi/network/intercepted_auth'
|
32
|
+
autoload :InterceptedItem, 'selenium/webdriver/bidi/network/intercepted_item'
|
29
33
|
|
30
34
|
def initialize(url:)
|
31
35
|
@ws = WebSocketConnection.new(url: url)
|
@@ -17,47 +17,85 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
+
require 'forwardable'
|
21
|
+
|
20
22
|
module Selenium
|
21
23
|
module WebDriver
|
22
24
|
class Network
|
23
|
-
|
25
|
+
extend Forwardable
|
26
|
+
|
27
|
+
attr_reader :callbacks, :network
|
28
|
+
alias bidi network
|
29
|
+
|
30
|
+
def_delegators :network, :continue_with_auth, :continue_with_request, :continue_with_response
|
24
31
|
|
25
32
|
def initialize(bridge)
|
26
33
|
@network = BiDi::Network.new(bridge.bidi)
|
27
34
|
@callbacks = {}
|
28
35
|
end
|
29
36
|
|
30
|
-
def
|
31
|
-
intercept =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
def remove_handler(id)
|
38
|
+
intercept = callbacks[id]
|
39
|
+
network.remove_intercept(intercept['intercept'])
|
40
|
+
callbacks.delete(id)
|
41
|
+
end
|
42
|
+
|
43
|
+
def clear_handlers
|
44
|
+
callbacks.each_key { |id| remove_handler(id) }
|
45
|
+
end
|
37
46
|
|
38
|
-
|
47
|
+
def add_authentication_handler(username = nil, password = nil, *filter, pattern_type: nil, &block)
|
48
|
+
selected_block =
|
49
|
+
if username && password
|
50
|
+
proc { |auth| auth.authenticate(username, password) }
|
51
|
+
else
|
52
|
+
block
|
53
|
+
end
|
54
|
+
|
55
|
+
add_handler(
|
56
|
+
:auth_required,
|
57
|
+
BiDi::Network::PHASES[:auth_required],
|
58
|
+
BiDi::InterceptedAuth,
|
59
|
+
filter,
|
60
|
+
pattern_type: pattern_type,
|
61
|
+
&selected_block
|
62
|
+
)
|
39
63
|
end
|
40
64
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
65
|
+
def add_request_handler(*filter, pattern_type: nil, &)
|
66
|
+
add_handler(
|
67
|
+
:before_request,
|
68
|
+
BiDi::Network::PHASES[:before_request],
|
69
|
+
BiDi::InterceptedRequest,
|
70
|
+
filter,
|
71
|
+
pattern_type: pattern_type,
|
72
|
+
&
|
73
|
+
)
|
45
74
|
end
|
46
75
|
|
47
|
-
def
|
48
|
-
|
76
|
+
def add_response_handler(*filter, pattern_type: nil, &)
|
77
|
+
add_handler(
|
78
|
+
:response_started,
|
79
|
+
BiDi::Network::PHASES[:response_started],
|
80
|
+
BiDi::InterceptedResponse,
|
81
|
+
filter,
|
82
|
+
pattern_type: pattern_type,
|
83
|
+
&
|
84
|
+
)
|
49
85
|
end
|
50
86
|
|
51
|
-
|
52
|
-
intercept = @network.add_intercept(phases: [BiDi::Network::PHASES[:before_request]])
|
53
|
-
request_id = @network.on(:before_request) do |event|
|
54
|
-
request_id = event['requestId']
|
55
|
-
@network.continue_with_request(request_id: request_id)
|
56
|
-
end
|
87
|
+
private
|
57
88
|
|
58
|
-
|
89
|
+
def add_handler(event_type, phase, intercept_type, filter, pattern_type: nil)
|
90
|
+
intercept = network.add_intercept(phases: [phase], url_patterns: [filter].flatten, pattern_type: pattern_type)
|
91
|
+
callback_id = network.on(event_type) do |event|
|
92
|
+
request = event['request']
|
93
|
+
intercepted_item = intercept_type.new(network, request)
|
94
|
+
yield(intercepted_item)
|
95
|
+
end
|
59
96
|
|
60
|
-
|
97
|
+
callbacks[callback_id] = intercept
|
98
|
+
callback_id
|
61
99
|
end
|
62
100
|
end # Network
|
63
101
|
end # WebDriver
|
@@ -30,7 +30,6 @@ module Selenium
|
|
30
30
|
DriverExtensions::FullPageScreenshot,
|
31
31
|
DriverExtensions::HasContext,
|
32
32
|
DriverExtensions::HasBiDi,
|
33
|
-
DriverExtensions::HasDevTools,
|
34
33
|
DriverExtensions::HasLogEvents,
|
35
34
|
DriverExtensions::HasNetworkInterception,
|
36
35
|
DriverExtensions::HasWebStorage,
|
@@ -46,23 +45,6 @@ module Selenium
|
|
46
45
|
def browser
|
47
46
|
:firefox
|
48
47
|
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def devtools_url
|
53
|
-
if capabilities['moz:debuggerAddress'].nil?
|
54
|
-
raise(Error::WebDriverError, 'DevTools is not supported by this version of Firefox; use v85 or higher')
|
55
|
-
end
|
56
|
-
|
57
|
-
uri = URI("http://#{capabilities['moz:debuggerAddress']}")
|
58
|
-
response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
|
59
|
-
|
60
|
-
JSON.parse(response)['webSocketDebuggerUrl']
|
61
|
-
end
|
62
|
-
|
63
|
-
def devtools_version
|
64
|
-
Firefox::DEVTOOLS_VERSION
|
65
|
-
end
|
66
48
|
end # Driver
|
67
49
|
end # Firefox
|
68
50
|
end # WebDriver
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-
|
13
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: base64
|
@@ -298,6 +298,14 @@ files:
|
|
298
298
|
- lib/selenium/webdriver/bidi/log_handler.rb
|
299
299
|
- lib/selenium/webdriver/bidi/log_inspector.rb
|
300
300
|
- lib/selenium/webdriver/bidi/network.rb
|
301
|
+
- lib/selenium/webdriver/bidi/network/cookies.rb
|
302
|
+
- lib/selenium/webdriver/bidi/network/credentials.rb
|
303
|
+
- lib/selenium/webdriver/bidi/network/headers.rb
|
304
|
+
- lib/selenium/webdriver/bidi/network/intercepted_auth.rb
|
305
|
+
- lib/selenium/webdriver/bidi/network/intercepted_item.rb
|
306
|
+
- lib/selenium/webdriver/bidi/network/intercepted_request.rb
|
307
|
+
- lib/selenium/webdriver/bidi/network/intercepted_response.rb
|
308
|
+
- lib/selenium/webdriver/bidi/network/url_pattern.rb
|
301
309
|
- lib/selenium/webdriver/bidi/session.rb
|
302
310
|
- lib/selenium/webdriver/bidi/struct.rb
|
303
311
|
- lib/selenium/webdriver/chrome.rb
|