Skip to content

Commit f5b5a92

Browse files
committed
Undoing improper spec compliance for finding elements
1 parent 0bbb132 commit f5b5a92

File tree

2 files changed

+78
-24
lines changed

2 files changed

+78
-24
lines changed

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

+42-24
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,13 @@ public ReadOnlyCollection<IWebElement> FindElementsById(string id)
487487
/// </example>
488488
public IWebElement FindElementByClassName(string className)
489489
{
490-
// TODO: Modified for spec-compliance. May change.
491-
// Requires cleanup after spec is at recommendation.
492-
// return this.FindElement("class name", className);
493-
return this.FindElement("css selector", "." + className);
490+
// Element finding mechanism is not allowed by the W3C WebDriver
491+
// specification, but rather should be implemented as a function
492+
// of other finder mechanisms as documented in the spec.
493+
// Implementation after spec reaches recommendation should be as
494+
// follows:
495+
// return this.FindElement("css selector", "." + className);
496+
return this.FindElement("class name", className);
494497
}
495498

496499
/// <summary>
@@ -506,10 +509,13 @@ public IWebElement FindElementByClassName(string className)
506509
/// </example>
507510
public ReadOnlyCollection<IWebElement> FindElementsByClassName(string className)
508511
{
509-
// TODO: Modified for spec-compliance. May change.
510-
// Requires cleanup after spec is at recommendation.
511-
// return this.FindElements("class name", className);
512-
return this.FindElements("css selector", "." + className);
512+
// Element finding mechanism is not allowed by the W3C WebDriver
513+
// specification, but rather should be implemented as a function
514+
// of other finder mechanisms as documented in the spec.
515+
// Implementation after spec reaches recommendation should be as
516+
// follows:
517+
// return this.FindElements("css selector", "." + className);
518+
return this.FindElements("class name", className);
513519
}
514520

