Skip to content

Commit 4077df8

Browse files
committed
Remove appium. Fix cache. Update readme.
1 parent 1b90672 commit 4077df8

File tree

5 files changed

+45
-64
lines changed

5 files changed

+45
-64
lines changed

README.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# WebDriverManager.Net
77
This small library aimed to automate the [Selenium WebDriver] binaries management inside a .Net project.
88

9+
*You need run you IDE/program/tests with Administrator privileges*
10+
911
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.
1012
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).
1113

@@ -64,9 +66,8 @@ Notice that simple adding ``new DriverManager().SetUpDriver(<config>)`` does mag
6466
1. It checks the latest version of the WebDriver binary file
6567
2. It downloads the binary WebDriver if it is not present in your system
6668

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

69-
new AppiumConfig();
7071
new ChromeConfig();
7172
new EdgeConfig();
7273
new FirefoxConfig();
@@ -99,38 +100,67 @@ Or version and architecture:
99100
"chromedriver.exe"
100101
);
101102

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
103+
### If you want use your own implementation you need to create driver config and use it for set up(ex get, setup and wotk with phantomjs driver from taobao mirror):
104+
public class TaobaoPhantomConfig : IDriverConfig
104105
{
105106
public string GetName()
106107
{
107-
return "CustomDriverName";
108+
return "TaobaoPhantom";
108109
}
109110

110111
public string GetUrl32()
111112
{
112-
return "https://someurl/<version>/win32.zip";
113+
return "https://npm.taobao.org/mirrors/phantomjs/phantomjs-<version>-windows.zip";
113114
}
114115

115116
public string GetUrl64()
116117
{
117-
return "https://someurl/<version>/win64.zip";
118+
return GetUrl32();
118119
}
119120

120121
public string GetBinaryName()
121122
{
122-
return "binary.name.exe";
123+
return "phantomjs.exe";
123124
}
124125

125126
public string GetLatestVersion()
126127
{
127-
<some code that get and return latest version>
128+
using (var client = new WebClient())
129+
{
130+
var doc = new HtmlDocument();
131+
var htmlCode = client.DownloadString("https://bitbucket.org/ariya/phantomjs/downloads");
132+
doc.LoadHtml(htmlCode);
133+
var itemList =
134+
doc.DocumentNode.SelectNodes("//tr[@class='iterable-item']/td[@class='name']/a")
135+
.Select(p => p.InnerText)
136+
.ToList();
137+
var version = itemList.FirstOrDefault()?.Split('-')[1];
138+
return version;
139+
}
140+
}
141+
}
142+
143+
...
144+
145+
new DriverManager().SetUpDriver(new TaobaoPhantomConfig());
146+
147+
### Or you can modify existed drivers and change only necessary fields(same example):
148+
public class TaobaoPhantomConfig : PhantomConfig
149+
{
150+
public string GetName()
151+
{
152+
return "TaobaoPhantom";
153+
}
154+
155+
public string GetUrl32()
156+
{
157+
return "https://npm.taobao.org/mirrors/phantomjs/phantomjs-<version>-windows.zip";
128158
}
129159
}
130160

131161
...
132162

133-
new DriverManager().SetUpDriver(new CustomDriverConfig());
163+
new DriverManager().SetUpDriver(new TaobaoPhantomConfig());
134164

135165
## About
136166

WebDriverManager/DriverConfigs/Impl/AppiumConfig.cs

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

WebDriverManager/Services/Impl/BinaryService.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ public class BinaryService : IBinaryService
1010
public string SetupBinary(string url, string zipDestination, string binDestination, string binaryName)
1111
{
1212
if (File.Exists(binDestination)) return binDestination;
13-
if (!File.Exists(zipDestination))
14-
{
15-
zipDestination = DownloadZip(url, zipDestination);
16-
}
13+
zipDestination = DownloadZip(url, zipDestination);
1714
FileHelper.CreateDestinationDirectory(binDestination);
1815
binDestination = UnZip(zipDestination, binDestination, binaryName);
1916
RemoveZip(zipDestination);
@@ -22,6 +19,7 @@ public string SetupBinary(string url, string zipDestination, string binDestinati
2219

2320
protected string DownloadZip(string url, string destination)
2421
{
22+
if (File.Exists(destination)) return destination;
2523
using (var webClient = new WebClient())
2624
{
2725
webClient.DownloadFile(url, destination);

WebDriverManager/WebDriverManager.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
</ItemGroup>
5050
<ItemGroup>
5151
<Compile Include="DriverConfigs\IDriverConfig.cs" />
52-
<Compile Include="DriverConfigs\Impl\AppiumConfig.cs" />
5352
<Compile Include="DriverConfigs\Impl\ChromeConfig.cs" />
5453
<Compile Include="DriverConfigs\Impl\EdgeConfig.cs" />
5554
<Compile Include="DriverConfigs\Impl\FirefoxConfig.cs" />
@@ -70,6 +69,9 @@
7069
<ItemGroup>
7170
<Content Include="packages.config" />
7271
</ItemGroup>
72+
<ItemGroup>
73+
<Folder Include="DriverConfigs\Impl" />
74+
</ItemGroup>
7375
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7476
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
7577
Other similar extension points exist, see Microsoft.Common.targets.
File renamed without changes.

0 commit comments

Comments
 (0)