Skip to content

Commit c7d36d9

Browse files
committed
Updating .NET bindings tests to reflect current W3C specification
1 parent 7c33c5c commit c7d36d9

File tree

7 files changed

+85
-40
lines changed

7 files changed

+85
-40
lines changed

dotnet/test/common/ElementFindingTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ public void FindingASingleElementByInvalidClassNameShouldThrow()
325325
}
326326

327327
[Test]
328+
[IgnoreBrowser(Browser.IE, "Class name is perfectly legal when using CSS selector, if properly escaped.")]
329+
[IgnoreBrowser(Browser.Firefox, "Class name is perfectly legal when using CSS selector, if properly escaped.")]
328330
[IgnoreBrowser(Browser.Chrome, "Throws WebDriverException")]
329331
[IgnoreBrowser(Browser.Opera, "Throws WebDriverException")]
330332
public void FindingMultipleElementsByInvalidClassNameShouldThrow()

dotnet/test/common/FormHandlingTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public void ShouldBeAbleToClearTextFromTextAreas()
298298
}
299299

300300
[Test]
301+
[IgnoreBrowser(Browser.IE, "Hangs")]
301302
[IgnoreBrowser(Browser.Android, "Untested")]
302303
[IgnoreBrowser(Browser.HtmlUnit, "Untested")]
303304
[IgnoreBrowser(Browser.IPhone, "Untested")]

dotnet/test/common/Interactions/BasicKeyboardInterfaceTest.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ namespace OpenQA.Selenium.Interactions
55
[TestFixture]
66
public class BasicKeyboardInterfaceTest : DriverTestFixture
77
{
8+
[SetUp]
9+
public void Setup()
10+
{
11+
new Actions(driver).SendKeys(Keys.Null).Perform();
12+
}
13+
14+
[TearDown]
15+
public void ReleaseModifierKeys()
16+
{
17+
new Actions(driver).SendKeys(Keys.Null).Perform();
18+
}
19+
820
[Test]
921
[IgnoreBrowser(Browser.IPhone, "API not implemented in driver")]
1022
[IgnoreBrowser(Browser.Remote, "API not implemented in driver")]
@@ -52,7 +64,6 @@ public void ShouldAllowSendingKeyDownOnly()
5264
}
5365

5466
[Test]
55-
[IgnoreBrowser(Browser.IE, "API not implemented in driver")]
5667
[IgnoreBrowser(Browser.Firefox, "API not implemented in driver")]
5768
[IgnoreBrowser(Browser.Chrome, "API not implemented in driver")]
5869
[IgnoreBrowser(Browser.IPhone, "API not implemented in driver")]
@@ -64,16 +75,15 @@ public void ShouldAllowSendingKeyUp()
6475
driver.Url = javascriptPage;
6576
IWebElement keysEventInput = driver.FindElement(By.Id("theworks"));
6677

67-
Actions actionProvider = new Actions(driver);
68-
IAction pressShift = actionProvider.KeyDown(keysEventInput, Keys.Shift).Build();
78+
IAction pressShift = new Actions(driver).KeyDown(keysEventInput, Keys.Shift).Build();
6979
pressShift.Perform();
7080

7181
IWebElement keyLoggingElement = driver.FindElement(By.Id("result"));
7282

7383
string eventsText = keyLoggingElement.Text;
7484
Assert.IsTrue(keyLoggingElement.Text.EndsWith("keydown"), "Key down should be isolated for this test to be meaningful. Event text should end with 'keydown', got events: " + eventsText);
7585

76-
IAction releaseShift = actionProvider.KeyUp(keysEventInput, Keys.Shift).Build();
86+
IAction releaseShift = new Actions(driver).KeyUp(keysEventInput, Keys.Shift).Build();
7787

7888
releaseShift.Perform();
7989

@@ -82,7 +92,6 @@ public void ShouldAllowSendingKeyUp()
8292
}
8393

8494
[Test]
85-
[IgnoreBrowser(Browser.IE, "API not implemented in driver")]
8695
[IgnoreBrowser(Browser.Firefox, "API not implemented in driver")]
8796
[IgnoreBrowser(Browser.Chrome, "API not implemented in driver")]
8897
[IgnoreBrowser(Browser.IPhone, "API not implemented in driver")]
@@ -97,14 +106,13 @@ public void ShouldAllowSendingKeysWithShiftPressed()
97106

98107
keysEventInput.Click();
99108

100-
Actions actionProvider = new Actions(driver);
101-
IAction pressShift = actionProvider.KeyDown(keysEventInput, Keys.Shift).Build();
109+
IAction pressShift = new Actions(driver).KeyDown(Keys.Shift).Build();
102110
pressShift.Perform();
103111

