-
Notifications
You must be signed in to change notification settings - Fork 83
Added support for chrome for testing apis #254
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
rosolko
merged 5 commits into
rosolko:master
from
iouym:feature/chrome-for-testing-integration
Jul 30, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e542035
Added support for the chrome for testing apis
iouym 5b1031e
Factor out storage URL resolution into own method
iouym c3b6208
Fixup additional return
iouym e165b33
Updated to use raw browser version
iouym f3e102f
Fix deadlocks, make client static
iouym 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using System; | ||
| using System.Net.Http; | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
| using WebDriverManager.Models.Chrome; | ||
|
|
||
| namespace WebDriverManager.Clients | ||
| { | ||
| public static class ChromeForTestingClient | ||
| { | ||
| private static readonly string BaseUrl = "https://googlechromelabs.github.io/chrome-for-testing/"; | ||
| private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions | ||
| { | ||
| PropertyNameCaseInsensitive = true | ||
| }; | ||
|
|
||
| private static readonly HttpClient _httpClient; | ||
|
|
||
| static ChromeForTestingClient() | ||
| { | ||
| _httpClient = new HttpClient | ||
| { | ||
| BaseAddress = new Uri(BaseUrl) | ||
| }; | ||
| } | ||
|
|
||
| public static ChromeVersions GetKnownGoodVersionsWithDownloads() | ||
| { | ||
| return GetResultFromHttpTask<ChromeVersions>( | ||
| _httpClient.GetAsync("known-good-versions-with-downloads.json") | ||
| ); | ||
| } | ||
|
|
||
| public static ChromeVersions GetLastKnownGoodVersions() | ||
| { | ||
| return GetResultFromHttpTask<ChromeVersions>( | ||
| _httpClient.GetAsync("last-known-good-versions-with-downloads.json") | ||
| ); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Get a HTTP result without causing any deadlocks | ||
| /// <para>See: https://learn.microsoft.com/en-us/archive/blogs/jpsanders/asp-net-do-not-use-task-result-in-main-context</para> | ||
| /// </summary> | ||
| /// <typeparam name="TResult">The type of result to convert the HTTP response to</typeparam> | ||
| /// <param name="taskToRun">The <see cref="HttpResponseMessage"/> task to run</param> | ||
| private static TResult GetResultFromHttpTask<TResult>(Task<HttpResponseMessage> taskToRun) | ||
| where TResult : class | ||
| { | ||
| var httpTask = Task.Run(() => taskToRun); | ||
| httpTask.Wait(); | ||
|
|
||
| var readStringTask = Task.Run(() => httpTask.Result.Content.ReadAsStringAsync()); | ||
| readStringTask.Wait(); | ||
|
|
||
| return JsonSerializer.Deserialize<TResult>(readStringTask.Result, JsonSerializerOptions); | ||
| } | ||
| } | ||
| } |
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,9 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromeDownload | ||
| { | ||
| public IEnumerable<ChromePlatformInfo> ChromeDriver { get; set; } | ||
| } | ||
| } |
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,9 @@ | ||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromePlatformInfo | ||
| { | ||
| public string Platform { get; set; } | ||
|
|
||
| public string Url { get; set; } | ||
| } | ||
| } |
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,13 @@ | ||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromeReleaseChannels | ||
| { | ||
| public ChromeReleaseTrack Stable { get; set; } | ||
|
|
||
| public ChromeReleaseTrack Beta { get; set; } | ||
|
|
||
| public ChromeReleaseTrack Dev { get; set; } | ||
|
|
||
| public ChromeReleaseTrack Canary { get; set; } | ||
| } | ||
| } |
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,13 @@ | ||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromeReleaseTrack | ||
| { | ||
| public string Channel { get; set; } | ||
|
|
||
| public string Version { get; set; } | ||
|
|
||
| public string Revision { get; set; } | ||
|
|
||
| public ChromeDownload Downloads { get; set; } | ||
| } | ||
| } |
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,11 @@ | ||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromeVersionInfo | ||
| { | ||
| public string Version { get; set; } | ||
|
|
||
| public string Revision { get; set; } | ||
|
|
||
| public ChromeDownload Downloads { get; set; } | ||
| } | ||
| } |
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,13 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace WebDriverManager.Models.Chrome | ||
| { | ||
| public class ChromeVersions | ||
| { | ||
| public string Timestamp { get; set; } | ||
|
|
||
| public ChromeReleaseChannels Channels { get; set; } | ||
|
|
||
| public IEnumerable<ChromeVersionInfo> Versions { get; set; } | ||
| } | ||
| } |
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.