515521
#endregion
@@ -598,10 +604,13 @@ public ReadOnlyCollection<IWebElement> FindElementsByPartialLinkText(string part
598604
/// </example>
599605
public IWebElement FindElementByName(string name)
600606
{
601-
// TODO: Modified for spec-compliance. May change.
602-
// Requires cleanup after spec is at recommendation.
603-
// return this.FindElement("name", name);
604-
return this.FindElement("css selector", "*[name=\"" + name + "\"]");
607+
// Element finding mechanism is not allowed by the W3C WebDriver
608+
// specification, but rather should be implemented as a function
609+
// of other finder mechanisms as documented in the spec.
610+
// Implementation after spec reaches recommendation should be as
611+
// follows:
612+
// return this.FindElement("css selector", "*[name=\"" + name + "\"]");
613+
return this.FindElement("name", name);
605614
}
606615

607616
/// <summary>
@@ -617,10 +626,13 @@ public IWebElement FindElementByName(string name)
617626
/// </example>
618627
public ReadOnlyCollection<IWebElement> FindElementsByName(string name)
619628
{
620-
// TODO: Modified for spec-compliance. May change.
621-
// Requires cleanup after spec is at recommendation.
622-
// return this.FindElements("name", name);
623-
return this.FindElements("css selector", "*[name=\"" + name + "\"]");
629+
// Element finding mechanism is not allowed by the W3C WebDriver
630+
// specification, but rather should be implemented as a function
631+
// of other finder mechanisms as documented in the spec.
632+
// Implementation after spec reaches recommendation should be as
633+
// follows:
634+
// return this.FindElements("css selector", "*[name=\"" + name + "\"]");
635+
return this.FindElements("name", name);
624636
}
625637

626638
#endregion
@@ -639,10 +651,13 @@ public ReadOnlyCollection<IWebElement> FindElementsByName(string name)
639651
/// </example>
640652
public IWebElement FindElementByTagName(string tagName)
641653
{
642-
// TODO: Modified for spec-compliance. May change.
643-
// Requires cleanup after spec is at recommendation.
644-
// return this.FindElement("tag name", tagName);
645-
return this.FindElement("css selector", tagName);
654+
// Element finding mechanism is not allowed by the W3C WebDriver
655+
// specification, but rather should be implemented as a function
656+
// of other finder mechanisms as documented in the spec.
657+
// Implementation after spec reaches recommendation should be as
658+
// follows:
659+
// return this.FindElement("css selector", tagName);
660+
return this.FindElement("tag name", tagName);
646661
}
647662

648663
/// <summary>
@@ -658,10 +673,13 @@ public IWebElement FindElementByTagName(string tagName)
658673
/// </example>
659674
public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
660675
{
661-
// TODO: Modified for spec-compliance. May change.
662-
// Requires cleanup after spec is at recommendation.
663-
// return this.FindElements("tag name", tagName);
664-
return this.FindElements("css selector", tagName);
676+
// Element finding mechanism is not allowed by the W3C WebDriver
677+
// specification, but rather should be implemented as a function
678+
// of other finder mechanisms as documented in the spec.
679+
// Implementation after spec reaches recommendation should be as
680+
// follows:
681+
// return this.FindElements("css selector", tagName);
682+
return this.FindElements("tag name", tagName);
665683
}
666684
#endregion
667685

dotnet/src/webdriver/Remote/RemoteWebElement.cs

+36
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,12 @@ public ReadOnlyCollection<IWebElement> FindElementsById(string id)
536536
/// </example>
537537
public IWebElement FindElementByName(string name)
538538
{
539+
// Element finding mechanism is not allowed by the W3C WebDriver
540+
// specification, but rather should be implemented as a function
541+
// of other finder mechanisms as documented in the spec.
542+
// Implementation after spec reaches recommendation should be as
543+
// follows:
544+
// return this.FindElement("css selector", "*[name=\"" + name + "\"]");
539545
return this.FindElement("name", name);
540546
}
541547

@@ -552,6 +558,12 @@ public IWebElement FindElementByName(string name)
552558
/// </example>
553559
public ReadOnlyCollection<IWebElement> FindElementsByName(string name)
554560
{
561+
// Element finding mechanism is not allowed by the W3C WebDriver
562+
// specification, but rather should be implemented as a function
563+
// of other finder mechanisms as documented in the spec.
564+
// Implementation after spec reaches recommendation should be as
565+
// follows:
566+
// return this.FindElements("css selector", "*[name=\"" + name + "\"]");
555567
return this.FindElements("name", name);
556568
}
557569

@@ -571,6 +583,12 @@ public ReadOnlyCollection<IWebElement> FindElementsByName(string name)
571583
/// </example>
572584
public IWebElement FindElementByTagName(string tagName)
573585
{
586+
// Element finding mechanism is not allowed by the W3C WebDriver
587+
// specification, but rather should be implemented as a function
588+
// of other finder mechanisms as documented in the spec.
589+
// Implementation after spec reaches recommendation should be as
590+
// follows:
591+
// return this.FindElement("css selector", tagName);
574592
return this.FindElement("tag name", tagName);
575593
}
576594

@@ -587,6 +605,12 @@ public IWebElement FindElementByTagName(string tagName)
587605
/// </example>
588606
public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
589607
{
608+
// Element finding mechanism is not allowed by the W3C WebDriver
609+
// specification, but rather should be implemented as a function
610+
// of other finder mechanisms as documented in the spec.
611+
// Implementation after spec reaches recommendation should be as
612+
// follows:
613+
// return this.FindElements("css selector", tagName);
590614
return this.FindElements("tag name", tagName);
591615
}
592616
#endregion
@@ -605,6 +629,12 @@ public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
605629
/// </example>
606630
public IWebElement FindElementByClassName(string className)
607631
{
632+
// Element finding mechanism is not allowed by the W3C WebDriver
633+
// specification, but rather should be implemented as a function
634+
// of other finder mechanisms as documented in the spec.
635+
// Implementation after spec reaches recommendation should be as
636+
// follows:
637+
// return this.FindElement("css selector", "." + className);
608638
return this.FindElement("class name", className);
609639
}
610640

@@ -621,6 +651,12 @@ public IWebElement FindElementByClassName(string className)
621651
/// </example>
622652
public ReadOnlyCollection<IWebElement> FindElementsByClassName(string className)
623653
{
654+
// Element finding mechanism is not allowed by the W3C WebDriver
655+
// specification, but rather should be implemented as a function
656+
// of other finder mechanisms as documented in the spec.
657+
// Implementation after spec reaches recommendation should be as
658+
// follows:
659+
// return this.FindElements("css selector", "." + className);
624660
return this.FindElements("class name", className);
625661
}
626662
#endregion

0 commit comments

Comments
 (0)