Skip to content

Commit

Permalink
Undoing improper spec compliance for finding elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Oct 22, 2014
1 parent 0bbb132 commit f5b5a92
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 24 deletions.
66 changes: 42 additions & 24 deletions dotnet/src/webdriver/Remote/RemoteWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,13 @@ public ReadOnlyCollection<IWebElement> FindElementsById(string id)
/// </example>
public IWebElement FindElementByClassName(string className)
{
// TODO: Modified for spec-compliance. May change.
// Requires cleanup after spec is at recommendation.
// return this.FindElement("class name", className);
return this.FindElement("css selector", "." + className);
// Element finding mechanism is not allowed by the W3C WebDriver
// specification, but rather should be implemented as a function
// of other finder mechanisms as documented in the spec.
// Implementation after spec reaches recommendation should be as
// follows:
// return this.FindElement("css selector", "." + className);
return this.FindElement("class name", className);
}

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

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

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

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

/// <summary>
Expand All @@ -658,10 +673,13 @@ public IWebElement FindElementByTagName(string tagName)
/// </example>
public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
{
// TODO: Modified for spec-compliance. May change.
// Requires cleanup after spec is at recommendation.
// return this.FindElements("tag name", tagName);
return this.FindElements("css selector", tagName);
// Element finding mechanism is not allowed by the W3C WebDriver
// specification, but rather should be implemented as a function
// of other finder mechanisms as documented in the spec.
// Implementation after spec reaches recommendation should be as
// follows:
// return this.FindElements("css selector", tagName);
return this.FindElements("tag name", tagName);
}
#endregion

Expand Down
36 changes: 36 additions & 0 deletions dotnet/src/webdriver/Remote/RemoteWebElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ public ReadOnlyCollection<IWebElement> FindElementsById(string id)
/// </example>
public IWebElement FindElementByName(string name)
{
// Element finding mechanism is not allowed by the W3C WebDriver
// specification, but rather should be implemented as a function
// of other finder mechanisms as documented in the spec.
// Implementation after spec reaches recommendation should be as
// follows:
// return this.FindElement("css selector", "*[name=\"" + name + "\"]");
return this.FindElement("name", name);
}

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

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

Expand All @@ -587,6 +605,12 @@ public IWebElement FindElementByTagName(string tagName)
/// </example>
public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
{
// Element finding mechanism is not allowed by the W3C WebDriver
// specification, but rather should be implemented as a function
// of other finder mechanisms as documented in the spec.
// Implementation after spec reaches recommendation should be as
// follows:
// return this.FindElements("css selector", tagName);
return this.FindElements("tag name", tagName);
}
#endregion
Expand All @@ -605,6 +629,12 @@ public ReadOnlyCollection<IWebElement> FindElementsByTagName(string tagName)
/// </example>
public IWebElement FindElementByClassName(string className)
{
// Element finding mechanism is not allowed by the W3C WebDriver
// specification, but rather should be implemented as a function
// of other finder mechanisms as documented in the spec.
// Implementation after spec reaches recommendation should be as
// follows:
// return this.FindElement("css selector", "." + className);
return this.FindElement("class name", className);
}

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

0 comments on commit f5b5a92

Please sign in to comment.