Skip to content

Commit

Permalink
Merge pull request #44 from Jayx239/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jayx239 authored Dec 1, 2018
2 parents f74c3c3 + ccf7e6c commit 90f7cbd
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 171 deletions.
14 changes: 8 additions & 6 deletions BrowseSharp/BrowseSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;net46;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net46;net452;netstandard2.0</TargetFrameworks>
<Authors>Jason Gallagher</Authors>
<Description>A headless browser supporting web navigation, html parsing, css style parsing, and javascript parsing/execution.</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>0.0.7.0</AssemblyVersion>
<FileVersion>0.0.7.0</FileVersion>
<Version>0.0.7-alpha</Version>
<AssemblyVersion>0.0.7.1</AssemblyVersion>
<FileVersion>0.0.7.1</FileVersion>
<Version>0.0.7-beta</Version>
<PackageLicenseUrl>https://github.com/Jayx239/BrowseSharp/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Copyright (c) 2018 Jason Gallagher</Copyright>
<PackageProjectUrl>https://www.browsesharp.org/</PackageProjectUrl>
<RepositoryUrl>https://github.com/Jayx239/BrowseSharp</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>Headless Browser Javascript HTML Parser Web RestSharp AngleSharp Jint Type Deserialization API Testing Security Automation Bot</PackageTags>
<Company>Jason Gallagher</Company>
<PackageReleaseNotes>* Added target frameworks for .net 4.5.2 and .net 4.6</PackageReleaseNotes>
<PackageReleaseNotes>* Fixed bug with target frameworks 4.5.2 and 4.6
- Needed to setup ServicePointManager.SecurityProtocol configuration.
</PackageReleaseNotes>
<NeutralLanguage />
<PackageIconUrl>https://raw.githubusercontent.com/Jayx239/BrowseSharp/master/BrowseSharp.png</PackageIconUrl>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
Expand All @@ -29,7 +31,7 @@
<PackageReference Include="AngleSharp" Version="0.9.9.2" />
<PackageReference Include="Jint" Version="2.11.55" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="RestSharp" Version="106.3.1" />
<PackageReference Include="RestSharp" Version="106.5.4" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net452'">
<Reference Include="System.Net.Http" />
Expand Down
1 change: 1 addition & 0 deletions BrowseSharp/Browsers/Core/BrowserCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public BrowserCore()
_styleScrapingEnabled = true;
_javascriptScrapingEnabled = true;
DefaultUriProtocol = "http";
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; // Updates protocol for target framework 4.5.2

}

Expand Down
24 changes: 12 additions & 12 deletions BrowseSharpTest/BrowseSharpTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -166,9 +167,6 @@
<Reference Include="Microsoft.DocAsCode.Build.UniversalReference, Version=2.37.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Microsoft.DocAsCode.Build.UniversalReference.2.37.2\lib\net461\Microsoft.DocAsCode.Build.UniversalReference.dll</HintPath>
</Reference>
<Reference Include="Microsoft.DocAsCode.Common, Version=2.37.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Microsoft.DocAsCode.Common.2.37.2\lib\net461\Microsoft.DocAsCode.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.DocAsCode.DataContracts.Common, Version=2.37.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Microsoft.DocAsCode.DataContracts.Common.2.37.2\lib\net461\Microsoft.DocAsCode.DataContracts.Common.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -319,8 +317,8 @@
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.3.1.0, Culture=neutral, PublicKeyToken=598062e77f915f75">
<HintPath>..\packages\RestSharp.106.3.1\lib\net452\RestSharp.dll</HintPath>
<Reference Include="RestSharp, Version=106.5.4.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="SimpleSyndicate, Version=1.0.38.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\SimpleSyndicate.1.0.38\lib\net45\SimpleSyndicate.dll</HintPath>
Expand Down Expand Up @@ -394,6 +392,7 @@
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
Expand All @@ -418,6 +417,8 @@
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand All @@ -437,8 +438,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="StandardCore.Test.cs" />
<Compile Include="TypedCore.Test.cs" />
<Compile Include="BrowserStandard.Test.cs" />
<Compile Include="BrowserTyped.Test.cs" />
<Compile Include="Form.Test.cs" />
Expand All @@ -447,19 +446,20 @@
<Compile Include="Models\Request.cs" />
<Compile Include="Models\RandomObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StandardCore.Test.cs" />
<Compile Include="TypedCore.Test.cs" />
<Compile Include="UriHelper.Test.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BrowseSharp\BrowseSharp.csproj">
<Project>{5892995f-8cbc-439a-9802-464e4333734e}</Project>
<Name>BrowseSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Build.Locator.1.0.13\build\Microsoft.Build.Locator.targets" Condition="Exists('..\packages\Microsoft.Build.Locator.1.0.13\build\Microsoft.Build.Locator.targets')" />
<Import Project="..\packages\docfx.console.2.37.2\build\docfx.console.targets" Condition="Exists('..\packages\docfx.console.2.37.2\build\docfx.console.targets')" />
Expand Down
80 changes: 40 additions & 40 deletions BrowseSharpTest/Browser.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using BrowseSharp;
using BrowseSharp.Html;
using BrowseSharpTest.Models;
using Microsoft.DocAsCode.Common;
using NUnit.Framework;
using RestSharp;

