Skip to content

Commit 3c74f07

Browse files
committed
[dotnet] Fixing SelectTests.cs
1 parent 65b5ff3 commit 3c74f07

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

dotnet/test/support/UI/SelectTests.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void CanSetSingleOptionSelectedByText()
109109
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
110110
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
111111
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
112+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
112113
option1.Setup(_ => _.Click());
113114
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
114115

@@ -128,6 +129,7 @@ public void CanSetSingleOptionSelectedByValue()
128129
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
129130
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
130131
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
132+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
131133
option1.Setup(_ => _.Click());
132134
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
133135

@@ -148,6 +150,7 @@ public void CanSetSingleOptionSelectedByIndex()
148150
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns((string)null);
149151
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
150152
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
153+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
151154
option1.Setup(_ => _.Click());
152155
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
153156

@@ -170,8 +173,10 @@ public void CanSetMultipleOptionSelectedByText()
170173
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
171174
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
172175
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
176+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
173177
option1.Setup(_ => _.Click());
174178
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
179+
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
175180
option2.Setup(_ => _.Click());
176181
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
177182

@@ -195,8 +200,10 @@ public void CanSetMultipleOptionSelectedByValue()
195200
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
196201
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
197202
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
203+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
198204
option1.Setup(_ => _.Click());
199205
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
206+
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
200207
option2.Setup(_ => _.Click());
201208
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
202209

@@ -219,17 +226,19 @@ public void CanSetMultipleOptionSelectedByIndex()
219226

220227
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
221228
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
222-
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
229+
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
223230
option1.SetupGet<bool>(_ => _.Selected).Returns(false);
231+
option1.SetupGet<bool>(_ => _.Enabled).Returns(true);
224232
option1.Setup(_ => _.Click());
225233
option2.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
226234
option2.SetupGet<bool>(_ => _.Selected).Returns(false);
235+
option2.SetupGet<bool>(_ => _.Enabled).Returns(true);
227236
option2.Setup(_ => _.Click());
228237
webElement.Setup(_ => _.FindElements(It.IsAny<By>())).Returns(new ReadOnlyCollection<IWebElement>(options)).Verifiable();
229238

230239
new SelectElement(webElement.Object).SelectByIndex(2);
231-
option1.Verify(_ => _.Selected, Times.Once);
232-
option1.Verify(_ => _.Click(), Times.Once);
240+
option1.Verify(_ => _.Selected, Times.Never);
241+
option1.Verify(_ => _.Click(), Times.Never);
233242
option1.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
234243
option2.Verify(_ => _.Selected, Times.Once);
235244
option2.Verify(_ => _.Click(), Times.Once);
@@ -352,7 +361,7 @@ public void CanDeselectMultipleOptionSelectedByIndex()
352361

353362
webElement.SetupGet<string>(_ => _.TagName).Returns("select");
354363
webElement.Setup(_ => _.GetAttribute(It.Is<string>(x => x == "multiple"))).Returns("true");
355-
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
364+
option1.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("1");
356365
option1.SetupGet<bool>(_ => _.Selected).Returns(true);
357366
option1.Setup(_ => _.Click());
358367
option2.Setup<string>(_ => _.GetAttribute(It.IsAny<string>())).Returns("2");
@@ -362,8 +371,8 @@ public void CanDeselectMultipleOptionSelectedByIndex()
362371

363372
new SelectElement(webElement.Object).DeselectByIndex(2);
364373
option1.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
365-
option1.Verify(_ => _.Selected, Times.Once);
366-
option1.Verify(_ => _.Click(), Times.Once);
374+
option1.Verify(_ => _.Selected, Times.Never);
375+
option1.Verify(_ => _.Click(), Times.Never);
367376
option2.Verify(_ => _.GetAttribute(It.IsAny<string>()), Times.Once);
368377
option2.Verify(_ => _.Selected, Times.Once);
369378
option2.Verify(_ => _.Click(), Times.Once);

0 commit comments

Comments
 (0)