Skip to content

Commit ac318a9

Browse files
committed
Use Has.Exactly(x).Items instead of Has.Count.EqualTo(x)
1 parent a249411 commit ac318a9

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

dotnet/test/common/AlertsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public void ShouldNotHandleAlertInAnotherWindow()
412412
driver.FindElement(By.Id("open-new-window")).Click();
413413
List<String> allWindows = new List<string>(driver.WindowHandles);
414414
allWindows.Remove(mainWindow);
415-
Assert.That(allWindows, Has.Count.EqualTo(1));
415+
Assert.That(allWindows, Has.One.Items);
416416
onloadWindow = allWindows[0];
417417

418418
Assert.That(() =>

dotnet/test/common/ChildrenFindingTest.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void FindingElementsOnElementByXPathShouldFindTopLevelElements()
4141
IWebElement parent = driver.FindElement(By.Id("multiline"));
4242
ReadOnlyCollection<IWebElement> allParaElements = driver.FindElements(By.XPath("//p"));
4343
ReadOnlyCollection<IWebElement> children = parent.FindElements(By.XPath("//p"));
44-
Assert.That(children, Has.Count.EqualTo(allParaElements.Count));
44+
Assert.That(children, Has.Exactly(allParaElements.Count).Items);
4545
}
4646

4747
[Test]
@@ -51,7 +51,7 @@ public void FindingDotSlashElementsOnElementByXPathShouldFindNotTopLevelElements
5151
IWebElement parent = driver.FindElement(By.Id("multiline"));
5252

5353
ReadOnlyCollection<IWebElement> children = parent.FindElements(By.XPath("./p"));
54-
Assert.That(children, Has.Count.EqualTo(1));
54+
Assert.That(children, Has.One.Items);
5555
Assert.That(children[0].Text, Is.EqualTo("A div containing"));
5656
}
5757

@@ -73,7 +73,7 @@ public void FindElementsByXPath()
7373
IWebElement element = driver.FindElement(By.Name("form2"));
7474

7575
ReadOnlyCollection<IWebElement> children = element.FindElements(By.XPath("select/option"));
76-
Assert.That(children, Has.Count.EqualTo(8));
76+
Assert.That(children, Has.Exactly(8).Items);
7777
Assert.Multiple(() =>
7878
{
7979
Assert.That(children[0].Text, Is.EqualTo("One"));
@@ -106,7 +106,7 @@ public void FindElementsByName()
106106
IWebElement element = driver.FindElement(By.Name("form2"));
107107

108108
ReadOnlyCollection<IWebElement> children = element.FindElements(By.Name("selectomatic"));
109-
Assert.That(children, Has.Count.EqualTo(2));
109+
Assert.That(children, Has.Exactly(2).Items);
110110
}
111111

112112
[Test]
@@ -159,7 +159,7 @@ public void FindElementsById()
159159
driver.Url = nestedPage;
160160
IWebElement element = driver.FindElement(By.Name("form2"));
161161
ReadOnlyCollection<IWebElement> children = element.FindElements(By.Id("2"));
162-
Assert.That(children, Has.Count.EqualTo(2));
162+
Assert.That(children, Has.Exactly(2).Items);
163163
}
164164

165165
[Test]
@@ -168,9 +168,9 @@ public void FindElementsByIdWithNonAlphanumericCharacters()
168168
driver.Url = nestedPage;
169169
IWebElement element = driver.FindElement(By.Id("test_special_chars"));
170170
ReadOnlyCollection<IWebElement> children = element.FindElements(By.Id("white space"));
171-
Assert.That(children, Has.Count.EqualTo(1));
171+
Assert.That(children, Has.One.Items);
172172
ReadOnlyCollection<IWebElement> children2 = element.FindElements(By.Id("css#.chars"));
173-
Assert.That(children2, Has.Count.EqualTo(1));
173+
Assert.That(children2, Has.One.Items);
174174
}
175175

176176
[Test]
@@ -191,7 +191,7 @@ public void FindElementsByLinkText()
191191
IWebElement element = driver.FindElement(By.Name("div1"));
192192
ReadOnlyCollection<IWebElement> elements = element.FindElements(By.LinkText("hello world"));
193193

194-
Assert.That(elements, Has.Count.EqualTo(2));
194+
Assert.That(elements, Has.Exactly(2).Items);
195195
Assert.That(elements[0].GetAttribute("name"), Is.EqualTo("link1"));
196196
Assert.That(elements[1].GetAttribute("name"), Is.EqualTo("link2"));
197197
}
@@ -237,7 +237,7 @@ public void ShouldFindChildrenByClassName()
237237

238238
ReadOnlyCollection<IWebElement> elements = parent.FindElements(By.ClassName("one"));
239239

240-
Assert.That(elements, Has.Count.EqualTo(2));
240+
Assert.That(elements, Has.Exactly(2).Items);
241241
}
242242

243243

@@ -261,7 +261,7 @@ public void ShouldFindChildrenByTagName()
261261

262262
ReadOnlyCollection<IWebElement> elements = parent.FindElements(By.TagName("a"));
263263

264-
Assert.That(elements, Has.Count.EqualTo(2));
264+
Assert.That(elements, Has.Exactly(2).Items);
265265
}
266266

267267
[Test]
@@ -294,7 +294,7 @@ public void ShouldBeAbleToFindElementsByCssSelector()
294294

295295
ReadOnlyCollection<IWebElement> elements = parent.FindElements(By.CssSelector("*[name=\"selectomatic\"]"));
296296

297-
Assert.That(elements, Has.Count.EqualTo(2));
297+
Assert.That(elements, Has.Exactly(2).Items);
298298
}
299299

300300
[Test]
@@ -305,7 +305,7 @@ public void ShouldBeAbleToFindChildrenOfANode()
305305
IWebElement head = elements[0];
306306

307307
ReadOnlyCollection<IWebElement> importedScripts = head.FindElements(By.TagName("script"));
308-
Assert.That(importedScripts, Has.Count.EqualTo(3));
308+
Assert.That(importedScripts, Has.Exactly(3).Items);
309309
}
310310

311311
[Test]
@@ -342,8 +342,8 @@ public void FindingByTagNameShouldNotIncludeParentElementIfSameTagType()
342342
driver.Url = xhtmlTestPage;
343343
IWebElement parent = driver.FindElement(By.Id("my_span"));
344344

345-
Assert.That(parent.FindElements(By.TagName("div")), Has.Count.EqualTo(2));
346-
Assert.That(parent.FindElements(By.TagName("span")), Has.Count.EqualTo(2));
345+
Assert.That(parent.FindElements(By.TagName("div")), Has.Exactly(2).Items);
346+
Assert.That(parent.FindElements(By.TagName("span")), Has.Exactly(2).Items);
347347
}
348348

349349
[Test]
@@ -364,7 +364,7 @@ public void FindMultipleElements()
364364

365365
ReadOnlyCollection<IWebElement> elements = elem.FindElements(By.PartialLinkText("link"));
366366
Assert.That(elements, Is.Not.Null);
367-
Assert.That(elements, Has.Count.EqualTo(6));
367+
Assert.That(elements, Has.Exactly(6).Items);
368368
}
369369

370370
[Test]

0 commit comments

Comments
 (0)