-
Notifications
You must be signed in to change notification settings - Fork 8
Implement protocol detection and protocol-agnostic session creation. #187
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
tristanlabelle
merged 6 commits into
thebrowsercompany:main
from
tristanlabelle:protocol-detection
May 2, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7fa3ea7
Implement protocol detection and protocol-agnostic session creation.
tristanlabelle f6c1822
Missing returns
tristanlabelle 32a4f13
Use LegacySelenium + W3C enum-namespaces.
tristanlabelle 7931a0c
Update CMakeLists
tristanlabelle 1278b8d
Fix LegacySelenium that should be W3C
tristanlabelle 036739b
legacy -> legacySelenium
tristanlabelle 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,37 @@ | ||
| extension Requests { | ||
| /// Defines requests and response types specific to the legacy selenium json wire protocol. | ||
| public enum LegacySelenium { | ||
| // https://www.selenium.dev/documentation/legacy/json_wire_protocol/#session | ||
| public struct Session<Caps: Capabilities>: Request { | ||
| public var desiredCapabilities: Caps | ||
| public var requiredCapabilities: Caps? | ||
|
|
||
| public init(desiredCapabilities: Caps, requiredCapabilities: Caps? = nil) { | ||
| self.requiredCapabilities = requiredCapabilities | ||
| self.desiredCapabilities = desiredCapabilities | ||
| } | ||
|
|
||
| public var pathComponents: [String] { ["session"] } | ||
| public var method: HTTPMethod { .post } | ||
| public var body: Body { .init(desiredCapabilities: desiredCapabilities, requiredCapabilities: requiredCapabilities) } | ||
|
|
||
| public struct Body: Codable { | ||
| public var desiredCapabilities: Caps | ||
| public var requiredCapabilities: Caps? | ||
| } | ||
|
|
||
| public struct Response: Codable { | ||
| public var sessionId: String | ||
| public var value: Caps | ||
| } | ||
| } | ||
|
|
||
| // https://www.selenium.dev/documentation/legacy/json_wire_protocol/#status | ||
| public struct Status: Request { | ||
| public var pathComponents: [String] { ["status"] } | ||
| public var method: HTTPMethod { .get } | ||
|
|
||
| public typealias Response = WebDriverStatus | ||
| } | ||
| } | ||
| } |
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,41 @@ | ||
| extension Requests { | ||
| /// Defines requests and response types specific to the W3C WebDriver protocol. | ||
| public enum W3C { | ||
| public struct Session<Caps: Capabilities>: Request { | ||
| public var alwaysMatch: Caps | ||
| public var firstMatch: [Caps] | ||
|
|
||
| public init(alwaysMatch: Caps, firstMatch: [Caps] = []) { | ||
| self.alwaysMatch = alwaysMatch | ||
| self.firstMatch = firstMatch | ||
| } | ||
|
|
||
| public var pathComponents: [String] { ["session"] } | ||
| public var method: HTTPMethod { .post } | ||
| public var body: Body { .init(capabilities: .init(alwaysMatch: alwaysMatch, firstMatch: firstMatch)) } | ||
|
|
||
| public struct Body: Codable { | ||
| public struct Capabilities: Codable { | ||
| public var alwaysMatch: Caps | ||
| public var firstMatch: [Caps]? | ||
| } | ||
|
|
||
| public var capabilities: Capabilities | ||
| } | ||
|
|
||
| public typealias Response = ResponseWithValue<ResponseValue> | ||
|
|
||
| public struct ResponseValue: Codable { | ||
| public var sessionId: String | ||
| public var capabilities: Caps | ||
| } | ||
| } | ||
|
|
||
| public struct Status: Request { | ||
| public var pathComponents: [String] { ["status"] } | ||
| public var method: HTTPMethod { .get } | ||
|
|
||
| public typealias Response = ResponseWithValue<WebDriverStatus> | ||
| } | ||
| } | ||
| } |
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
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
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
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.