Skip to content

Commit b4ed35f

Browse files
authored
Merge pull request #105 from quantori/BAP-122-add-FindSubElement-to-IWebElementWrapper
Added FindSubElement interface member to IWebElementWrapper
2 parents d748c00 + 7742461 commit b4ed35f

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

Behavioral.Automation.DemoBindings/Elements/WebElementWrapper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ private IEnumerable<IWebElementWrapper> ElementsToWrappers(IEnumerable<IWebEleme
102102
}
103103
}
104104

105+
public IWebElementWrapper FindSubElement(By locator, string caption)
106+
{
107+
var element = Assert.ShouldGet(() => Element.FindElement(locator));
108+
return new WebElementWrapper(() => element, caption, _driverService);
109+
}
110+
105111
protected IDriverService Driver => _driverService;
106112

107113
private bool AriaEnabled

Behavioral.Automation.Template/Behavioral.Automation.Template.Bindings/Behavioral.Automation.Template.Bindings.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Behavioral.Automation" Version="1.8.0" />
12+
<PackageReference Include="Behavioral.Automation" Version="1.9.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

Behavioral.Automation.Template/Behavioral.Automation.Template.Bindings/ElementWrappers/WebElementWrapper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public IEnumerable<IWebElementWrapper> FindSubElements(By locator, string captio
128128
}
129129
}
130130

131+
public IWebElementWrapper FindSubElement(By locator, string caption)
132+
{
133+
var element = Assert.ShouldGet(() => Element.FindElement(locator));
134+
return new WebElementWrapper(() => element, caption, Driver);
135+
}
136+
131137
private IEnumerable<IWebElementWrapper> ElementsToWrappers(IEnumerable<IWebElement> elements, string caption)
132138
{
133139
return elements.Select(element => new WebElementWrapper(() => element, caption, Driver));

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
[1.8.7] - 2022-02-25
8-
- Moved tooltip attribute to separate interface
7+
[1.9.0] - 2022-04-22
8+
- Added FindSubElement method to IWebElementWrapper

src/Behavioral.Automation/Behavioral.Automation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The whole automation code is divided into the following parts:
1616
- UI structure descriptive code
1717
- Supportive code</Description>
1818
<Copyright>Quantori Inc.</Copyright>
19-
<PackageVersion>1.8.7</PackageVersion>
19+
<PackageVersion>1.9.0</PackageVersion>
2020
<RepositoryUrl>https://github.com/quantori/Behavioral.Automation</RepositoryUrl>
2121
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2222
<IncludeSymbols>true</IncludeSymbols>

src/Behavioral.Automation/Elements/IWebElementWrapper.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public interface IWebElementWrapper
4949
/// <returns></returns>
5050
public IEnumerable<IWebElementWrapper> FindSubElements([NotNull] By locator, [CanBeNull] string caption);
5151

52+
/// <summary>
53+
/// Nested Element inside current web element
54+
/// </summary>
55+
/// <param name="locator">mechanism of finding nested element using <see cref="By"/> class object</param>
56+
/// <param name="caption">element caption</param>
57+
/// <returns></returns>
58+
public IWebElementWrapper FindSubElement([NotNull] By locator, [CanBeNull] string caption);
59+
5260
/// <summary>
5361
/// Sends given text symbol by symbol, including special symbols. See <see cref="Keys"/>
5462
/// </summary>

src/Behavioral.Automation/FluentAssertions/Assert.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private static T TryGetValue<T>(Func<T> getValue, TimeSpan wait, int attempts =
112112
{
113113
return getValue();
114114
}
115-
catch (StaleElementReferenceException)
115+
catch (Exception e) when (e is StaleElementReferenceException || e is NoSuchElementException)
116116
{
117117
Thread.Sleep(wait);
118118
if (counter++ == attempts)

0 commit comments

Comments
 (0)