public void ClickButtonAdvanced() { // Generates JavaScript: return $(".some-label").filter(function() { return $(this).text().trim() === "Label Text"; }).parents(".parent-class").find(".button-class"); Driver.FindElement((By)By.jQuery(".some-label") .Filter(JQuery.HasTextFilterFunction("Label Text")) .Parents(".parent-class") .Find(".button-class")) .Click(); }
public void JQueryFindByText() { By selector = By.jQuery(".depth-level-2 > span") .Filter(JQuery.HasTextFilterFunction("--Div at depth 2 index 1")) .Parent() .Find(".depth-level-3 > span") .Filter(JQuery.HasTextFilterFunction("---Div at depth 3 index 1")); var textFromFoundElements = Driver.FindElements(selector).Select(x => x.Text).ToList(); textFromFoundElements.ShouldHaveTheSameElementsAs( "---Div at depth 3 index 1", "---Div at depth 3 index 1", "---Div at depth 3 index 1"); }
public void BuildsFilterHasTextFunction() { string function = JQuery.HasTextFilterFunction("some text").Statement; function.ShouldEqual("function() { return $(this).text().trim() === 'some text'; }"); }