Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfowler committed Mar 27, 2019
2 parents ea1c4cd + 18c0dcb commit 734ce4c
Show file tree
Hide file tree
Showing 21 changed files with 216 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ matrix:
- env:
- WebDriver_Platform="macOS 10.13"
- WebDriver_BrowserName="Safari"
- WebDriver_BrowserVersion="11.0"
- WebDriver_BrowserVersion="11.1"
- env:
- WebDriver_Platform="macOS 10.13"
- WebDriver_BrowserName="Safari"
- WebDriver_BrowserVersion="latest"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>CSF.Screenplay.Selenium.Tests</RootNamespace>
<AssemblyName>CSF.Screenplay.Selenium.BrowserFlags.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>0.5.0-beta</ReleaseVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>CSF.Screenplay.Selenium</RootNamespace>
<AssemblyName>CSF.Screenplay.Selenium.BrowserFlags</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>0.5.0-beta</ReleaseVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<package>
<metadata>
<id>CSF.Screenplay.Selenium.BrowserFlags</id>
<version>0.5.0-beta</version>
<version>1.0.0</version>
<title>CSF.Screenplay.Selenium.BrowserFlags</title>
<authors>CSF Software Ltd</authors>
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
<license type="expression">MIT</license>
<projectUrl>https://github.com/csf-dev/CSF.Screenplay.Selenium</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>An assembly containing 'browser flags definitions' for CSF.Screenplay.Selenium. This indicates the quirks and behaviours of various popular web browsers which are compatible with Selenium WebDriver.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>CSF.Screenplay.Selenium</RootNamespace>
<AssemblyName>CSF.Screenplay.Selenium.JavaScriptWorkarounds</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>0.5.0-beta</ReleaseVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>CSF.Screenplay.Selenium.Tests</RootNamespace>
<AssemblyName>CSF.Screenplay.Selenium.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>0.5.0-beta</ReleaseVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
33 changes: 33 additions & 0 deletions CSF.Screenplay.Selenium.Tests/Waits/WaitUntilVisibleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,38 @@ public void Wait_UntilVisible_raises_exception_if_we_dont_wait_long_enough(ICast
When(joe).AttemptsTo(Wait.ForAtMost(2).Seconds().OrUntil(PageThree.DelayedLinkOne).IsVisible());
});
}

[Test,Screenplay]
[Description("If the actor's default wait time is not long enough for the element to appear then an exception is raised.")]
public void Wait_UntilVisible_raises_exception_if_actors_default_wait_time_is_not_long_enough(ICast cast, BrowseTheWeb browseTheWeb)
{
var joe = cast.Get("Joe");
joe.IsAbleTo(browseTheWeb);
joe.IsAbleTo(ChooseADefaultWaitTime.Of(TimeSpan.FromSeconds(2)));

Given(joe).WasAbleTo(OpenTheirBrowserOn.ThePage<PageThree>());

When(joe).AttemptsTo(Click.On(PageThree.DelayedButtonOne));

Assert.Throws<GivenUpWaitingException>(() => {
When(joe).AttemptsTo(Wait.Until(PageThree.DelayedLinkOne).IsVisible());
});
}

[Test,Screenplay]
[Description("If the actor's default wait time is sufficient for the element to appear then no exception is raised.")]
public void Wait_UntilVisible_does_not_raise_exception_if_actors_default_wait_time_is_long_enough(ICast cast, BrowseTheWeb browseTheWeb)
{
var joe = cast.Get("Joe");
joe.IsAbleTo(browseTheWeb);
joe.IsAbleTo(ChooseADefaultWaitTime.Of(TimeSpan.FromSeconds(5)));

Given(joe).WasAbleTo(OpenTheirBrowserOn.ThePage<PageThree>());

When(joe).AttemptsTo(Click.On(PageThree.DelayedButtonOne));
When(joe).AttemptsTo(Wait.Until(PageThree.DelayedLinkOne).IsVisible());

Then(joe).ShouldSee(TheText.Of(PageThree.DelayedLinkOne)).Should().Be("This link appears!");
}
}
}
2 changes: 1 addition & 1 deletion CSF.Screenplay.Selenium.sln
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ Global
{87454F03-FBB3-4506-9055-551297445891} = {ED939EED-BD26-4C3C-9089-48E04DD01CD8}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 0.5.0-beta
version = 1.0.0
EndGlobalSection
EndGlobal
62 changes: 62 additions & 0 deletions CSF.Screenplay.Selenium/Abilities/ChooseADefaultWaitTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// SetADefaultWaitTime.cs
//
// Author:
// Craig Fowler <craig@csf-dev.com>
//
// Copyright (c) 2019 Craig Fowler
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using CSF.Screenplay.Abilities;

