Permalink
Browse files

Packaged chromedriver.exe into SeleniumWebDriver

  • Loading branch information...
1 parent 2a3dbce commit 11dbf5351a875d2bb186034b956163d89314de9c @stirno committed Apr 22, 2012
@@ -92,23 +92,10 @@ private Process startPhantomJS(int portNumber)
private static string UnpackResources()
{
- var unpackResource = new Action<string, Assembly>((resourceFileName, assembly) =>
- {
- var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(resourceFileName));
- if (!File.Exists(resourceFileName))
- {
- var resourceStream = assembly.GetManifestResourceStream(resourceName);
- var resourceBytes = new byte[(int)resourceStream.Length];
-
- resourceStream.Read(resourceBytes, 0, resourceBytes.Length);
- File.WriteAllBytes(resourceFileName, resourceBytes);
- }
- });
-
var containerAssembly = Assembly.GetAssembly(typeof(PhantomJS));
- unpackResource("phantomjs.exe", containerAssembly);
- unpackResource("PhantomDriver.coffee", containerAssembly);
+ EmbeddedResources.UnpackFromAssembly("phantomjs.exe", containerAssembly);
+ EmbeddedResources.UnpackFromAssembly("PhantomDriver.coffee", containerAssembly);
return containerAssembly.CodeBase;
}
@@ -74,6 +74,9 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="3rdPartyLib\chromedriver.exe" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FluentAutomation.Interfaces;
@@ -43,6 +44,7 @@ public static void Bootstrap(Browser browser)
container.Register<IWebDriver, OpenQA.Selenium.Firefox.FirefoxDriver>().AsMultiInstance();
break;
case Browser.Chrome:
+ EmbeddedResources.UnpackFromAssembly("chromedriver.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
container.Register<IWebDriver, OpenQA.Selenium.Chrome.ChromeDriver>().AsMultiInstance();
break;
}
@@ -48,13 +48,15 @@
<Otherwise />
</Choose>
<ItemGroup>
+ <Compile Include="Native\SeleniumChrome.cs" />
+ <Compile Include="Native\SeleniumFirefox.cs" />
<Compile Include="Native\FormsNative.cs" />
<Compile Include="Native\InteractiveNative.cs" />
<Compile Include="Native\PhantomJS.cs" />
<Compile Include="Remote\FormsRemote.cs" />
<Compile Include="Remote\InteractiveRemote.cs" />
<Compile Include="Native\RepeatableNativeTest.cs" />
- <Compile Include="Native\Selenium.cs" />
+ <Compile Include="Native\SeleniumIE.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Native\WatiN.cs" />
<Compile Include="Remote\Node.cs" />
@@ -0,0 +1,27 @@
+using System;
+using FluentAutomation;
+using FluentAutomation.Tests;
+using Xunit;
+
+namespace Tests
+{
+ public class SeleniumChrome : RepeatableNativeTest
+ {
+ public SeleniumChrome()
+ {
+ FluentAutomation.SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.Chrome);
+ }
+
+ [Fact]
+ public void YUIDragDrop()
+ {
+ this.interactive.YUIDragDrop();
+ }
+
+ [Fact]
+ public void Autocomplete_ExpectedResult()
+ {
+ this.forms.Autocomplete_ExpectedResult();
+ }
+ }
+}
@@ -5,9 +5,9 @@
namespace Tests
{
- public class Selenium : RepeatableNativeTest
+ public class SeleniumFirefox : RepeatableNativeTest
{
- public Selenium()
+ public SeleniumFirefox()
{
FluentAutomation.SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.Firefox);
}
@@ -0,0 +1,27 @@
+using System;
+using FluentAutomation;
+using FluentAutomation.Tests;
+using Xunit;
+
+namespace Tests
+{
+ public class SeleniumIE : RepeatableNativeTest
+ {
+ public SeleniumIE()
+ {
+ FluentAutomation.SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.InternetExplorer);
+ }
+
+ [Fact]
+ public void YUIDragDrop()
+ {
+ this.interactive.YUIDragDrop();
+ }
+
+ [Fact]
+ public void Autocomplete_ExpectedResult()
+ {
+ this.forms.Autocomplete_ExpectedResult();
+ }
+ }
+}
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace FluentAutomation
+{
+ public static class EmbeddedResources
+ {
+ public static void UnpackFromAssembly(string resourceFileName, Assembly assembly)
+ {
+ var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(x => x.EndsWith(resourceFileName));
+ if (!File.Exists(resourceFileName))
+ {
+ var resourceStream = assembly.GetManifestResourceStream(resourceName);
+ var resourceBytes = new byte[(int)resourceStream.Length];
+
+ resourceStream.Read(resourceBytes, 0, resourceBytes.Length);
+ File.WriteAllBytes(resourceFileName, resourceBytes);
+ }
+ }
+ }
+}
@@ -44,6 +44,7 @@
<Compile Include="ActionSyntaxProvider.cs" />
<Compile Include="BaseCommandProvider.cs" />
<Compile Include="BaseFluentTest.cs" />
+ <Compile Include="EmbeddedResources.cs" />
<Compile Include="ExpectProvider.cs" />
<Compile Include="Exceptions\FluentException.cs" />
<Compile Include="Exceptions\FluentExpectFailedException.cs" />

0 comments on commit 11dbf53

Please sign in to comment.