-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from maik-hasler/develop
Added IWebDriverManager<T> & extension method to fire DOM events
- Loading branch information
Showing
19 changed files
with
339 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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,22 @@ | ||
root = True | ||
|
||
# Default settings | ||
[*] | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Xml project files | ||
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] | ||
indent_size = 2 | ||
|
||
# Xml files | ||
[*.{xml,stylecop,resx,ruleset}] | ||
indent_size = 2 | ||
|
||
# Xml config files | ||
[*.{props,targets,config,nuspec}] | ||
indent_size = 2 | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains 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,40 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased](https://github.com/maik-hasler/SeleniumSharper/compare/v1.1.0...HEAD) | ||
|
||
## [v1.1.0](https://github.com/maik-hasler/SeleniumSharper/releases/tag/v1.1.0) | ||
**Published:** 21th April 2023 | ||
### Added | ||
- `IWebDriverManager<TOptions>` and first implementation for Chrome to automatically install driver binaries | ||
- Helper classes related to `IWebDriverManager<TOptions>` | ||
- Enum and extension method to fire JavaScript event | ||
### Changed | ||
- Upgrade dependencies: Selenium.WebDriver, Selenium.Support etc. | ||
### Removed | ||
- Custom result classes | ||
|
||
## [v1.0.0](https://github.com/maik-hasler/SeleniumSharper/releases/tag/v1.0.0) | ||
**Published:** 19th April 2023 | ||
### Added | ||
- `WebElementsConditionBuilder<TSearchContext, TSearchResult>` to build wait conditions for a `ReadOnlyCollection<IWebElement>` | ||
- `WebElementConditionBuilder<TSearchContext, TSearchResult>` to build wait conditions for a `IWebElement` | ||
- `ClassConditionBuilder<TSearchContext, TSearchResult>` to build wait conditions for a `IEquatable<string>` | ||
- Custom result classes `WebElementsVisibilityResult` and `WebElementVisibilityResult` | ||
### Changed | ||
- Changed `Waiter<T>` to `ContextualWait<TSearchContext>`, which supports more generic method chaining | ||
### Removed | ||
- Collection of commonly used selenium wait conditions | ||
|
||
## [v1.0.0-preview.0](https://github.com/maik-hasler/SeleniumSharper/releases/tag/v1.0.0-preview.0) | ||
**Published:** 18th April 2023 | ||
<br /> | ||
**Disclaimer:** This is a pre-release. It was published in order to verify, that the nuget.yml workflow works fine. | ||
### Added | ||
- `Waiter<T>` to wait for a specified condition to be satisfied | ||
- Collection of commonly used selenium wait conditions | ||
- Extension method to create a `Waiter<T>` object from an `ISearchContext` | ||
- Various `IJavaScriptExecutor` extension methods |
6 changes: 3 additions & 3 deletions
6
src/ClassConditionBuilder.cs → src/Conditions/StringConditionBuilder.cs
This file contains 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 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 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 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 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 SeleniumSharper; | ||
|
||
public enum DomEvent | ||
{ | ||
Click, | ||
DoubleClick, | ||
MouseDown, | ||
MouseUp, | ||
KeyDown, | ||
KeyUp | ||
} |
This file contains 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 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,101 @@ | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
using SeleniumSharper.Managers.Interfaces; | ||
using SeleniumSharper.Managers.Services; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SeleniumSharper.Managers; | ||
|
||
public sealed class ChromeDriverManager : IWebDriverManager<ChromeOptions> | ||
{ | ||
public IWebDriver Setup() | ||
{ | ||
var driverPath = InstallBinary(); | ||
|
||
var chromeDriverService = ChromeDriverService.CreateDefaultService(driverPath); | ||
|
||
return new ChromeDriver(chromeDriverService); | ||
} | ||
|
||
public IWebDriver Setup(ChromeOptions chromeOptions) | ||
{ | ||
var driverPath = InstallBinary(); | ||
|
||
var chromeDriverService = ChromeDriverService.CreateDefaultService(driverPath); | ||
|
||
return new ChromeDriver(chromeDriverService, chromeOptions); | ||
} | ||
|
||
private static string GetBinaryName() | ||
{ | ||
var suffix = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : string.Empty; | ||
|
||
return $"chromedriver{suffix}"; | ||
} | ||
|
||
private static Uri GetDownloadUrl(string version, string fileName) | ||
{ | ||
var url = $"https://chromedriver.storage.googleapis.com/{version}/{fileName}"; | ||
|
||
return new Uri(url); | ||
} | ||
|
||
private static string GetFileName() | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
{ | ||
var architectureExtension = RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? "_arm64" : "64"; | ||
|
||
return $"chromedriver_mac{architectureExtension}.zip"; | ||
} | ||
|
||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
return "chromedriver_linux64.zip"; | ||
} | ||
|
||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
return "chromedriver_win32.zip"; | ||
} | ||
|
||
throw new PlatformNotSupportedException(); | ||
} | ||
|
||
private static string GetLatestVersion() | ||
{ | ||
var url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"; | ||
|
||
using var httpClient = new HttpClient(); | ||
|
||
var response = httpClient.GetStringAsync(url).Result; | ||
|
||
return response.Trim(); | ||
} | ||
|
||
private static string GetBinaryPath(string version) | ||
{ | ||
var architecture = Environment.Is64BitOperatingSystem ? "64" : "32"; | ||
|
||
return Path.Combine( | ||
Directory.GetCurrentDirectory(), | ||
"Binaries", | ||
"Chrome", | ||
version, | ||
architecture, | ||
GetBinaryName()); | ||
} | ||
|
||
private static string InstallBinary() | ||
{ | ||
var version = GetLatestVersion(); | ||
|
||
var fileName = GetFileName(); | ||
|
||
var downloadUrl = GetDownloadUrl(version, fileName); | ||
|
||
var binaryPath = GetBinaryPath(version); | ||
|
||
return WebDriverManagerUtils.InstallBinary(fileName, downloadUrl, binaryPath, GetBinaryName()); | ||
} | ||
} |
This file contains 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 @@ | ||
using OpenQA.Selenium; | ||
|
||
namespace SeleniumSharper.Managers.Interfaces; | ||
|
||
public interface IWebDriverManager<TOptions> | ||
where TOptions : DriverOptions | ||
{ | ||
public IWebDriver Setup(); | ||
|
||
public IWebDriver Setup(TOptions options); | ||
} |
Oops, something went wrong.