Skip to content

Commit

Permalink
More csharp warpper for #327
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jan 12, 2017
1 parent 3af60d9 commit 6a1c152
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
42 changes: 41 additions & 1 deletion csharptests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,49 @@ static void Main(string[] args)
_.test("#firstName should have John (using == infix operator)", () =>
{
_.url(testpage);
_.equals("#firstName", "John");
_.eq("#firstName", "John");
});


_.test("#lastName should have Doe via read IWebElements", () =>
{
_.url(testpage);
var e = _.element("#lastname");
var value = _.read(e);
_.equality(value, "Doe");
});

_.test("clearing #firstName sets text to new empty string", () =>
{
_.url(testpage);
_.clear("#firstName");
_.eq("#firstName", "");
});

_.test("clearing #firstName sets text to new empty string via IWebElement", () =>
{
_.url(testpage);
_.clear(_.element("#firstName"));
_.eq("#firstName", "");
});

_.test("writing to #lastName sets text to Smith", () =>
{
_.url(testpage);
_.clear("#lastName");
_.write("#lastName", "Smith");
_.eq("#lastName", "Smith");
});

_.test("writing to #lastName (as element) sets text to John", () =>
{
_.url(testpage);
var lastname = _.element("#lastname");
_.clear(lastname);
_.write(lastname, "John");
_.eq("#lastname", "John");
});

_.run();

System.Console.ReadKey();
Expand Down
1 change: 1 addition & 0 deletions csharptests/csharptests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WebDriver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
Expand Down
13 changes: 12 additions & 1 deletion src/canopy/csharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ type canopy () =

static member quit () = canopy.core.quit ()

//element stuff
static member element selector = canopy.core.element selector

static member read selector = canopy.core.read selector

static member clear selector = canopy.core.clear selector

static member write selector value = selector << value

//assertions
static member equals selector value = selector == value
static member eq selector value = selector == value

static member equality value1 value2 = value1 === value2

static member count selector value = count selector value

0 comments on commit 6a1c152

Please sign in to comment.