namespace CSF.Screenplay.Selenium.Abilities
{
/// <summary>
/// An ability which allows an actor to specify/choose a default amount of time to wait.
/// This default waiting-time applies to all web-driver-wait scenarios where no waiting time has been specified.
/// Actors without this ability use a hard-coded default of ten seconds for waits.
/// </summary>
public class ChooseADefaultWaitTime : Ability
{
readonly TimeSpan timeout;

/// <summary>
/// Gets the wait timeout.
/// </summary>
/// <value>The timeout.</value>
public TimeSpan Timeout => timeout;

/// <summary>
/// Initializes a new instance of the <see cref="ChooseADefaultWaitTime"/> class.
/// </summary>
/// <param name="timeout">Timeout.</param>
public ChooseADefaultWaitTime(TimeSpan timeout)
{
this.timeout = timeout;
}

/// <summary>
/// Static builder function to get a new instance of this ability.
/// </summary>
/// <returns>An instance of the ability.</returns>
/// <param name="timeout">Timeout.</param>
public static ChooseADefaultWaitTime Of(TimeSpan timeout) => new ChooseADefaultWaitTime(timeout);
}
}
16 changes: 5 additions & 11 deletions CSF.Screenplay.Selenium/Builders/Wait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace CSF.Screenplay.Selenium.Builders
/// </summary>
public class Wait
{
static readonly IProvidesTimespan DefaultTimeout = new TimespanWrapper(TimeSpan.FromSeconds(4));

IProvidesTimespan timespanProvider;
ITarget target;

Expand Down Expand Up @@ -57,11 +55,7 @@ public static Wait Until(ITarget target)
if(target == null)
throw new ArgumentNullException(nameof(target));

return new Wait
{
target = target,
timespanProvider = DefaultTimeout,
};
return new Wait { target = target };
}

/// <summary>
Expand All @@ -72,20 +66,20 @@ public static Wait Until(ITarget target)
/// <param name="conditionName">A name for the condition.</param>
public static IPerformable Until(Func<IWebDriver,bool> expectedCondition, string conditionName)
{
return new WaitForACondition(expectedCondition, conditionName, DefaultTimeout.GetTimespan());
return new WaitForACondition(expectedCondition, conditionName, null);
}

/// <summary>
/// Gets a 'wait' performable which completes once the page has finished loading, using the default timeout.
/// </summary>
/// <returns>The performable.</returns>
public static IPerformable UntilThePageLoads() => new WaitUntilThePageLoads(DefaultTimeout.GetTimespan());
public static IPerformable UntilThePageLoads() => new WaitUntilThePageLoads(null);

/// <summary>
/// Gets a 'wait' performable which completes once the page has finished loading.
/// </summary>
/// <returns>The performable.</returns>
public IPerformable OrUntilThePageLoads() => new WaitUntilThePageLoads(timespanProvider.GetTimespan());
public IPerformable OrUntilThePageLoads() => new WaitUntilThePageLoads(timespanProvider?.GetTimespan());

/// <summary>
/// Gets a wait builder for a given target.
Expand Down Expand Up @@ -173,7 +167,7 @@ ITargettedWait GetTargettedWait<T>(IQuery<T> query, Func<T,bool> predicate)
if(target == null)
throw new InvalidOperationException("You must choose a target.");

