MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ClassName

Method ClassName

dotnet/src/webdriver/By.cs:238–252  ·  view source on GitHub ↗

Gets a mechanism to find elements by their CSS class. The CSS class to find. A object the driver can use to find the elements. If an element has many classes then this will match against each of them. For example if the value is "one two onone", then the following values for the className parame

(string classNameToFind)

Source from the content-addressed store, hash-verified

236 /// className parameter will match: "one" and "two".</remarks>
237 /// <exception cref="ArgumentNullException">If <paramref name="classNameToFind"/> is null.</exception>
238 public static By ClassName(string classNameToFind)
239 {
240 if (classNameToFind == null)
241 {
242 throw new ArgumentNullException(nameof(classNameToFind), "Cannot find elements when the class name expression is null.");
243 }
244
245 ThrowIfClassNameHasWhitespace(classNameToFind);
246 string selector = "." + EscapeCssSelector(classNameToFind);
247
248 return new By(CssSelectorMechanism, selector)
249 {
250 Description = "By.ClassName[Contains]: " + classNameToFind
251 };
252 }
253
254 /// <summary>
255 /// Gets a mechanism to find elements by a partial match on their link text.

Calls

no outgoing calls