Skip to content

Commit 80b193f

Browse files
committed
Fix an error which lead to fallback messages being used needlessly
The problem was that formatting the Lazy Selenium Element caused a new exception of its own, causing the fallback message to be used. This now catches those errors and handles them in a way that allows the proper message to be generated.
1 parent 9589dff commit 80b193f

21 files changed

Lines changed: 94 additions & 24 deletions

CSF.Screenplay.Selenium/Actions/ClearTheContents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ClearTheContents : ISingleElementPerformable
4646
{
4747
/// <inheritdoc/>
4848
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
49-
=> formatter.Format("{Actor} clears the contents of {Element}", actor.Name, element.Value);
49+
=> formatter.Format("{Actor} clears the contents of {Element}", actor.Name, element);
5050

5151
/// <inheritdoc/>
5252
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/Click.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Click : ISingleElementPerformable
4141
{
4242
/// <inheritdoc/>
4343
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
44-
=> formatter.Format("{Actor} clicks on {Element}", actor.Name, element.Value);
44+
=> formatter.Format("{Actor} clicks on {Element}", actor.Name, element);
4545

4646
/// <inheritdoc/>
4747
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/DeselectAll.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class DeselectAll : ISingleElementPerformable
4747
{
4848
/// <inheritdoc/>
4949
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
50-
=> formatter.Format("{Actor} deselects all of the options from {Element}", actor.Name, element.Value);
50+
=> formatter.Format("{Actor} deselects all of the options from {Element}", actor.Name, element);
5151

5252
/// <inheritdoc/>
5353
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/DeselectByIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class DeselectByIndex : ISingleElementPerformable
5050

5151
/// <inheritdoc/>
5252
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
53-
=> formatter.Format("{Actor} deselects option {Index} (zero-based) from {Element}", actor.Name, index, element.Value);
53+
=> formatter.Format("{Actor} deselects option {Index} (zero-based) from {Element}", actor.Name, index, element);
5454

5555
/// <inheritdoc/>
5656
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/DeselectByText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class DeselectByText : ISingleElementPerformable
5050

5151
/// <inheritdoc/>
5252
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
53-
=> formatter.Format("{Actor} deselects '{Text}' from {Element}", actor.Name, text, element.Value);
53+
=> formatter.Format("{Actor} deselects '{Text}' from {Element}", actor.Name, text, element);
5454

5555
/// <inheritdoc/>
5656
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/DeselectByValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class DeselectByValue : ISingleElementPerformable
5050

5151
/// <inheritdoc/>
5252
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
53-
=> formatter.Format("{Actor} deselects the option with value {Value} from {Element}", actor.Name, value, element.Value);
53+
=> formatter.Format("{Actor} deselects the option with value {Value} from {Element}", actor.Name, value, element);
5454

5555
/// <inheritdoc/>
5656
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/SelectByIndex.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SelectByIndex : ISingleElementPerformable
5959

6060
/// <inheritdoc/>
6161
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
62-
=> formatter.Format("{Actor} selects option {Index} (zero-based) from {Element}", actor.Name, index, element.Value);
62+
=> formatter.Format("{Actor} selects option {Index} (zero-based) from {Element}", actor.Name, index, element);
6363

6464
/// <inheritdoc/>
6565
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/SelectByText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SelectByText : ISingleElementPerformable
5959

6060
/// <inheritdoc/>
6161
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
62-
=> formatter.Format("{Actor} selects '{Text}' from {Element}", actor.Name, text, element.Value);
62+
=> formatter.Format("{Actor} selects '{Text}' from {Element}", actor.Name, text, element);
6363

6464
/// <inheritdoc/>
6565
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/SelectByValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SelectByValue : ISingleElementPerformable
5959

6060
/// <inheritdoc/>
6161
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
62-
=> formatter.Format("{Actor} selects the option with value {Value} from {Element}", actor.Name, value, element.Value);
62+
=> formatter.Format("{Actor} selects the option with value {Value} from {Element}", actor.Name, value, element);
6363

6464
/// <inheritdoc/>
6565
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

CSF.Screenplay.Selenium/Actions/SendKeys.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class SendKeys : ISingleElementPerformable
5353

5454
/// <inheritdoc/>
5555
public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)
56-
=> formatter.Format("{Actor} enters the text '{Text}' into {Element}", actor.Name, text, element.Value);
56+
=> formatter.Format("{Actor} enters the text '{Text}' into {Element}", actor.Name, text, element);
5757

5858
/// <inheritdoc/>
5959
public ValueTask PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

0 commit comments

Comments
 (0)