public static TagComponent compileSelector(ArgumentMap argumentMap, Selector selector) { CssSelector<Selector, TagComponent> cssSelector = CssSelectorFactory.parsedSelectorToCssSelector(selector); return cssSelector.toXPath(argumentMap, selector); }
public static boolean elementMatchesSelector(WebDriver driver, WebElement element, ArgumentMap argumentMap, Selector selector) { CssSelector<Selector, TagComponent> cssSelector = CssSelectorFactory.parsedSelectorToCssSelector(selector); return cssSelector.is(driver, element, argumentMap, selector); }
@SuppressWarnings("unchecked") public static CssSelector<Selector, TagComponent> parsedSelectorToCssSelector(Selector parsedSimpleSelector) { return (CssSelector<Selector, TagComponent>) CssSelectorFactory.getSelector(parsedSimpleSelector); }
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { String notSelector = pseudoClassSelector.getPseudoClassContent(); return !CssSelectorMatcherService.elementMatchesStringSelector(driver, element, notSelector); }
ConditionComponent conditionToXPath(ArgumentMap argumentMap, Selector simpleSelector, Condition condition) { @SuppressWarnings("unchecked") CssConditionalSelector<Condition, ConditionComponent> evaluator = (CssConditionalSelector<Condition, ConditionComponent>) conditionalCssSelectorFactory.getSelector(condition); return evaluator.conditionToXPath(argumentMap, simpleSelector, condition); }
/** * Gets the given condition's CssSelector and tests if the element matches it. */ boolean isCondition(WebDriver driver, WebElement element, ArgumentMap argumentMap, Selector simpleSelector, Condition condition) { @SuppressWarnings("unchecked") CssConditionalSelector<Condition, ConditionComponent> evaluator = (CssConditionalSelector<Condition, ConditionComponent>) conditionalCssSelectorFactory.getSelector(condition); return evaluator.isCondition(driver, element, argumentMap, simpleSelector, condition); }
public static boolean elementMatchesStringSelector(WebDriver driver, WebElement element, String selector) { W3cCssSelectorListWithMap cssParsedSelectors = W3cCssSelectorWithMapParser.parseSelector(selector); for (W3cCssSelectorWithMap w3cCssSelectorWithMap : cssParsedSelectors) { if (elementMatchesSelector(driver, element, w3cCssSelectorWithMap)) { return true; } } return false; }
public static WebElement closest(WebDriver driver, WebElement element, String selector) { WebElement ancestorOrSelf = element; // begins by evaluating the element itself while (ancestorOrSelf != null) { if (CssSelectorMatcherService.elementMatchesStringSelector(driver, ancestorOrSelf, selector)) { return ancestorOrSelf; } ancestorOrSelf = SelectorUtils.parent(ancestorOrSelf); } // if ancestorOrSelf is null, it reached document root, // so no ancestor matching the selector was found return null; }
public static TagComponent compileSelector(ArgumentMap argumentMap, Selector selector) { CssSelector<Selector, TagComponent> cssSelector = CssSelectorFactory.parsedSelectorToCssSelector(selector); return cssSelector.toXPath(argumentMap, selector); }
public static boolean elementMatchesSelector(WebDriver driver, WebElement element, ArgumentMap argumentMap, Selector selector) { CssSelector<Selector, TagComponent> cssSelector = CssSelectorFactory.parsedSelectorToCssSelector(selector); return cssSelector.is(driver, element, argumentMap, selector); }
@Override public boolean isPseudoClass(WebDriver driver, WebElement element, PseudoClassSelector pseudoClassSelector) { String notSelector = pseudoClassSelector.getPseudoClassContent(); return !CssSelectorMatcherService.elementMatchesStringSelector(driver, element, notSelector); }
ConditionComponent conditionToXPath(ArgumentMap argumentMap, Selector simpleSelector, Condition condition) { @SuppressWarnings("unchecked") CssConditionalSelector<Condition, ConditionComponent> evaluator = (CssConditionalSelector<Condition, ConditionComponent>) conditionalCssSelectorFactory.getSelector(condition); return evaluator.conditionToXPath(argumentMap, simpleSelector, condition); }
/** * Gets the given condition's CssSelector and tests if the element matches it. */ boolean isCondition(WebDriver driver, WebElement element, ArgumentMap argumentMap, Selector simpleSelector, Condition condition) { @SuppressWarnings("unchecked") CssConditionalSelector<Condition, ConditionComponent> evaluator = (CssConditionalSelector<Condition, ConditionComponent>) conditionalCssSelectorFactory.getSelector(condition); return evaluator.isCondition(driver, element, argumentMap, simpleSelector, condition); }
public static boolean elementMatchesStringSelector(WebDriver driver, WebElement element, String selector) { W3cCssSelectorListWithMap cssParsedSelectors = W3cCssSelectorWithMapParser.parseSelector(selector); for (W3cCssSelectorWithMap w3cCssSelectorWithMap : cssParsedSelectors) { if (elementMatchesSelector(driver, element, w3cCssSelectorWithMap)) { return true; } } return false; }
public static WebElement closest(WebDriver driver, WebElement element, String selector) { WebElement ancestorOrSelf = element; // begins by evaluating the element itself while (ancestorOrSelf != null) { if (CssSelectorMatcherService.elementMatchesStringSelector(driver, ancestorOrSelf, selector)) { return ancestorOrSelf; } ancestorOrSelf = SelectorUtils.parent(ancestorOrSelf); } // if ancestorOrSelf is null, it reached document root, // so no ancestor matching the selector was found return null; }
@SuppressWarnings("unchecked") public static CssSelector<Selector, TagComponent> parsedSelectorToCssSelector(Selector parsedSimpleSelector) { return (CssSelector<Selector, TagComponent>) CssSelectorFactory.getSelector(parsedSimpleSelector); }
private boolean elementMatchesDescendantSelector(WebDriver driver, WebElement element, DescendantSelector descendantSelector, ArgumentMap argumentMap) { return CssSelectorMatcherService.elementMatchesSelector(driver, element, argumentMap, descendantSelector.getSimpleSelector()); }
private boolean elementMatchesDescendantSelector(WebDriver driver, WebElement element, DescendantSelector descendantSelector, ArgumentMap argumentMap) { return CssSelectorMatcherService.elementMatchesSelector(driver, element, argumentMap, descendantSelector.getSimpleSelector()); }
public static boolean elementMatchesSelector(WebDriver driver, WebElement element, W3cCssSelectorWithMap w3cCssSelectorWithMap) { return CssSelectorMatcherService.elementMatchesSelector(driver, element, w3cCssSelectorWithMap.getArgumentMap(), w3cCssSelectorWithMap.getSelector()); }
public static boolean elementMatchesSelector(WebDriver driver, WebElement element, W3cCssSelectorWithMap w3cCssSelectorWithMap) { return CssSelectorMatcherService.elementMatchesSelector(driver, element, w3cCssSelectorWithMap.getArgumentMap(), w3cCssSelectorWithMap.getSelector()); }