Skip to content

Commit d318249

Browse files
quigamdevcafour
authored andcommitted
Fixed collection selectorMethod references
1 parent a0a6602 commit d318249

File tree

4 files changed

+68
-23
lines changed

4 files changed

+68
-23
lines changed

src/Core/Riganti.Selenium.Core/ElementWrapperCollection.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ private void SetReferences(List<TElement> elms, string selector, Func<string, By
100100
foreach (var ew in elms)
101101
{
102102
ew.Selector = selector;
103-
ew.SelectMethod = selectMethod;
104103
ew.ParentWrapper = this;
105104
}
106105
}
106+
/// <summary>
107+
/// Throws exception when collection of elements does not contain any elements.
108+
/// </summary>
107109
public IElementWrapperCollection<TElement, TBrowser> ThrowIfSequenceEmpty()
108110
{
109111
if (!GetCollection().Any())
@@ -113,6 +115,9 @@ public IElementWrapperCollection<TElement, TBrowser> ThrowIfSequenceEmpty()
113115
return this;
114116
}
115117

118+
/// <summary>
119+
/// Throws exception when collection of elements does contain more then one element.
120+
/// </summary>
116121
public IElementWrapperCollection<TElement, TBrowser> ThrowIfSequenceContainsMoreThanOneElement()
117122
{
118123
if (Count > 1)
@@ -122,7 +127,7 @@ public IElementWrapperCollection<TElement, TBrowser> ThrowIfSequenceContainsMore
122127
return this;
123128
}
124129
/// <summary>
125-
/// Throws exception when lenght of a sequence is empty or the sequence contains more than one element.
130+
/// Throws exception when length of a sequence is empty or the sequence contains more than one element.
126131
/// </summary>
127132
/// <returns></returns>
128133
public IElementWrapperCollection<TElement, TBrowser> ThrowIfEmptyOrMoreThanOne()
@@ -287,7 +292,7 @@ public TElement FirstOrDefault(string selector, Func<string, By> tmpSelectMethod
287292
IElementWrapperCollection<TElement1, TBrowser1> ISeleniumWrapperCollection.Convert<TElement1, TBrowser1>()
288293
{
289294
return new ElementWrapperCollection<TElement1, TBrowser1>(() => GetCollection().Cast<TElement1>(),
290-
Selector, SelectMethod ,BrowserWrapper, ParentWrapper);
295+
Selector, SelectMethod, BrowserWrapper, ParentWrapper);
291296
}
292297
}
293298
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
<div id="displayed">
2-
visible element
3-
<div>
4-
<p>
5-
a
6-
</p>
7-
<p>
8-
b
9-
<span></span>
10-
</p>
11-
<p>
12-
c
13-
<span>
14-
This is what I want.
15-
</span>
16-
</p>
17-
</div>
2+
visible element
3+
<div>
4+
<p>
5+
a
6+
</p>
7+
<p>
8+
b
9+
<span></span>
10+
</p>
11+
<p>
12+
c
13+
<span>
14+
This is what I want.
15+
</span>
16+
</p>
17+
</div>
1818
</div>
1919
<div id="non-displayed" style="display: none;">
20-
Invisible element
20+
Invisible element
2121
</div>
2222
<div id="displayed-zero-draw-rec" style="width: 0px;height: 0px">
23-
Invisible element
23+
Invisible element
2424
</div>
2525

2626
<div id="content" class="test">
27-
Lorem Ipsum je demonstrativní výplňový text používaný v tiskařském a knihařském průmyslu. Lorem Ipsum je považováno za standard v této oblasti už od začátku 16. století, kdy dnes neznámý tiskař vzal kusy textu a na jejich základě vytvořil speciální vzorovou knihu. Jeho odkaz nevydržel pouze pět století, on přežil i nástup elektronické sazby v podstatě beze změny. Nejvíce popularizováno bylo Lorem Ipsum v šedesátých letech 20. století, kdy byly vydávány speciální vzorníky s jeho pasážemi a později pak díky počítačovým DTP programům jako Aldus PageMaker.
27+
Lorem Ipsum je demonstrativní výplňový text používaný v tiskařském a knihařském průmyslu. Lorem Ipsum je považováno za standard v této oblasti už od začátku 16. století, kdy dnes neznámý tiskař vzal kusy textu a na jejich základě vytvořil speciální vzorovou knihu. Jeho odkaz nevydržel pouze pět století, on přežil i nástup elektronické sazby v podstatě beze změny. Nejvíce popularizováno bylo Lorem Ipsum v šedesátých letech 20. století, kdy byly vydávány speciální vzorníky s jeho pasážemi a později pak díky počítačovým DTP programům jako Aldus PageMaker.
2828
</div>
2929

3030
<button id="dis-button" disabled>disabled button</button>
31-
<input id="submit-button" type="submit" value="Submit Button Test" />
31+
<input id="submit-button" type="submit" value="Submit Button Test" />
32+
33+
<div data-ui="selector-test">
34+
<span data-ui="selector-test-inner"></span>
35+
</div>

src/Tests/Riganti.Selenium.Core.Samples.Assert.Tests/ScrollToTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ public void ScrollToChild()
2626
}
2727
}
2828

29+
2930
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using OpenQA.Selenium;
2+
using Riganti.Selenium.AssertApi;
3+
using System.Security.Principal;
4+
using Xunit;
5+
using Xunit.Abstractions;
6+
7+
namespace Riganti.Selenium.Core.Samples.AssertApi.Tests
8+
{
9+
10+
public class SelectorsTests : AppSeleniumTest
11+
{
12+
public SelectorsTests(ITestOutputHelper output) : base(output)
13+
{
14+
15+
}
16+
public By SelectByDataUi(string selector)
17+
=> SelectBy.CssSelector($"[data-ui='{selector}']");
18+
19+
[Fact]
20+
public void SelectByCssSelectorTest()
21+
{
22+
RunInAllBrowsers(browser =>
23+
{
24+
browser.NavigateToUrl("/test/Index");
25+
26+
var div = browser.Single("selector-test", SelectByDataUi);
27+
var span = div.Single("span");
28+
});
29+
}
30+
31+
32+
}
33+
34+
35+
}

0 commit comments

Comments
 (0)