From 9a17d3144557f8b46cc43677a5a8dd677a41a8ba Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:24:05 -0500 Subject: [PATCH 1/9] Add SwitchFrame property to control whether or not to start from DefaultContent --- Boa.Constrictor.Selenium/CHANGELOG.md | 7 ++++- Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs | 26 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index b0cbc6b..bb5edab 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -19,13 +19,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (none) +## [4.1.0-alpha1] - 2024-01-25 + +### Added + +- Added `SwitchFrames` property to control switching to Default Content first ## [4.0.0] - 2023-05-29 ### Added - Added `SwitchFrame` Task with automatic waiting -- Addd commented code for a potential `PerformInFrame` Task +- Add commented code for a potential `PerformInFrame` Task - This one is currently exhibiting flaky errors - We must investigate further before releasing it officially diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs index c345e9d..6b1e631 100644 --- a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs +++ b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs @@ -16,10 +16,12 @@ public class SwitchFrame : AbstractWebTask /// (Use static builder methods to construct.) /// /// The locator. + /// If true switch to DefaultContent before switching to the locator. /// If true use DefaultContent instead of the locator. - private SwitchFrame(IWebLocator locator, bool useDefaultContent) + private SwitchFrame(IWebLocator locator, bool useDefaultContent, bool startFromDefaultContent = true) { Locator = locator; + StartFromDefaultContent = startFromDefaultContent; UseDefaultContent = useDefaultContent; } @@ -32,6 +34,11 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent) /// public IWebLocator Locator { get; } + /// + /// Switch to DefaultContent first before switching to a frame. + /// + public bool StartFromDefaultContent { get; } + /// /// The DefaultContent is used. /// @@ -54,6 +61,13 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent) /// public static SwitchFrame ToDefaultContent() => new SwitchFrame(null, true); + /// + /// Constructs the Task object for the given locator without starting from DefaultContent. + /// + /// The locator. + /// + public static SwitchFrame WithoutUsingDefaultContentTo(IWebLocator locator) => new SwitchFrame(locator, false, false); + #endregion #region Methods @@ -65,7 +79,8 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent) /// The WebDriver. public override void PerformAs(IActor actor, IWebDriver driver) { - driver.SwitchTo().DefaultContent(); + if (StartFromDefaultContent) + driver.SwitchTo().DefaultContent(); if (!UseDefaultContent) { @@ -81,6 +96,7 @@ public override void PerformAs(IActor actor, IWebDriver driver) public override bool Equals(object obj) => obj is SwitchFrame frame && Locator.Equals(frame.Locator) && + StartFromDefaultContent == frame.StartFromDefaultContent && UseDefaultContent == frame.UseDefaultContent; /// @@ -88,14 +104,14 @@ obj is SwitchFrame frame && /// /// public override int GetHashCode() => - HashCode.Combine(GetType(), Locator, UseDefaultContent); + HashCode.Combine(GetType(), Locator, StartFromDefaultContent, UseDefaultContent); /// /// Returns a description of the Task. /// /// - public override string ToString() => - UseDefaultContent + public override string ToString() => + UseDefaultContent ? "switch frame to DefaultContent" : $"switch frame to '{Locator.Description}'"; From f5552c174fb76c7ae8ece56e50d2935b02ac8606 Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:45:28 -0500 Subject: [PATCH 2/9] Add SwitchIntoNestedFrames Task --- .../Boa.Constrictor.Selenium.csproj | 2 +- Boa.Constrictor.Selenium/CHANGELOG.md | 2 + Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs | 4 +- .../Tasks/SwitchIntoNestedFrames.cs | 82 +++++++++++++++++++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs diff --git a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj index b4e5272..bf150d8 100644 --- a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj +++ b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 4.0.0 + 4.1.0-alpha1 Pandy Knight and the PrecisionLender SETs Q2 Boa.Constrictor.Selenium diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index bb5edab..9c24072 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `SwitchFrames` property to control switching to Default Content first +- Added `SwitchIntoNestedFrames` Task + ## [4.0.0] - 2023-05-29 diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs index 6b1e631..6e2bd98 100644 --- a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs +++ b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs @@ -1,6 +1,6 @@ -using System; -using Boa.Constrictor.Screenplay; +using Boa.Constrictor.Screenplay; using OpenQA.Selenium; +using System; namespace Boa.Constrictor.Selenium { diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs b/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs new file mode 100644 index 0000000..fb25c54 --- /dev/null +++ b/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs @@ -0,0 +1,82 @@ +using Boa.Constrictor.Screenplay; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Boa.Constrictor.Selenium +{ + /// + /// Traverses through nested frames to switch to the final one. + /// + public class SwitchIntoNestedFrames : ITask + { + #region Constructors + + /// + /// Private Constructor. + /// (Use the public builder methods.) + /// + /// The frame locator list. + private SwitchIntoNestedFrames(List locators) => Locators = locators; + + #endregion + + #region Properties + + /// + /// The list of frame locators. + /// The target Web element's locator is the last element of the frame locator list. + /// + public List Locators { get; } + + #endregion + + #region Builder Methods + + /// + /// Constructs the Task. + /// + /// The frame locator list. + public static SwitchIntoNestedFrames To(List locators) => new SwitchIntoNestedFrames(locators); + + #endregion + + #region Methods + + /// + /// Switch into frames to the last locator in the list. + /// + /// The Screenplay Actor. + public void PerformAs(IActor actor) + { + actor.AttemptsTo(SwitchFrame.ToDefaultContent()); + + foreach (IWebLocator locator in Locators) + actor.AttemptsTo(SwitchFrame.WithoutUsingDefaultContentTo(locator)); + } + + /// + /// Checks if this interaction is equal to another interaction. + /// + /// The other object. + public override bool Equals(object obj) => + obj is SwitchIntoNestedFrames frame && + Locators.Equals(frame.Locators); + + /// + /// Gets a unique hash code for this interaction. + /// + /// + public override int GetHashCode() => + HashCode.Combine(GetType(), Locators); + + /// + /// Returns a description of the Task. + /// + /// + public override string ToString() => + $"switch into nested frames to '{Locators.Last().Description}'"; + + #endregion + } +} From 71108871b4ae2fc5939a44903535964c9aa1f1b1 Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:46:51 -0500 Subject: [PATCH 3/9] Add property to control whether or not to start from use DefaultContent --- .../Tasks/SwitchIntoNestedFrames.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs b/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs index fb25c54..f07f8a3 100644 --- a/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs +++ b/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs @@ -17,7 +17,12 @@ public class SwitchIntoNestedFrames : ITask /// (Use the public builder methods.) /// /// The frame locator list. - private SwitchIntoNestedFrames(List locators) => Locators = locators; + /// If true switch to DefaultContent before switching to the locator. + private SwitchIntoNestedFrames(List locators, bool startFromDefaultContent = true) + { + Locators = locators; + StartFromDefaultContent = startFromDefaultContent; + } #endregion @@ -29,6 +34,11 @@ public class SwitchIntoNestedFrames : ITask /// public List Locators { get; } + /// + /// Switch to DefaultContent first before switching to a frame. + /// + public bool StartFromDefaultContent { get; } + #endregion #region Builder Methods @@ -37,7 +47,15 @@ public class SwitchIntoNestedFrames : ITask /// Constructs the Task. /// /// The frame locator list. - public static SwitchIntoNestedFrames To(List locators) => new SwitchIntoNestedFrames(locators); + public static SwitchIntoNestedFrames To(List locators) => + new SwitchIntoNestedFrames(locators); + + /// + /// Constructs the Task. + /// + /// The frame locator list. + public static SwitchIntoNestedFrames WithoutUsingDefaultContentTo(List locators) => + new SwitchIntoNestedFrames(locators, false); #endregion @@ -49,7 +67,8 @@ public class SwitchIntoNestedFrames : ITask /// The Screenplay Actor. public void PerformAs(IActor actor) { - actor.AttemptsTo(SwitchFrame.ToDefaultContent()); + if (StartFromDefaultContent) + actor.AttemptsTo(SwitchFrame.ToDefaultContent()); foreach (IWebLocator locator in Locators) actor.AttemptsTo(SwitchFrame.WithoutUsingDefaultContentTo(locator)); From 734858dde6729cbdfde67ac670c1b84ffb3aaf3f Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:55:41 -0500 Subject: [PATCH 4/9] Update to Boa.Constrictor.Selenium to 4.1.0-alpha2 and correct CHANGELOG --- Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj | 2 +- Boa.Constrictor.Selenium/CHANGELOG.md | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj index bf150d8..910b14f 100644 --- a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj +++ b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 4.1.0-alpha1 + 4.1.0-alpha2 Pandy Knight and the PrecisionLender SETs Q2 Boa.Constrictor.Selenium diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index 9c24072..36f8e9d 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -19,12 +19,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (none) +## [4.1.0-alpha2] - 2024-01-25 + +### Added +- Added `SwitchIntoNestedFrames` Task + + ## [4.1.0-alpha1] - 2024-01-25 ### Added - Added `SwitchFrames` property to control switching to Default Content first -- Added `SwitchIntoNestedFrames` Task ## [4.0.0] - 2023-05-29 From fd40970b3a4d73b5b9b94d4b64b1d4ab15182cc2 Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:18:22 -0500 Subject: [PATCH 5/9] Boa.Constrictor.Selenium 4.1.0 --- Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj | 4 ++-- Boa.Constrictor.Selenium/CHANGELOG.md | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj index 910b14f..8eab3b0 100644 --- a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj +++ b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj @@ -2,13 +2,13 @@ netstandard2.0 - 4.1.0-alpha2 + 4.1.0 Pandy Knight and the PrecisionLender SETs Q2 Boa.Constrictor.Selenium Boa.Constrictor.Selenium Boa Constrictor is the .NET Screenplay Pattern! This package is the Selenium WebDriver interaction library. - Copyright © 2020-2023 Q2 Holdings Inc. + Copyright © 2020-2024 Q2 Holdings Inc. https://github.com/q2ebanking/boa-constrictor git true diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index 36f8e9d..76b1f53 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -19,17 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (none) -## [4.1.0-alpha2] - 2024-01-25 - -### Added -- Added `SwitchIntoNestedFrames` Task - -## [4.1.0-alpha1] - 2024-01-25 +## [4.1.0] - 2024-01-25 ### Added - - Added `SwitchFrames` property to control switching to Default Content first +- Added `SwitchIntoNestedFrames` Task ## [4.0.0] - 2023-05-29 From bc469283eba34c756a88b2940e5753f8fd583489 Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:20:35 -0500 Subject: [PATCH 6/9] Bump version to today's date --- Boa.Constrictor.Selenium/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index 76b1f53..2e0b2de 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (none) -## [4.1.0] - 2024-01-25 +## [4.1.0] - 2024-01-26 ### Added - Added `SwitchFrames` property to control switching to Default Content first From 9ab2a078ddc097407cb8779d92c0384abc06e0f9 Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:30:51 -0500 Subject: [PATCH 7/9] Merge nested functionality into SwitchFrame --- .../Boa.Constrictor.Selenium.csproj | 2 +- Boa.Constrictor.Selenium/CHANGELOG.md | 9 +- Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs | 62 +++++++---- .../Tasks/SwitchIntoNestedFrames.cs | 101 ------------------ 4 files changed, 46 insertions(+), 128 deletions(-) delete mode 100644 Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs diff --git a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj index 8eab3b0..344f328 100644 --- a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj +++ b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 4.1.0 + 4.1.0-alpha4 Pandy Knight and the PrecisionLender SETs Q2 Boa.Constrictor.Selenium diff --git a/Boa.Constrictor.Selenium/CHANGELOG.md b/Boa.Constrictor.Selenium/CHANGELOG.md index 2e0b2de..136e1a8 100644 --- a/Boa.Constrictor.Selenium/CHANGELOG.md +++ b/Boa.Constrictor.Selenium/CHANGELOG.md @@ -20,11 +20,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 (none) -## [4.1.0] - 2024-01-26 +## [4.1.0] - 2024-01-29 ### Added -- Added `SwitchFrames` property to control switching to Default Content first -- Added `SwitchIntoNestedFrames` Task +- Added `SwitchFrames` property to control switching to DefaultContent first +- Added functionality to switch into nested frames in `SwitchFrames` + +### Changed +- `SwitchFrames` `Locator` property is now a list ## [4.0.0] - 2023-05-29 diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs index 6e2bd98..f4a8977 100644 --- a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs +++ b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs @@ -1,11 +1,14 @@ using Boa.Constrictor.Screenplay; using OpenQA.Selenium; using System; +using System.Collections.Generic; +using System.Linq; namespace Boa.Constrictor.Selenium { /// /// Switches the frame. + /// Start from DefaultContent by default. /// public class SwitchFrame : AbstractWebTask { @@ -15,13 +18,12 @@ public class SwitchFrame : AbstractWebTask /// Private constructor. /// (Use static builder methods to construct.) /// - /// The locator. - /// If true switch to DefaultContent before switching to the locator. - /// If true use DefaultContent instead of the locator. - private SwitchFrame(IWebLocator locator, bool useDefaultContent, bool startFromDefaultContent = true) + /// The list of locators. + /// If true use DefaultContent instead of the locators. + private SwitchFrame(List locators, bool useDefaultContent) { - Locator = locator; - StartFromDefaultContent = startFromDefaultContent; + Locators = locators; + StartFromCurrentLocation = false; UseDefaultContent = useDefaultContent; } @@ -30,17 +32,17 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent, bool startFromD #region Properties /// - /// The target Web element's locator. + /// The list of target Web element locators. /// - public IWebLocator Locator { get; } + public List Locators { get; } /// - /// Switch to DefaultContent first before switching to a frame. + /// Start from current location instead of switching to DefaultContent first. /// - public bool StartFromDefaultContent { get; } + public bool StartFromCurrentLocation { get; set; } /// - /// The DefaultContent is used. + /// Switch to DefaultContent instead of a target frame. /// public bool UseDefaultContent { get; } @@ -53,20 +55,31 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent, bool startFromD /// /// The locator. /// - public static SwitchFrame To(IWebLocator locator) => new SwitchFrame(locator, false); + public static SwitchFrame To(IWebLocator locator) => + new SwitchFrame(new List { locator }, false); /// /// Constructs the Task object for DefaultContent. /// /// - public static SwitchFrame ToDefaultContent() => new SwitchFrame(null, true); + public static SwitchFrame ToDefaultContent() => new SwitchFrame(new List(), true); /// - /// Constructs the Task object for the given locator without starting from DefaultContent. + /// Constructs the Task object for the given locator list. + /// + /// The list of locators. + /// + public static SwitchFrame ToNested(List locators) => new SwitchFrame(locators, false); + + /// + /// Sets the Task to start from current location instead of DefaultContent. /// - /// The locator. /// - public static SwitchFrame WithoutUsingDefaultContentTo(IWebLocator locator) => new SwitchFrame(locator, false, false); + public SwitchFrame AndStartFromCurrentLocation() + { + StartFromCurrentLocation = true; + return this; + } #endregion @@ -79,13 +92,16 @@ private SwitchFrame(IWebLocator locator, bool useDefaultContent, bool startFromD /// The WebDriver. public override void PerformAs(IActor actor, IWebDriver driver) { - if (StartFromDefaultContent) + if (UseDefaultContent || !StartFromCurrentLocation) driver.SwitchTo().DefaultContent(); if (!UseDefaultContent) { - actor.WaitsUntil(Existence.Of(Locator), IsEqualTo.True()); - driver.SwitchTo().Frame(Locator.FindElement(driver)); + foreach (IWebLocator locator in Locators) + { + actor.WaitsUntil(Existence.Of(locator), IsEqualTo.True()); + driver.SwitchTo().Frame(locator.FindElement(driver)); + } } } @@ -95,8 +111,8 @@ public override void PerformAs(IActor actor, IWebDriver driver) /// The other object. public override bool Equals(object obj) => obj is SwitchFrame frame && - Locator.Equals(frame.Locator) && - StartFromDefaultContent == frame.StartFromDefaultContent && + Locators.Equals(frame.Locators) && + StartFromCurrentLocation == frame.StartFromCurrentLocation && UseDefaultContent == frame.UseDefaultContent; /// @@ -104,7 +120,7 @@ obj is SwitchFrame frame && /// /// public override int GetHashCode() => - HashCode.Combine(GetType(), Locator, StartFromDefaultContent, UseDefaultContent); + HashCode.Combine(GetType(), Locators, StartFromCurrentLocation, UseDefaultContent); /// /// Returns a description of the Task. @@ -113,7 +129,7 @@ public override int GetHashCode() => public override string ToString() => UseDefaultContent ? "switch frame to DefaultContent" - : $"switch frame to '{Locator.Description}'"; + : $"switch frame to '{Locators.Last().Description}'"; #endregion } diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs b/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs deleted file mode 100644 index f07f8a3..0000000 --- a/Boa.Constrictor.Selenium/Tasks/SwitchIntoNestedFrames.cs +++ /dev/null @@ -1,101 +0,0 @@ -using Boa.Constrictor.Screenplay; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Boa.Constrictor.Selenium -{ - /// - /// Traverses through nested frames to switch to the final one. - /// - public class SwitchIntoNestedFrames : ITask - { - #region Constructors - - /// - /// Private Constructor. - /// (Use the public builder methods.) - /// - /// The frame locator list. - /// If true switch to DefaultContent before switching to the locator. - private SwitchIntoNestedFrames(List locators, bool startFromDefaultContent = true) - { - Locators = locators; - StartFromDefaultContent = startFromDefaultContent; - } - - #endregion - - #region Properties - - /// - /// The list of frame locators. - /// The target Web element's locator is the last element of the frame locator list. - /// - public List Locators { get; } - - /// - /// Switch to DefaultContent first before switching to a frame. - /// - public bool StartFromDefaultContent { get; } - - #endregion - - #region Builder Methods - - /// - /// Constructs the Task. - /// - /// The frame locator list. - public static SwitchIntoNestedFrames To(List locators) => - new SwitchIntoNestedFrames(locators); - - /// - /// Constructs the Task. - /// - /// The frame locator list. - public static SwitchIntoNestedFrames WithoutUsingDefaultContentTo(List locators) => - new SwitchIntoNestedFrames(locators, false); - - #endregion - - #region Methods - - /// - /// Switch into frames to the last locator in the list. - /// - /// The Screenplay Actor. - public void PerformAs(IActor actor) - { - if (StartFromDefaultContent) - actor.AttemptsTo(SwitchFrame.ToDefaultContent()); - - foreach (IWebLocator locator in Locators) - actor.AttemptsTo(SwitchFrame.WithoutUsingDefaultContentTo(locator)); - } - - /// - /// Checks if this interaction is equal to another interaction. - /// - /// The other object. - public override bool Equals(object obj) => - obj is SwitchIntoNestedFrames frame && - Locators.Equals(frame.Locators); - - /// - /// Gets a unique hash code for this interaction. - /// - /// - public override int GetHashCode() => - HashCode.Combine(GetType(), Locators); - - /// - /// Returns a description of the Task. - /// - /// - public override string ToString() => - $"switch into nested frames to '{Locators.Last().Description}'"; - - #endregion - } -} From ce0717d82d69cdb2158f59b497d659c99ef3efee Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:38:48 -0500 Subject: [PATCH 8/9] Forgot to remove alpha from project --- Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj index 344f328..8eab3b0 100644 --- a/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj +++ b/Boa.Constrictor.Selenium/Boa.Constrictor.Selenium.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 4.1.0-alpha4 + 4.1.0 Pandy Knight and the PrecisionLender SETs Q2 Boa.Constrictor.Selenium From 85b95941e98d8b8005d0152a3fd668c4b05b569a Mon Sep 17 00:00:00 2001 From: Sarah Watkins <75698467+Swatkins18@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:29:24 -0500 Subject: [PATCH 9/9] Fix the Equals method for locator list --- Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs index f4a8977..ed303ee 100644 --- a/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs +++ b/Boa.Constrictor.Selenium/Tasks/SwitchFrame.cs @@ -111,7 +111,7 @@ public override void PerformAs(IActor actor, IWebDriver driver) /// The other object. public override bool Equals(object obj) => obj is SwitchFrame frame && - Locators.Equals(frame.Locators) && + Locators.SequenceEqual(frame.Locators) && StartFromCurrentLocation == frame.StartFromCurrentLocation && UseDefaultContent == frame.UseDefaultContent;