-
Notifications
You must be signed in to change notification settings - Fork 9
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 #16 from riganti/browser-manager
Browser manager support
- Loading branch information
Showing
19 changed files
with
162 additions
and
104 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
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
10 changes: 6 additions & 4 deletions
10
src/Core/Riganti.Selenium.Core/Drivers/Implementation/ChromeHelpers.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
using OpenQA.Selenium.Chrome; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
using Riganti.Selenium.Core.Factories; | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Riganti.Selenium.Core.Drivers.Implementation | ||
{ | ||
public static class ChromeHelpers | ||
{ | ||
|
||
public static ChromeDriver CreateChromeDriver(LocalWebBrowserFactory factory) | ||
{ | ||
|
||
var options = new ChromeOptions(); | ||
options.AddArgument("test-type"); | ||
options.AddArgument("disable-popup-blocking"); | ||
|
||
options.AddArguments(factory.Capabilities); | ||
options.BrowserVersion = factory.Options.TryGet(nameof(options.BrowserVersion)); | ||
|
||
if (factory.GetBooleanOption("disableExtensions")) | ||
{ | ||
options.AddArgument("--disable-extensions"); | ||
} | ||
return new ChromeDriver(options); | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -13,6 +13,5 @@ public CoordinatorWebBrowserBase(CoordinatorWebBrowserFactoryBase factory, Conta | |
{ | ||
Lease = lease; | ||
} | ||
|
||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Core/Riganti.Selenium.Core/Drivers/Implementation/DictionaryExtensions.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Riganti.Selenium.Core.Drivers.Implementation | ||
{ | ||
public static class DictionaryExtensions | ||
{ | ||
|
||
public static T2 TryGet<T1, T2>(this IDictionary<T1, T2> dic, T1 key) | ||
{ | ||
if (dic is not null && dic.TryGetValue(key, out T2 value) && value is T2) | ||
{ | ||
return value; | ||
} | ||
return default; | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/Riganti.Selenium.DotVVM3Samples/Riganti.Selenium.DotVVM3.Samples.csproj
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
5 changes: 4 additions & 1 deletion
5
src/Tests/Riganti.Selenium.Core.Samples.Assert.Tests/seleniumconfig.json
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
5 changes: 4 additions & 1 deletion
5
src/Tests/Riganti.Selenium.Core.Samples.Tests/Profiles/seleniumconfig.chrome.json
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
36 changes: 36 additions & 0 deletions
36
src/Tests/Riganti.Selenium.Core.Samples.Tests/SeleniumManagerTests.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Newtonsoft.Json; | ||
using OpenQA.Selenium; | ||
|
||
[TestClass] | ||
public class SeleniumManagerTests | ||
{ | ||
[TestMethod] | ||
public void GetBinariesVersion113() | ||
{ | ||
var data1 = SeleniumManager.BinaryPaths("--browser firefox --driver geckodriver --browser-version 113"); | ||
Console.WriteLine("Firefox binaries: " + JsonConvert.SerializeObject(data1)); | ||
Assert.IsNotNull(data1["browser_path"]); | ||
Assert.IsNotNull(data1["driver_path"]); | ||
|
||
var data2 = SeleniumManager.BinaryPaths("--browser chrome --driver chromedriver --browser-version 113"); | ||
Console.WriteLine("Chrome binaries: " + JsonConvert.SerializeObject(data2)); | ||
Assert.IsNotNull(data2["browser_path"]); | ||
Assert.IsNotNull(data2["driver_path"]); | ||
} | ||
|
||
[TestMethod] | ||
public void GetBinariesVersionStable() | ||
{ | ||
var data1 = SeleniumManager.BinaryPaths("--browser firefox --driver geckodriver --browser-version stable"); | ||
Console.WriteLine("Firefox binaries: " + JsonConvert.SerializeObject(data1)); | ||
Assert.IsNotNull(data1["browser_path"]); | ||
Assert.IsNotNull(data1["driver_path"]); | ||
|
||
var data2 = SeleniumManager.BinaryPaths("--browser chrome --driver chromedriver --browser-version stable"); | ||
Console.WriteLine("Chrome binaries: " + JsonConvert.SerializeObject(data2)); | ||
Assert.IsNotNull(data2["browser_path"]); | ||
Assert.IsNotNull(data2["driver_path"]); | ||
} | ||
} |
12 changes: 10 additions & 2 deletions
12
src/Tests/Riganti.Selenium.Core.Samples.Tests/seleniumconfig.json
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
Oops, something went wrong.