Skip to content

Commit

Permalink
NEW: upgrade selenium to 4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yashaka committed May 27, 2022
1 parent 86b43b8 commit 6692f61
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
## 1.0.0-alpha1x (to be released on 2021.05.??)
- deprecate the majority of Selene.* (except S, SS) when providing alternative API via Browser.*

## 1.0.0-alpha10 (to be released on 2022.05.27)
- upgraded Selenium.WebDriver from 3.141.0 to 4.2.0
- kept old-fashioned names for SeleneElement.GetAttribute & .GetProperty
but now under the hood they use new GetDomAttribute & GetDomProperty correspondingly
- added SeleneElement.GetShadowRoot as wrapper over WebElement.GetShadowRoot

## 1.0.0-alpha09 (to be released on 2021.05.19)
- improved error messages for cases of inner element search
- like error on S(".parent").Find(".child").Click() when .parent is absent or not visible
Expand Down
4 changes: 2 additions & 2 deletions NSelene/NSelene.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>NSelene</PackageId>
<Version>1.0.0-alpha09</Version>
<Version>1.0.0-alpha10</Version>
<Authors>yashaka</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright (c) 2015-2021 Iakiv Kramarenko</Copyright>
Expand Down Expand Up @@ -33,7 +33,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.2.0" />
</ItemGroup>

</Project>
25 changes: 23 additions & 2 deletions NSelene/SeleneElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ public bool Displayed

//
// IWebElement Methods
//
// TODO: do we really need these explicit interface implemantations? why?
// we might need only GetDomAttribute and GetDomProperty
// because we want to hide them from SeleneElement public API...
// so more lacontic versions (GetAttribute, GetProperty) can be used
//

void IWebElement.Clear()
Expand All @@ -705,16 +710,32 @@ void IWebElement.Click()
Click();
}

string IWebElement.GetDomAttribute(string attributeName)
{
return this.ActualWebElement.GetDomAttribute(attributeName);
}

string IWebElement.GetDomProperty(string propertyName)
{
return this.ActualWebElement.GetDomProperty(propertyName);
}

public string GetAttribute(string name)
{
Should(Be.InDom);
return this.ActualWebElement.GetAttribute(name);
return this.ActualWebElement.GetDomAttribute(name);
}

public string GetProperty (string propertyName)
{
Should(Be.InDom);
return this.ActualWebElement.GetProperty(propertyName);
return this.ActualWebElement.GetDomProperty(propertyName);
}

public ISearchContext GetShadowRoot ()
{
Should(Be.InDom);
return this.ActualWebElement.GetShadowRoot();
}