Expand Down Expand Up @@ -889,18 +889,18 @@ public void TestSubmitForm()
postForm.SetValue("Password", "TestPassword");

IDocument postResponse = browser.SubmitForm(postForm);
dynamic postResponseJson = postResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(postResponseJson.formData.UserName.ToString() == "TestUser");
Assert.True(postResponseJson.formData.Password.ToString() == "TestPassword");
dynamic postResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(postResponse.Body.TextContent);
Assert.True(postResponseJson["formData"]["UserName"] == "TestUser");
Assert.True(postResponseJson["formData"]["Password"] == "TestPassword");

getForm.SetValue("Message", "This is the test message");
getForm.SetValue("Email", "testemail@test.com");
getForm.SetValue("Rating", "3");
IDocument getResponse = browser.SubmitForm(getForm);
dynamic getResponseJson = getResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(getResponseJson.query.Message.ToString() == "This is the test message");
Assert.True(getResponseJson.query.Email.ToString() == "testemail@test.com");
Assert.True(getResponseJson.query.Rating.ToString() == "3");
dynamic getResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(getResponse.Body.TextContent);
Assert.True(getResponseJson["query"]["Message"] == "This is the test message");
Assert.True(getResponseJson["query"]["Email"] == "testemail@test.com");
Assert.True(getResponseJson["query"]["Rating"] == "3");
}

[Test]
Expand All @@ -918,12 +918,12 @@ public void TestSubmitFormHeaders()
postHeaders.Add("other-header","this is the other header");

IDocument postResponse = browser.SubmitForm(postForm, postHeaders);
dynamic postResponseJson = postResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(postResponseJson.formData.UserName.ToString() == "TestUser");
Assert.True(postResponseJson.formData.Password.ToString() == "TestPassword");
dynamic postResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(postResponse.Body.TextContent);
Assert.True(postResponseJson["formData"]["UserName"] == "TestUser");
Assert.True(postResponseJson["formData"]["Password"] == "TestPassword");

Assert.True(postResponseJson.headers["x-my-header"].ToString() == "MyHeaderValue");
Assert.True(postResponseJson.headers["other-header"].ToString() == "this is the other header");
Assert.True(postResponseJson["headers"]["x-my-header"] == "MyHeaderValue");
Assert.True(postResponseJson["headers"]["other-header"].ToString() == "this is the other header");

getForm.SetValue("Message", "This is the test message");
getForm.SetValue("Email", "testemail@test.com");
Expand All @@ -935,14 +935,14 @@ public void TestSubmitFormHeaders()
getHeaders.Add("athirdheader", "A 3rd header");

IDocument getResponse = browser.SubmitForm(getForm, getHeaders);
dynamic getResponseJson = getResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(getResponseJson.query.Message.ToString() == "This is the test message");
Assert.True(getResponseJson.query.Email.ToString() == "testemail@test.com");
Assert.True(getResponseJson.query.Rating.ToString() == "3");
dynamic getResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(getResponse.Body.TextContent);
Assert.True(getResponseJson["query"]["Message"] == "This is the test message");
Assert.True(getResponseJson["query"]["Email"] == "testemail@test.com");
Assert.True(getResponseJson["query"]["Rating"] == "3");