104-
IAction sendLowercase = actionProvider.SendKeys(keysEventInput, "ab").Build();
112+
IAction sendLowercase = new Actions(driver).SendKeys("ab").Build();
105113
sendLowercase.Perform();
106114

107-
IAction releaseShift = actionProvider.KeyUp(keysEventInput, Keys.Shift).Build();
115+
IAction releaseShift = new Actions(driver).KeyUp(Keys.Shift).Build();
108116
releaseShift.Perform();
109117

110118
AssertThatFormEventsFiredAreExactly("focus keydown keydown keypress keyup keydown keypress keyup keyup");

dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public void ShouldAllowMoveAndClick()
140140
}
141141

142142
[Test]
143+
[IgnoreBrowser(Browser.IE, "Clicking without context is perfectly valid for W3C-compliant remote ends.")]
144+
[IgnoreBrowser(Browser.Firefox, "Clicking without context is perfectly valid for W3C-compliant remote ends.")]
143145
[IgnoreBrowser(Browser.IPhone, "API not implemented in driver")]
144146
[IgnoreBrowser(Browser.Remote, "API not implemented in driver")]
145147
[IgnoreBrowser(Browser.Android, "API not implemented in driver")]
@@ -148,10 +150,9 @@ public void ShouldNotMoveToANullLocator()
148150
{
149151
driver.Url = javascriptPage;
150152

151-
Actions actionProvider = new Actions(driver);
152153
try
153154
{
154-
IAction contextClick = actionProvider.MoveToElement(null).Build();
155+
IAction contextClick = new Actions(driver).MoveToElement(null).Build();
155156

156157
contextClick.Perform();
157158
Assert.Fail("Shouldn't be allowed to click on null element.");
@@ -163,7 +164,7 @@ public void ShouldNotMoveToANullLocator()
163164

164165
try
165166
{
166-
actionProvider.Click().Build().Perform();
167+
new Actions(driver).Click().Build().Perform();
167168
Assert.Fail("Shouldn't be allowed to click without a context.");
168169
}
169170
catch (Exception)
@@ -330,14 +331,13 @@ private void PerformDragAndDropWithMouse()
330331
IWebElement toDrag = driver.FindElement(By.Id("rightitem-3"));
331332
IWebElement dragInto = driver.FindElement(By.Id("sortable1"));
332333

333-
Actions actionProvider = new Actions(driver);
334-
IAction holdItem = actionProvider.ClickAndHold(toDrag).Build();
334+
IAction holdItem = new Actions(driver).ClickAndHold(toDrag).Build();
335335

336-
IAction moveToSpecificItem = actionProvider.MoveToElement(driver.FindElement(By.Id("leftitem-4"))).Build();
336+
IAction moveToSpecificItem = new Actions(driver).MoveToElement(driver.FindElement(By.Id("leftitem-4"))).Build();
337337

338-
IAction moveToOtherList = actionProvider.MoveToElement(dragInto).Build();
338+
IAction moveToOtherList = new Actions(driver).MoveToElement(dragInto).Build();
339339

340-
IAction drop = actionProvider.Release(dragInto).Build();
340+
IAction drop = new Actions(driver).Release(dragInto).Build();
341341

342342
Assert.AreEqual("Nothing happened.", dragReporter.Text);
343343

dotnet/test/common/Interactions/CombinedInputActionsTest.cs

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@ namespace OpenQA.Selenium.Interactions
66
[TestFixture]
77
public class CombinedInputActionsTest : DriverTestFixture
88
{
9+
[SetUp]
10+
public void Setup()
11+
{
12+
new Actions(driver).SendKeys(Keys.Null).Perform();
13+
}
14+
15+
[TearDown]
16+
public void ReleaseModifierKeys()
17+
{
18+
new Actions(driver).SendKeys(Keys.Null).Perform();
19+
}
20+
921
[Test]
10-
[IgnoreBrowser(Browser.IE, "Shift-click implementation not complete")]
22+
[IgnoreBrowser(Browser.IE, "IE reports [0,0] as location for <option> elements")]
1123
[IgnoreBrowser(Browser.Remote, "Shift-click implementation not complete")]
1224
[IgnoreBrowser(Browser.IPhone, "Shift-click implementation not complete")]
1325
[IgnoreBrowser(Browser.Android, "Shift-click implementation not complete")]
@@ -35,7 +47,7 @@ public void ShouldAllowClickingOnFormElements()
3547
}
3648

3749
[Test]
38-
[IgnoreBrowser(Browser.IE, "Control-click implementation not complete")]
50+
[IgnoreBrowser(Browser.IE, "Browser does not respond to combined input using SendMessage, only SendInput")]
3951
[IgnoreBrowser(Browser.Remote, "Control-click implementation not complete")]
4052
[IgnoreBrowser(Browser.IPhone, "Control-click implementation not complete")]
4153
[IgnoreBrowser(Browser.Android, "Control-click implementation not complete")]
@@ -50,8 +62,7 @@ public void ShouldAllowSelectingMultipleItems()
5062

5163
ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li"));
5264

53-
Actions actionBuider = new Actions(driver);
54-
IAction selectThreeItems = actionBuider.KeyDown(Keys.Control)
65+
IAction selectThreeItems = new Actions(driver).KeyDown(Keys.Control)
5566
.Click(listItems[1])
5667
.Click(listItems[3])
5768
.Click(listItems[5])
@@ -62,7 +73,7 @@ public void ShouldAllowSelectingMultipleItems()
6273
Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text);
6374

6475
// Now click on another element, make sure that's the only one selected.
65-
actionBuider.Click(listItems[6]).Build().Perform();
76+
new Actions(driver).Click(listItems[6]).Build().Perform();
6677
Assert.AreEqual("#item7", reportingElement.Text);
6778
}
6879