public string GetCssValue(string property)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class BrowserTest
public void initDriver()
{
new DriverManager().SetUpDriver(
// new ChromeConfig(), version: "Latest"
new ChromeConfig(), version: "89.0.4389.23"
new ChromeConfig(), version: "Latest"
// new ChromeConfig(), version: "89.0.4389.23"
);
var options = new ChromeOptions();
options.AddArguments("headless");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class BrowserTest
public void initDriver()
{
new DriverManager().SetUpDriver(
// new ChromeConfig(), version: "Latest"
new ChromeConfig(), version: "89.0.4389.23"
new ChromeConfig(), version: "Latest"
// new ChromeConfig(), version: "89.0.4389.23"
);
var options = new ChromeOptions();
options.AddArguments("headless");
Expand Down
4 changes: 2 additions & 2 deletions NSeleneTests/Integration/SharedDriver/Configuration_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class Configuration_Specs
public void InitConfiguration()
{
new DriverManager().SetUpDriver(
// new ChromeConfig(), version: "Latest"
new ChromeConfig(), version: "89.0.4389.23"
new ChromeConfig(), version: "Latest"
// new ChromeConfig(), version: "89.0.4389.23"
);

var options = new ChromeOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Clear_WaitsForVisibility_OfInitiialyAbsent()
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.6));
Expand Down Expand Up @@ -125,7 +125,7 @@ public void Clear_IsRenderedInError_OnAbsentElementFailure_WhenCustomizedToWaitF
// Assert.AreEqual(
// "",
// Configuration.Driver
// .FindElement(By.TagName("input")).GetProperty("value")
// .FindElement(By.TagName("input")).GetDomProperty("value")
// );
// }

Expand Down Expand Up @@ -158,7 +158,7 @@ public void Clear_WaitsForVisibility_OfInitialyHidden()
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.6));
Expand Down Expand Up @@ -199,7 +199,7 @@ public void Clear_IsRenderedInError_OnHiddenElementFailure()
Assert.AreEqual(
"abracadabra",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ public void Clear_IsRenderedInError_OnHiddenElementFailure_WhenCustomizedToWaitF
Assert.AreEqual(
"abracadabra",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -287,7 +287,7 @@ public void Clear_WorksUnderOverlay_ByDefault()
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down Expand Up @@ -341,7 +341,7 @@ public void Clear_Waits_For_NoOverlay_WhenCustomized()
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void DoubleClick_WaitsForVisibility_OfInitiialyAbsent()
<span ondblclick='window.location=this.href + ""#second""'>to h2</span>
<h2 id='second'>Heading 2</h2>
",
300
250
);

S("span").DoubleClick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void SendKeys_WaitsForVisibility_OfInitiialyAbsent()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.7));
Expand Down Expand Up @@ -102,7 +102,7 @@ public void SendKeys_PassesOnHiddenInputOfTypeFile()
StringAssert.Contains(
"empty.html",
Configuration.Driver
.FindElement(By.CssSelector("[type=file]")).GetProperty("value")
.FindElement(By.CssSelector("[type=file]")).GetDomProperty("value")
);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ public void SendKeys_WaitsForVisibility_OfInitialyHidden()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.7));
Expand Down Expand Up @@ -176,7 +176,7 @@ public void SendKeys_IsRenderedInError_OnHiddenElementFailure()
Assert.AreEqual(
"before ",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public void SendKeys_IsRenderedInError_OnHiddenElementFailure()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void SetValue_WaitsForVisibility_OfInitiialyAbsent()
Assert.AreEqual(
"overwritten",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.6));
Expand Down Expand Up @@ -147,7 +147,7 @@ public void SetValue_IsRenderedInError_OnAbsentElementFailure_WhenCustomizedToWa
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ public void SetValue_IsRenderedInError_OnAbsentElementFailure_WhenCustomizedToWa
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -226,7 +226,7 @@ public void SetValue_WaitsForVisibility_OfInitialyHidden()
Assert.AreEqual(
"overwritten",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.6));
Expand Down Expand Up @@ -267,7 +267,7 @@ public void SetValue_IsRenderedInError_OnHiddenElementFailure()
Assert.AreEqual(
"initial",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public void SetValue_IsRenderedInError_OnHiddenElementFailure_WhenCustomizedToWa
Assert.AreEqual(
"initial",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -355,7 +355,7 @@ public void SetValue_WorksUnderOverlay_ByDefault()
Assert.AreEqual(
"overwritten",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down Expand Up @@ -409,7 +409,7 @@ public void SetValue_WaitsForNoOverlay_WhenCustomized()
Assert.AreEqual(
"overwritten",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,7 @@ public void Submit_Fails_OnNonFormElement()

Assert.Contains("Reason:", lines);
Assert.Contains(
"no such element: Unable to locate element: "
+ "{\"method\":\"xpath\",\"selector\":\"./ancestor-or-self::form\"}"
,
"javascript error: Unable to find owning document",
lines
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Type_WaitsForVisibility_OfInitiialyAbsent()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.7));
Expand Down Expand Up @@ -118,7 +118,7 @@ public void Type_FailsOnHiddenInputOfTypeFile()
Assert.AreEqual(
"",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public void Type_WaitsForVisibility_OfInitialyHidden()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
Assert.Greater(afterCall, beforeCall.AddSeconds(0.3));
Assert.Less(afterCall, beforeCall.AddSeconds(0.7));
Expand Down Expand Up @@ -193,7 +193,7 @@ public void Type_IsRenderedInError_OnHiddenElementFailure()
Assert.AreEqual(
"before ",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public void Type_IsRenderedInError_OnHiddenElementFailure_WhenCustomizedToWaitFo
Assert.AreEqual(
"before ",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}
}
Expand Down Expand Up @@ -280,7 +280,7 @@ public void Type_WorksUnderOverlay_ByDefault()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down Expand Up @@ -334,7 +334,7 @@ public void Type_WaitsForNoOverlay_IfExplicitelyCustomized()
Assert.AreEqual(
"before and after",
Configuration.Driver
.FindElement(By.TagName("input")).GetProperty("value")
.FindElement(By.TagName("input")).GetDomProperty("value")
);
}

Expand Down
2 changes: 1 addition & 1 deletion NSeleneTests/NSeleneTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="WebDriverManager" Version="2.11.1" />
<PackageReference Include="WebDriverManager" Version="2.13.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 6692f61

Please sign in to comment.