Assert.True(getResponseJson.headers["get-header"].ToString() == "This is a get header");
Assert.True(getResponseJson.headers["other-header"].ToString() == "Other header value");
Assert.True(getResponseJson.headers["athirdheader"].ToString() == "A 3rd header");
Assert.True(getResponseJson["headers"]["get-header"] == "This is a get header");
Assert.True(getResponseJson["headers"]["other-header"].ToString() == "Other header value");
Assert.True(getResponseJson["headers"]["athirdheader"].ToString() == "A 3rd header");
}


Expand All @@ -957,18 +957,18 @@ public async Task TestSubmitFormAsync()
postForm.SetValue("Password", "TestPassword");

IDocument postResponse = await browser.SubmitFormAsync(postForm);
dynamic postResponseJson = postResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(postResponseJson.formData.UserName.ToString() == "TestUser");
Assert.True(postResponseJson.formData.Password.ToString() == "TestPassword");
dynamic postResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(postResponse.Body.TextContent);
Assert.True(postResponseJson["formData"]["UserName"] == "TestUser");
Assert.True(postResponseJson["formData"]["Password"] == "TestPassword");

getForm.SetValue("Message", "This is the test message");
getForm.SetValue("Email", "testemail@test.com");
getForm.SetValue("Rating", "3");
IDocument getResponse = await browser.SubmitFormAsync(getForm);
dynamic getResponseJson = getResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(getResponseJson.query.Message.ToString() == "This is the test message");
Assert.True(getResponseJson.query.Email.ToString() == "testemail@test.com");
Assert.True(getResponseJson.query.Rating.ToString() == "3");
dynamic getResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(getResponse.Body.TextContent);
Assert.True(getResponseJson["query"]["Message"] == "This is the test message");
Assert.True(getResponseJson["query"]["Email"] == "testemail@test.com");
Assert.True(getResponseJson["query"]["Rating"] == "3");
}

[Test]
Expand All @@ -986,12 +986,12 @@ public async Task TestSubmitFormAsyncHeaders()
postHeaders.Add("other-header","this is the other header");

IDocument postResponse = await browser.SubmitFormAsync(postForm, postHeaders);
dynamic postResponseJson = postResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(postResponseJson.formData.UserName.ToString() == "TestUser");
Assert.True(postResponseJson.formData.Password.ToString() == "TestPassword");
dynamic postResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(postResponse.Body.TextContent);
Assert.True(postResponseJson["formData"]["UserName"] == "TestUser");
Assert.True(postResponseJson["formData"]["Password"] == "TestPassword");

Assert.True(postResponseJson.headers["x-my-header"].ToString() == "MyHeaderValue");
Assert.True(postResponseJson.headers["other-header"].ToString() == "this is the other header");
Assert.True(postResponseJson["headers"]["x-my-header"] == "MyHeaderValue");
Assert.True(postResponseJson["headers"]["other-header"].ToString() == "this is the other header");

getForm.SetValue("Message", "This is the test message");
getForm.SetValue("Email", "testemail@test.com");
Expand All @@ -1003,14 +1003,14 @@ public async Task TestSubmitFormAsyncHeaders()
getHeaders.Add("athirdheader", "A 3rd header");

IDocument getResponse = await browser.SubmitFormAsync(getForm, getHeaders);
dynamic getResponseJson = getResponse.Body.TextContent.FromJsonString<dynamic>();
Assert.True(getResponseJson.query.Message.ToString() == "This is the test message");
Assert.True(getResponseJson.query.Email.ToString() == "testemail@test.com");
Assert.True(getResponseJson.query.Rating.ToString() == "3");

Assert.True(getResponseJson.headers["get-header"].ToString() == "This is a get header");
Assert.True(getResponseJson.headers["other-header"].ToString() == "Other header value");
Assert.True(getResponseJson.headers["athirdheader"].ToString() == "A 3rd header");
dynamic getResponseJson = new JavaScriptSerializer().Deserialize<dynamic>(getResponse.Body.TextContent);
Assert.True(getResponseJson["query"]["Message"] == "This is the test message");
Assert.True(getResponseJson["query"]["Email"] == "testemail@test.com");
Assert.True(getResponseJson["query"]["Rating"] == "3");

Assert.True(getResponseJson["headers"]["get-header"] == "This is a get header");
Assert.True(getResponseJson["headers"]["other-header"].ToString() == "Other header value");
Assert.True(getResponseJson["headers"]["athirdheader"].ToString() == "A 3rd header");
}

/// <summary>
Expand Down
Loading

0 comments on commit 90f7cbd

Please sign in to comment.