Text(String, Boolean) Method

Definition

Assembly HeadlessTestingFramework.dll

Locates elements by their text content. Searches in common text properties like Text, Content, Header.

public static By Text(string text, bool exact = true)

Parameters

text
String

The text to match.

exact
Boolean

If true, requires exact match. If false, uses contains.

Returns

By
A By locator for text matching.

Examples

var element = driver.FindElement(By.Text("Submit"));
var partial = driver.FindElement(By.Text("Sub", exact: false));