-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[rb] Add Bidi Network Response Handler #14900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 51 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
7ef9d83
Add response handler
aguspe 2f2012a
Update auth handlers and improve the :on method
aguspe 487a6e3
Merge branch 'trunk' into add_response_handler
aguspe 28cf363
Request and response working as expected
aguspe 314b458
Add test for continue without auth and cancel auth
aguspe 305135e
Finish implementation
aguspe ff2ba0d
Correct rubocop offenses
aguspe 0b41266
Add alias for user to do network.bidi instead of network.network
aguspe 25c201b
Fix rust file causing formatting error
aguspe 92ea3ef
Merge branch 'trunk' into add_response_handler
aguspe 7e22239
Handle requests and responses in block
aguspe ad82e86
Merge remote-tracking branch 'origin/add_response_handler' into add_r…
aguspe b2cea1d
Merge branch 'trunk' into add_response_handler
pujagani ae80832
Add ability to pass handlers to each different intercepted element
aguspe b4a4fe7
Merge remote-tracking branch 'origin/add_response_handler' into add_r…
aguspe 13a0912
Merge branch 'trunk' into add_response_handler
aguspe c21f643
Headers working
aguspe f390699
Merge branch 'trunk' into add_response_handler
aguspe 69b5690
All tests passing and signatures simplified
aguspe bb1ece5
remove unnecessary changes
aguspe 996c527
remove unnecessary changes
aguspe f8f3f7f
Merge remote-tracking branch 'origin/add_response_handler' into add_r…
aguspe f2f9e01
Added credentials and set cookie header to intercepted response
aguspe 38d0b9a
Merge branch 'trunk' into add_response_handler
aguspe 71f5fa6
Fix rubocop issues
aguspe 9c23adf
Merge branch 'trunk' into add_response_handler
aguspe d9e0ffc
Make auth handler more user friendly
aguspe 87dc1e6
Add filtering an url pattern support
aguspe 9612939
Merge branch 'trunk' into add_response_handler
aguspe 7c49b93
Fix formatting issues
aguspe b1e14b6
Merge remote-tracking branch 'origin/add_response_handler' into add_r…
aguspe 3772844
Modify tests to avoid element related failures on firefox
aguspe 0515131
Fix styling of comments
aguspe eb3f378
Improve types and hash consistency
aguspe ac43ca2
Merge branch 'trunk' into add_response_handler
aguspe abb697d
Merge branch 'trunk' into add_response_handler
aguspe edc5508
Merge branch 'trunk' into add_response_handler
aguspe 296105e
Update all the places that use 9.4.8.0
aguspe 51e8f84
Merge branch 'trunk' into add_response_handler
aguspe c7552aa
Serialize request values
aguspe ab0f4c2
Refactor cookies, headers and set cookie headers
aguspe fa0c87a
Simplify serialization
aguspe bbd7bcc
Add extra type support
aguspe acce734
Improve typing
aguspe 2197e67
Merge branch 'trunk' into add_response_handler
aguspe 3ac73c1
Merge branch 'trunk' into add_response_handler
aguspe a98eafd
Merge branch 'trunk' into add_response_handler
aguspe 0484ee2
Merge branch 'trunk' into add_response_handler
aguspe 7760eb3
Merge branch 'trunk' into add_response_handler
aguspe 5596a53
Merge branch 'trunk' into add_response_handler
aguspe 71da231
Merge branch 'trunk' into add_response_handler
aguspe 15ef477
transform serialize to as_json
aguspe c35bdc2
Merge remote-tracking branch 'origin/add_response_handler' into add_r…
aguspe 1aa8835
Merge branch 'trunk' into add_response_handler
aguspe 75e89a9
Simplify cookies and add extra unit tests
aguspe e8f35c4
Merge branch 'trunk' into add_response_handler
aguspe ca3a0fe
Merge branch 'trunk' into add_response_handler
aguspe 8e27704
Simplify cookies and add extra unit tests
aguspe 0daec6d
Merge branch 'trunk' into add_response_handler
aguspe 00dd4aa
Merge branch 'trunk' into add_response_handler
aguspe 14853b6
Merge branch 'trunk' into add_response_handler
aguspe 68d28e1
Merge branch 'trunk' into add_response_handler
aguspe fe2bf4a
Merge branch 'trunk' into add_response_handler
aguspe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class Cookies < Hash | ||
def initialize(cookies = {}) | ||
super() | ||
merge!(cookies) | ||
end | ||
|
||
def serialize | ||
map do |name, value| | ||
{ | ||
name: name.to_s, | ||
value: { | ||
type: 'string', | ||
value: value.to_s | ||
} | ||
} | ||
end | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class Credentials | ||
attr_accessor :username, :password | ||
|
||
def initialize(username: nil, password: nil) | ||
@username = username | ||
@password = password | ||
end | ||
|
||
def serialize | ||
return nil unless username && password | ||
|
||
{ | ||
type: 'password', | ||
username: username, | ||
password: password | ||
} | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class Headers < Hash | ||
def serialize | ||
map do |name, val| | ||
{ | ||
name: name.to_s, | ||
value: { | ||
type: 'string', | ||
value: val.to_s | ||
} | ||
} | ||
end | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
38 changes: 38 additions & 0 deletions
38
rb/lib/selenium/webdriver/bidi/network/intercepted_auth.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class InterceptedAuth < InterceptedItem | ||
def authenticate(username, password) | ||
network.continue_with_auth(id, username, password) | ||
end | ||
|
||
def skip | ||
network.continue_without_auth(id) | ||
end | ||
|
||
def cancel | ||
network.cancel_auth(id) | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
37 changes: 37 additions & 0 deletions
37
rb/lib/selenium/webdriver/bidi/network/intercepted_item.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class InterceptedItem | ||
attr_reader :network, :request | ||
|
||
def initialize(network, request) | ||
@network = network | ||
@request = request | ||
end | ||
|
||
def id | ||
@id ||= @request['request'] | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
69 changes: 69 additions & 0 deletions
69
rb/lib/selenium/webdriver/bidi/network/intercepted_request.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
# 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. | ||
|
||
require_relative 'cookies' | ||
require_relative 'headers' | ||
|
||
module Selenium | ||
module WebDriver | ||
class BiDi | ||
class InterceptedRequest < InterceptedItem | ||
attr_accessor :method, :url | ||
attr_reader :body | ||
|
||
def initialize(network, request) | ||
super | ||
@method = nil | ||
@url = nil | ||
@body = nil | ||
end | ||
|
||
def continue | ||
network.continue_request( | ||
id: id, | ||
body: body, | ||
cookies: cookies.serialize, | ||
headers: headers.serialize, | ||
method: method, | ||
url: url | ||
) | ||
end | ||
|
||
def fail | ||
network.fail_request(id) | ||
end | ||
|
||
def body=(value) | ||
@body = { | ||
type: 'string', | ||
value: value.to_json | ||
} | ||
end | ||
|
||
def headers | ||
@headers ||= Headers.new | ||
end | ||
|
||
def cookies(cookies = {}) | ||
@cookies ||= Cookies.new(cookies) | ||
end | ||
end | ||
end # BiDi | ||
end # WebDriver | ||
end # Selenium |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.