@@ -143,7 +154,6 @@ public void MouseMovementWorksWhenNavigatingToAnotherPage()
143154
[IgnoreBrowser(Browser.Safari)]
144155
[IgnoreBrowser(Browser.HtmlUnit)]
145156
[IgnoreBrowser(Browser.Opera)]
146-
[IgnoreBrowser(Browser.IE, "Windows native events library does not support storing modifiers state yet.")]
147157
[IgnoreBrowser(Browser.Firefox, "Windows native events library does not support storing modifiers state yet.")]
148158
public void ChordControlCutAndPaste()
149159
{
@@ -171,17 +181,17 @@ public void ChordControlCutAndPaste()
171181

172182
//TODO: Figure out why calling sendKey(Key.CONTROL + "a") and then
173183
//sendKeys("x") does not work on Linux.
174-
new Actions(driver)
175-
.SendKeys(Keys.Control + "a" + "x")
184+
new Actions(driver).KeyDown(Keys.Control)
185+
.SendKeys("a" + "x")
176186
.Perform();
177187

178188
// Release keys before next step.
179189
new Actions(driver).SendKeys(Keys.Null).Perform();
180190

181191
Assert.AreEqual(string.Empty, element.GetAttribute("value"));
182192

183-
new Actions(driver)
184-
.SendKeys(Keys.Control + "v")
193+
new Actions(driver).KeyDown(Keys.Control)
194+
.SendKeys("v")
185195
.SendKeys("v")
186196
.Perform();
187197

@@ -191,7 +201,7 @@ public void ChordControlCutAndPaste()
191201
}
192202

193203
[Test]
194-
[IgnoreBrowser(Browser.IE)]
204+
[IgnoreBrowser(Browser.IE, "Browser does not respond to combined input using SendMessage, only SendInput")]
195205
[IgnoreBrowser(Browser.Remote)]
196206
[IgnoreBrowser(Browser.IPhone)]
197207
[IgnoreBrowser(Browser.Android)]
@@ -209,20 +219,31 @@ public void CombiningShiftAndClickResultsInANewWindow()
209219
IWebElement link = driver.FindElement(By.Id("link"));
210220
string originalTitle = driver.Title;
211221

212-
int nWindows = driver.WindowHandles.Count;
213222
new Actions(driver)
214223
.MoveToElement(link)
215224
.KeyDown(Keys.Shift)
216-
.Click()
225+
.Click(link)
217226
.KeyUp(Keys.Shift)
218227
.Perform();
219-
220-
Assert.AreEqual(nWindows + 1, driver.WindowHandles.Count, "Should have opened a new window.");
228+
WaitFor(() => { return driver.WindowHandles.Count > 1; }, "Did not receive new window");
229+
Assert.AreEqual(2, driver.WindowHandles.Count, "Should have opened a new window.");
221230
Assert.AreEqual(originalTitle, driver.Title, "Should not have navigated away.");
231+
232+
string originalHandle = driver.CurrentWindowHandle;
233+
foreach(string newHandle in driver.WindowHandles)
234+
{
235+
if (newHandle != originalHandle)
236+
{
237+
driver.SwitchTo().Window(newHandle);
238+
driver.Close();
239+
}
240+
}
241+
242+
driver.SwitchTo().Window(originalHandle);
222243
}
223244