return new TargettedWait<T>(target, query, predicate, timespanProvider.GetTimespan());
return new TargettedWait<T>(target, query, predicate, timespanProvider?.GetTimespan());
}
}
}
5 changes: 4 additions & 1 deletion CSF.Screenplay.Selenium/CSF.Screenplay.Selenium.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RootNamespace>CSF.Screenplay.Selenium</RootNamespace>
<AssemblyName>CSF.Screenplay.Selenium</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<ReleaseVersion>0.5.0-beta</ReleaseVersion>
<ReleaseVersion>1.0.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -210,6 +210,9 @@
<Compile Include="ITracksWebDriverCreation.cs" />
<Compile Include="Builders\Matches.cs" />
<Compile Include="Builders\MatcherBuilderExtensions.cs" />
<Compile Include="ScreenplayConstants.cs" />
<Compile Include="Abilities\ChooseADefaultWaitTime.cs" />
<Compile Include="Waits\GetDuration.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
8 changes: 4 additions & 4 deletions CSF.Screenplay.Selenium/CSF.Screenplay.Selenium.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<package>
<metadata>
<id>CSF.Screenplay.Selenium</id>
<version>0.5.0-beta</version>
<version>1.0.0</version>
<title>CSF.Screenplay.Selenium</title>
<authors>CSF Software Ltd</authors>
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
<license type="expression">MIT</license>
<projectUrl>https://github.com/csf-dev/CSF.Screenplay.Selenium</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Extension to CSF.Screenplay, providing an ability, actions and tasks for Selenium WebDriver for web UI testing using the Screenplay pattern</description>
Expand All @@ -15,9 +15,9 @@
<dependency id="CSF.Utils" version="[6.1.1,7.0.0)" />
<dependency id="Selenium.WebDriver" version="[3.4.0,4.0.0)" />
<dependency id="Selenium.Support" version="[3.4.0,4.0.0)" />
<dependency id="CSF.Screenplay" version="0.14.0-beta" />
<dependency id="CSF.Screenplay" version="[1.0.0,2.0.0)" />
<dependency id="CSF.WebDriverExtras" version="[1.0.3,2.0.0)" />
<dependency id="CSF.Screenplay.Selenium.BrowserFlags" version="0.5.0-beta" />
<dependency id="CSF.Screenplay.Selenium.BrowserFlags" version="[1.0.0,2.0.0)" />
</dependencies>
</metadata>
<files>
Expand Down
2 changes: 1 addition & 1 deletion CSF.Screenplay.Selenium/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
33 changes: 33 additions & 0 deletions CSF.Screenplay.Selenium/ScreenplayConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ScreenplayConstant.cs
//
// Author:
// Craig Fowler <craig@csf-dev.com>
//
// Copyright (c) 2019 Craig Fowler
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace CSF.Screenplay.Selenium
{
static class ScreenplayConstants
{
public static readonly TimeSpan DefaultWait = TimeSpan.FromSeconds(10);
}
}
50 changes: 50 additions & 0 deletions CSF.Screenplay.Selenium/Waits/GetDuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// GetWaitDuration.cs
//
// Author:
// Craig Fowler <craig@csf-dev.com>
//
// Copyright (c) 2019 Craig Fowler
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using CSF.Screenplay.Actors;
using CSF.Screenplay.Selenium.Abilities;

namespace CSF.Screenplay.Selenium.Waits
{
static class GetDuration
{
public static TimeSpan ToWait(TimeSpan? specifiedWaitTime, INamed actor)
=> ToWait(specifiedWaitTime, actor as IPerformer);

public static TimeSpan ToWait(TimeSpan? specifiedWaitTime, IPerformer actor)
=> specifiedWaitTime ?? GetActorWaitTime(actor) ?? GetDefaultWaitTime();

static TimeSpan GetDefaultWaitTime() => ScreenplayConstants.DefaultWait;

static TimeSpan? GetActorWaitTime(IPerformer actor)
{
if(actor == null) return null;
if(!actor.HasAbility<ChooseADefaultWaitTime>()) return null;
var ability = actor.GetAbility<ChooseADefaultWaitTime>();
return ability.Timeout;
}
}
}
Loading

0 comments on commit 734ce4c

Please sign in to comment.