Skip to content

Commit

Permalink
[#101] TEST: fix tests to pass on CI - try 2 + ...
Browse files Browse the repository at this point in the history
... update LangVersion to 11.0
  • Loading branch information
yashaka committed Sep 7, 2024
1 parent e368d06 commit f08003e
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 256 deletions.
1 change: 1 addition & 0 deletions NSelene/NSelene.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<PackageId>NSelene</PackageId>
<Version>1.0.0-alpha14</Version>
<Authors>yashaka</Authors>
Expand Down
2 changes: 1 addition & 1 deletion NSelene/SeleneElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private IWebElement ActualNotOverlappedWebElement {
? $": {webElement.GetAttribute("outerHTML")}"
: ""
) // TODO: ... while not applied here?
+ $"\n\tis overlapped by: {cover.GetAttribute("outerHTML")}"
+ $"\n is overlapped by: {cover.GetAttribute("outerHTML")}"
);
}
return webElement;
Expand Down
12 changes: 6 additions & 6 deletions NSelene/Wait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ private _Result<R> _For<R>(_Computation<T, R> computation) // TODO: should we ac
// TODO: should we move this error formatting to the Error class definition?
var describedLambda = this.describeComputation(computation.ToString());
var failure = new TimeoutException(
"\n"
+ $"Timed out after {this.timeout}s, while waiting for:\n"
+ $"\t{this.entity}.{describedLambda}\n" // TODO: handle trailing spaces
+ "Reason:\n"
+ $"\t{error.Message}" // TODO: error.Message or error?
,
$$"""
Timed out after {{this.timeout}}s, while waiting for:
{{this.entity}}.{{describedLambda}}
Reason:
{{error.Message}}
""",
error
);

Expand Down
24 changes: 12 additions & 12 deletions NSeleneTests/Integration/SharedDriver/ErrorMessages_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void SeleneElement_Click_Failure_OnHiddenElement()

catch (TimeoutException error)
{
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(a).ActualWebElement.Click()
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(a).ActualWebElement.Click()
Reason:
element not interactable
element not interactable
""".Trim()
));
}
Expand All @@ -61,11 +61,11 @@ public void SeleneElement_CustomizedToJsClick_Click_Failure_OnAbsentInDomElement
S("a").With(clickByJs: true).Click();
Assert.Fail("should fail on timeout before can be clicked");
} catch (TimeoutException error) {
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(a).JsClick(centerXOffset: 0, centerYOffset: 0)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(a).JsClick(centerXOffset: 0, centerYOffset: 0)
Reason:
no such element: Unable to locate element: {"method":"css selector","selector":"a"}
no such element: Unable to locate element: {"method":"css selector","selector":"a"}
""".Trim()
));
}
Expand All @@ -91,11 +91,11 @@ public void SeleneElement_JsClick_Failure_OnAbsentInDomElement()
S("a").JsClick();
Assert.Fail("should fail before can be js-clicked");
} catch (TimeoutException error) {
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(a).JsClick(centerXOffset: 0, centerYOffset: 0)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(a).JsClick(centerXOffset: 0, centerYOffset: 0)
Reason:
no such element: Unable to locate element: {"method":"css selector","selector":"a"}
no such element: Unable to locate element: {"method":"css selector","selector":"a"}
""".Trim()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public void SeleneWaitTo_HaveJsReturned_IsRenderedInError_OnAbsentElementTimeout
Assert.Greater(afterCall, beforeCall.AddSeconds(0.25));
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(JSReturnedTrue)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(JSReturnedTrue)
""".Trim()
));
}
Expand Down Expand Up @@ -165,9 +165,9 @@ public void SeleneWaitTo_HaveNoJsReturned_IsRenderedInError_OnInDomElementsTimeo
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(Not.JSReturnedTrue)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(Not.JSReturnedTrue)
""".Trim()
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ public void Should_HaveCount_IsRenderedInError_OnAbsentElementTimeoutFailure()
var lines = error.Message.Split("\n").Select(
item => item.Trim()
).ToList();
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.All(p).Should(count = 2)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.All(p).Should(count = 2)
Reason:
actual: count = 0
actual: count = 0
""".Trim()
));
}
Expand Down Expand Up @@ -125,11 +125,11 @@ public void Should_HaveNoCount_IsRenderedInError_OnInDomElementsTimeoutFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.All(p).Should(Not.count = 2)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.All(p).Should(Not.count = 2)
Reason:
condition not matched
condition not matched
""".Trim()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public void Should_HaveValue_IsRenderedInError_OnAbsentElementTimeoutFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(input).Should(Have.Attribute(value='initial'))
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(input).Should(Have.Attribute(value='initial'))
Reason:
no such element: Unable to locate element: {"method":"css selector","selector":"input"}
no such element: Unable to locate element: {"method":"css selector","selector":"input"}
""".Trim()
));
}
Expand Down Expand Up @@ -125,11 +125,11 @@ public void Should_HaveNoValue_IsRenderedInError_OnInDomElementTimeoutFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(input).Should(Not.Have.Attribute(value='initial'))
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(input).Should(Not.Have.Attribute(value='initial'))
Reason:
condition not matched
condition not matched
""".Trim()
));
}
Expand Down Expand Up @@ -223,11 +223,11 @@ public void Should_HaveText_IsRenderedInError_OnHiddenElementFailure()
item => item.Trim()
).ToList();

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(label).Should(Have.TextContaining(«initial»))
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(label).Should(Have.TextContaining(«initial»))
Reason:
Actual text: «»
Actual text: «»
Actual webelement: <label style="display:none">initial</label>
""".Trim()
));
Expand Down Expand Up @@ -359,11 +359,11 @@ public void Should_BeVisible_IsRenderedInError_OnHiddenInDomElementFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(label).Should(Visible)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(label).Should(Visible)
Reason:
actual: False
actual: False
""".Trim()
));

Expand Down Expand Up @@ -391,11 +391,11 @@ public void Should_BeNotVisible_IsRenderedInError_OnVisibleElementFailure()

catch (TimeoutException error)
{
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(label).Should(Not.Visible)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(label).Should(Not.Visible)
Reason:
condition not matched
condition not matched
""".Trim()
));

