Skip to content

Commit 1b90672

Browse files
committed
Version 2.0
1 parent 585fbaa commit 1b90672

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+674
-4002
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ _Pvt_Extensions
237237

238238
# Rider
239239
.idea
240+
.DotSettings
240241

241242
# SonarQube
242243
.sonarqube

README.md

Lines changed: 90 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
[![license](https://img.shields.io/github/license/rosolko/WebDriverManager.Net.svg?maxAge=3600)](https://github.com/rosolko/WebDriverManager.Net/blob/master/LICENSE)
55

66
# WebDriverManager.Net
7-
Automatic Selenium WebDriver binaries management for .Net
7+
This small library aimed to automate the [Selenium WebDriver] binaries management inside a .Net project.
88

9-
Original application idea is going from - [Boni García].
10-
Java implementation you can find here - [GitHub Repository].
11-
12-
This piece of software is a small library aimed to automate the [Selenium WebDriver] binaries management inside a .Net project.
13-
14-
If you have ever used [Selenium WebDriver], you probably know that in order to use some browsers (for example **Chrome**, **Internet Explorer**, **Opera**, **Microsoft Edge**, **PhantomJS**, **Marionette** or **Appium**) you need to download a binary which allows WebDriver to handle the browser.
9+
If you have ever used [Selenium WebDriver], you probably know that in order to use some browsers (for example **Chrome**) you need to download a binary which allows WebDriver to handle the browser.
1510
In addition, the absolute path to this binary must be set as part of the PATH environment variable or manually copied to build output folder (working directory).
1611

1712
This is quite annoying since it forces you to link directly this binary in your source code. In addition, you have to check manually when new versions of the binaries are released. This library comes to the rescue, performing in an automated way all this dirty job for you.
@@ -29,88 +24,113 @@ Use the GUI or the following command in the Package Manager Console:
2924

3025
Then you can let WebDriverManager.Net to do manage WebDriver binaries for your application/test. Take a look to this NUnit example which uses Chrome with Selenium WebDriver:
3126

32-
namespace BrowserTests
33-
{
34-
using OpenQA.Selenium;
35-
using OpenQA.Selenium.Chrome;
36-
using WebDriverManager.BrowserManagers;
37-
38-
[TestFixture]
39-
public class ChromeTest
40-
{
41-
protected IWebDriver driver;
42-
43-
[TestFixtureSetUp]
44-
public void FixtureSetUp()
45-
{
46-
new ChromeDriverManager().Init();
47-
}
48-
49-
[SetUp]
50-
public void TestSetUp()
51-
{
52-
driver = new ChromeDriver();
53-
}
54-
55-
[TestFixtureTearDown]
56-
public void teardown()
57-
{
58-
if (driver != null)
59-
driver.Quit();
60-
}
61-
62-
[Test]
63-
public void Test()
64-
{
65-
// Using Selenium WebDriver to carry out automated web testing
66-
}
67-
}
68-
}
69-
70-
Notice that simple adding ``new ChromeDriverManager().Init();`` WebDriverManager does magic for you:
27+
using NUnit.Framework;
28+
using OpenQA.Selenium;
29+
using OpenQA.Selenium.Chrome;
30+
using WebDriverManager;
31+
using WebDriverManager.DriverConfigs.Impl;
32+
33+
namespace Test
34+
{
35+
[TestFixture]
36+
public class Tests
37+
{
38+
private IWebDriver _webDriver;
39+
40+
[SetUp]
41+
public void SetUp()
42+
{
43+
new DriverManager().SetUpDriver(new ChromeConfig());
44+
_webDriver = new ChromeDriver();
45+
}
46+
47+
[TearDown]
48+
public void TearDown()
49+
{
50+
_webDriver.Quit();
51+
}
52+
53+
[Test]
54+
public void Test()
55+
{
56+
_webDriver.Navigate().GoToUrl("https://www.google.com");
57+
Assert.True(_webDriver.Title.Contains("Google"));
58+
}
59+
}
60+
}
61+
62+
Notice that simple adding ``new DriverManager().SetUpDriver(<config>)`` does magic for you:
7163

7264
1. It checks the latest version of the WebDriver binary file
7365
2. It downloads the binary WebDriver if it is not present in your system
7466

75-
So far, WebDriverManager supports **Chrome**, **Microsoft Edge**, **Internet Explorer**, **Marionette**, **Opera** or **PhantomJS** as follows:
67+
So far, WebDriverManager supports **Appium**, **Chrome**, **Microsoft Edge**, **Firefox(Marionette)**, **Internet Explorer**, **Opera** or **PhantomJS** configs (Just change <config> to prefered config):
7668

77-
new ChromeDriverManager().Init();
78-
new EdgeDriverManager().Init();
79-
new InternetExplorerDriverManager().Init();
80-
new MarionetteDriverManager().Init();
81-
new OperaDriverManager().Init();
82-
new PhantomJsDriverManager().Init();
83-
new AppiumDriverManager().Init();
69+
new AppiumConfig();
70+
new ChromeConfig();
71+
new EdgeConfig();
72+
new FirefoxConfig();
73+
new IEConfig();
74+
new OperaConfig();
75+
new PhantomConfig();
8476

8577
## Advanced
8678

87-
Configuration parameters for WebDriverManager are set in the class **constructor** parameter or **init** method parameter.
79+
You can use WebDriverManager in two ways:
80+
1. Automatic
81+
2. Manual
8882

89-
1. Target version can be specified in class constructor using parameter:
83+
#### Automatic way:
84+
new DriverManager().SetUpDriver(new <Driver>Config());
9085

91-
``new ChromeDriverManager("2.21").Init();``
86+
You can also specify version:
87+
``new DriverManager().SetUpDriver(new ChromeConfig(), "2.25")``
9288

93-
In this case manager try to download ChromeDriver binary with **2.11** version.
89+
Or architecture:
90+
``new DriverManager().SetUpDriver(new ChromeConfig(), "Latest", Architecture.X32)``
9491

95-
2. Also you can specify target binary architecture, for this case you need to include reference and specify architecture in class constructor using paramet
96-
97-
``using WebDriverManager.Helpers;``
92+
Or version and architecture:
93+
``new DriverManager().SetUpDriver(new ChromeConfig(), "2.25", Architecture.X64)``
9894

99-
``...``
95+
#### Manual way:
96+
new DriverManager().SetUpDriver(
97+
"https://chromedriver.storage.googleapis.com/2.25/chromedriver_win32.zip",
98+
Directory.GetCurrentDirectory(),
99+
"chromedriver.exe"
100+
);
100101

101-
`` new InternetExplorerDriverManager(Architecture.x32).Init();``
102+
### If you want use your own implementation you need to create driver config and use it for set up:
103+
public class CustomDriverConfig : IDriverConfig
104+
{
105+
public string GetName()
106+
{
107+
return "CustomDriverName";
108+
}
102109

103-
In this case manager try to download ChromeDriver binary with **x32** architecture.
110+
public string GetUrl32()
111+
{
112+
return "https://someurl/<version>/win32.zip";
113+
}
114+
115+
public string GetUrl64()
116+
{
117+
return "https://someurl/<version>/win64.zip";
118+
}
104119

105-
3. Target driver binary destination folder can be specified in class constructor using parameter:
106-
107-
``new ChromeDriverManager().Init(@"C:\Binaries");``
120+
public string GetBinaryName()
121+
{
122+
return "binary.name.exe";
123+
}
108124

109-
In this case manager try to download latest version of ChromeDriver and put binary to **C:\Binaries** folder.
125+
public string GetLatestVersion()
126+
{
127+
<some code that get and return latest version>
128+
}
129+
}
110130

111-
NOTE 1: You can mix parameters as you want but *NOTE 2*.
131+
...
112132

113-
NOTE 2: Some driver manager doesn't support vesion or architecture managements.
133+
new DriverManager().SetUpDriver(new CustomDriverConfig());
114134

115135
## About
116136

@@ -119,7 +139,5 @@ Comments, questions and suggestions are always very welcome!
119139

120140
[Alexander Rosolko]: https://github.com/rosolko
121141
[WebDriverManager.Net]: https://www.nuget.org/packages/WebDriverManager
122-
[Boni García]: http://bonigarcia.github.io
123-
[GitHub Repository]: https://github.com/bonigarcia/webdrivermanager
124142
[Selenium Webdriver]: http://docs.seleniumhq.org/projects/webdriver
125143
[MIT]: https://github.com/rosolko/WebDriverManager.Net/blob/master/LICENSE

WebDriverManager.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.25123.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDriverManager", "WebDriverManager\WebDriverManager.csproj", "{0066742E-391B-407C-9DC1-FF71A60BEC53}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDriverManager", "WebDriverManager\WebDriverManager.csproj", "{DDF73921-D0CD-4B7F-BAFB-021CEAC5FF73}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{0066742E-391B-407C-9DC1-FF71A60BEC53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{0066742E-391B-407C-9DC1-FF71A60BEC53}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{0066742E-391B-407C-9DC1-FF71A60BEC53}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{0066742E-391B-407C-9DC1-FF71A60BEC53}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{DDF73921-D0CD-4B7F-BAFB-021CEAC5FF73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DDF73921-D0CD-4B7F-BAFB-021CEAC5FF73}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DDF73921-D0CD-4B7F-BAFB-021CEAC5FF73}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DDF73921-D0CD-4B7F-BAFB-021CEAC5FF73}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE

WebDriverManager/BrowserManagers/AppiumDriverManager.cs

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)