Skip to content

Commit

Permalink
added jquery/sizzle selector support to accomodate pull request from …
Browse files Browse the repository at this point in the history
…gkinsman #98
  • Loading branch information
lefthandedgoat committed Sep 4, 2013
1 parent 69fd007 commit ab9b70c
Show file tree
Hide file tree
Showing 26 changed files with 76,239 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
136 changes: 136 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
13 changes: 11 additions & 2 deletions basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open runner
open configuration
open reporters

start chrome
start phantomJS
let mainBrowser = browser
elementTimeout <- 3.0
compareTimeout <- 3.0
Expand Down Expand Up @@ -187,6 +187,11 @@ test (fun _ ->
check "#checkbox"
selected "#checkbox")

"clicking #checkbox selects it via sizzle" &&& (fun _ ->
!^ testpage
check "#checkbox"
count "input:checked" 1)

"clicking selected #checkbox deselects it" &&& (fun _ ->
!^ testpage
check "#checkbox"
Expand Down Expand Up @@ -362,7 +367,7 @@ context "other tests"
!^ testpage
"#states" << "Kingman Reef"
"#states" == "Kingman Reef")

"double clicking" &&& (fun _ ->
!^ "http://lefthandedgoat.github.io/canopy/testpages/doubleClick"
"#clicked" == "Not Clicked"
Expand All @@ -389,6 +394,10 @@ context "other tests"
!^ "http://lefthandedgoat.github.io/canopy/testpages/count"
count ".number" 5)

"count test via sizzle" &&& (fun _ ->
!^ testpage
count "option:selected" 2)

context "dragging"
"draging works" &&& (fun _ ->
url "http://scrumy.com/silenter39delayed"
Expand Down
12 changes: 12 additions & 0 deletions canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,20 @@ let waitFor (f : unit -> bool) =

//find related
let private findByCss cssSelector f =
try
f(By.CssSelector(cssSelector)) |> List.ofSeq
with | ex -> []

let private findBySizzle cssSelector f =
try
f(BySizzle.CssSelector(cssSelector)) |> List.ofSeq
with | ex -> []

let private findByJQuery cssSelector f =
try
f(ByJQuery.CssSelector(cssSelector)) |> List.ofSeq
with | ex -> []

let private findByXpath xpath f =
try
f(By.XPath(xpath)) |> List.ofSeq
Expand Down Expand Up @@ -206,6 +216,8 @@ let rec private findElements (cssSelector : string) (searchContext : ISearchCont
yield (findByXpath cssSelector searchContext.FindElements)
yield (findByLabel cssSelector searchContext.FindElement)
yield (findByText cssSelector searchContext.FindElements)
yield (findBySizzle cssSelector searchContext.FindElements)
yield (findByJQuery cssSelector searchContext.FindElements)
yield (findInIFrame())
}
|> Seq.filter(fun list -> not(list.IsEmpty))
Expand Down
4 changes: 2 additions & 2 deletions canopy/canopy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json.5.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SizSelCsZzz">
<HintPath>..\..\packages\SizSelCsZzz.0.3.34.0\lib\SizSelCsZzz.dll</HintPath>
<HintPath>..\packages\SizSelCsZzz.0.3.34.0\lib\SizSelCsZzz.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
19 changes: 19 additions & 0 deletions packages/Newtonsoft.Json.5.0.6/Newtonsoft.Json.5.0.6.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>Newtonsoft.Json</id>
<version>5.0.6</version>
<title>Json.NET</title>
<authors>James Newton-King</authors>
<owners>James Newton-King</owners>
<licenseUrl>http://json.codeplex.com/license</licenseUrl>
<projectUrl>http://james.newtonking.com/projects/json-net.aspx</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
<language>en-US</language>
<tags>json</tags>
<references>
<reference file="Newtonsoft.Json.dll" />
</references>
</metadata>
</package>
Binary file not shown.
Loading

0 comments on commit ab9b70c

Please sign in to comment.