Expand Down Expand Up @@ -425,11 +425,11 @@ public void Should_BeVisible_IsRenderedInError_OnAbsentInDomElementFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(label).Should(Visible)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(label).Should(Visible)
Reason:
no such element: Unable to locate element: {"method":"css selector","selector":"label"}
no such element: Unable to locate element: {"method":"css selector","selector":"label"}
""".Trim()
));
}
Expand All @@ -453,11 +453,11 @@ public void Should_HaveText_IsRenderedInError_OnElementDifferentTextFailure()

catch (TimeoutException error)
{
Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.Element(label).Should(Have.TextContaining(«new»))
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.Element(label).Should(Have.TextContaining(«new»))
Reason:
Actual text: «initial»
Actual text: «initial»
Actual webelement: <label>initial</label>
""".Trim()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public void SeleneWaitTo_HaveJsReturned_IsRenderedInError_OnAbsentElementTimeout
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(JSReturnedTrue)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(JSReturnedTrue)
""".Trim()
));
}
Expand Down Expand Up @@ -166,9 +166,9 @@ public void SeleneWaitTo_HaveNoJsReturned_IsRenderedInError_OnInDomElementsTimeo
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(Not.JSReturnedTrue)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
OpenQA.Selenium.Chrome.ChromeDriver.Should(Not.JSReturnedTrue)
""".Trim()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void Should_HaveCount_IsRenderedInError_OnAbsentElementTimeoutFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.All(p).Should(Have.Count = 2)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.All(p).Should(Have.Count = 2)
Reason:
actual: Have.Count = 0
actual: Have.Count = 0
""".Trim()
));
}
Expand Down Expand Up @@ -121,11 +121,11 @@ public void Should_HaveNoCount_IsRenderedInError_OnInDomElementsTimeoutFailure()
var accuracyDelta = 0.2;
Assert.Less(afterCall, beforeCall.AddSeconds(0.25 + 0.1 + accuracyDelta));

Assert.That(error.Message.Trim(), Does.Contain("""
Timed out after 0.25s, while waiting for:
Browser.All(p).Should(Not.Have.Count = 2)
Assert.That(error.Message.Trim(), Does.Contain($$"""
Timed out after {{0.25}}s, while waiting for:
Browser.All(p).Should(Not.Have.Count = 2)
Reason:
condition not matched
condition not matched
""".Trim()
));
}
Expand Down
Loading

0 comments on commit f08003e

Please sign in to comment.