224245
[Test]
225-
[IgnoreBrowser(Browser.IE)]
246+
[IgnoreBrowser(Browser.IE, "Browser does not respond to combined input using SendMessage, only SendInput")]
226247
[IgnoreBrowser(Browser.Remote)]
227248
[IgnoreBrowser(Browser.IPhone)]
228249
[IgnoreBrowser(Browser.Android)]
@@ -240,7 +261,7 @@ public void HoldingDownShiftKeyWhileClicking()
240261

241262
IWebElement toClick = driver.FindElement(By.Id("eventish"));
242263

243-
new Actions(driver).KeyDown(Keys.Shift).Click(toClick).KeyUp(Keys.Shift).Perform();
264+
new Actions(driver).MoveToElement(toClick).KeyDown(Keys.Shift).Click().KeyUp(Keys.Shift).Perform();
244265

245266
IWebElement shiftInfo = WaitFor(() => { return driver.FindElement(By.Id("shiftKey")); }, "Could not find element with id 'shiftKey'");
246267
Assert.AreEqual("true", shiftInfo.Text);

dotnet/test/common/PositionAndSizeTest.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public void ShouldScrollPageAndGetCoordinatesOfAnElementThatIsOutOfViewPort()
5555
Point location = GetLocationInViewPort(By.Id("box"));
5656
Assert.AreEqual(10, location.X);
5757
Assert.GreaterOrEqual(location.Y, 0);
58-
Assert.LessOrEqual(location.Y, windowHeight - 100);
5958
Assert.AreEqual(new Point(10, 5010), GetLocationOnPage(By.Id("box")));
59+
// GetLocationInViewPort only works within the context of a single frame
60+
// for W3C-spec compliant remote ends.
61+
// Assert.LessOrEqual(location.Y, windowHeight - 100);
6062
}
6163

6264
[Test]
@@ -74,8 +76,10 @@ public void ShouldGetCoordinatesInViewPortOfAnElementInAFrame()
7476
{
7577
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/element_in_frame.html");
7678
driver.SwitchTo().Frame("ifr");
77-
Assert.AreEqual(new Point(25, 25), GetLocationInViewPort(By.Id("box")));
7879
Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
80+
// GetLocationInViewPort only works within the context of a single frame
81+
// for W3C-spec compliant remote ends.
82+
// Assert.AreEqual(new Point(25, 25), GetLocationInViewPort(By.Id("box")));
7983
}
8084

8185
[Test]
@@ -84,8 +88,10 @@ public void ShouldGetCoordinatesInViewPortOfAnElementInANestedFrame()
8488
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/element_in_nested_frame.html");
8589
driver.SwitchTo().Frame("ifr");
8690
driver.SwitchTo().Frame("ifr");
87-
Assert.AreEqual(new Point(40, 40), GetLocationInViewPort(By.Id("box")));
8891
Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
92+
// GetLocationInViewPort only works within the context of a single frame
93+
// for W3C-spec compliant remote ends.
94+
// Assert.AreEqual(new Point(40, 40), GetLocationInViewPort(By.Id("box")));
8995
}
9096

9197
[Test]

dotnet/test/common/UploadTest.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ public void ShouldAllowFileUploading()
4141

4242
driver.SwitchTo().Frame("upload_target");
4343

44-
IWebElement body = driver.FindElement(By.XPath("//body"));
44+
IWebElement body = null;
45+
WaitFor(() => {
46+
body = driver.FindElement(By.XPath("//body"));
47+
return LoremIpsumText == body.Text;
48+
}, "Page source is: " + driver.PageSource);
4549
Assert.IsTrue(LoremIpsumText == body.Text, "Page source is: " + driver.PageSource);
4650
driver.Url = "about:blank";
4751
}
4852

4953
[Test]
5054
[Category("Javascript")]
5155
[IgnoreBrowser(Browser.WindowsPhone, "Does not yet support file uploads")]
52-
//[IgnoreBrowser(Browser.IE, "Transparent file upload element not yet handled")]
5356
public void ShouldAllowFileUploadingUsingTransparentUploadElement()
5457
{
5558
if (TestUtilities.IsMarionette(driver))
@@ -63,7 +66,11 @@ public void ShouldAllowFileUploadingUsingTransparentUploadElement()
6366

6467
driver.SwitchTo().Frame("upload_target");
6568

66-
IWebElement body = driver.FindElement(By.XPath("//body"));
69+
IWebElement body = null;
70+
WaitFor(() => {
71+
body = driver.FindElement(By.XPath("//body"));
72+
return LoremIpsumText == body.Text;
73+
}, "Page source is: " + driver.PageSource);
6774
Assert.IsTrue(LoremIpsumText == body.Text, "Page source is: " + driver.PageSource);
6875
driver.Url = "about:blank";
6976
}

0 commit comments

Comments
 (0)