String simpleSelector = valueOf(s.getSimpleSelector());
@Override public boolean is(WebDriver driver, WebElement element, ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); return CssSelectorMatcherService.elementMatchesSelector(driver, element, argumentMap, simpleSelector) && isCondition(driver, element, argumentMap, simpleSelector, condition); }
@Override public boolean is(WebDriver driver, WebElement element, ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); return CssSelectorMatcherService.elementMatchesSelector(driver, element, argumentMap, simpleSelector) && isCondition(driver, element, argumentMap, simpleSelector, condition); }
public CssConditionalSelector translate(ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); CssSelector cssSelector = cssSelectorTranslator.translate(argumentMap, simpleSelector); CssCondition cssCondition = cssConditionTranslator.translate(simpleSelector, argumentMap, condition); return new CssConditionalSelector(cssSelector, cssCondition); }
@Override public TagComponent toXPath(ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); TagComponent tagComponent = XPathComponentCompilerService.compileSelector(argumentMap, simpleSelector); ConditionComponent compiledCondition = conditionToXPath(argumentMap, simpleSelector, condition); return tagComponent.cloneAndCombineTo(compiledCondition); }
public CssConditionalSelector translate(ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); CssSelector cssSelector = cssSelectorTranslator.translate(argumentMap, simpleSelector); CssCondition cssCondition = cssConditionTranslator.translate(simpleSelector, argumentMap, condition); return new CssConditionalSelector(cssSelector, cssCondition); }
@Override public TagComponent toXPath(ArgumentMap argumentMap, ConditionalSelector conditionalSelector) { Condition condition = conditionalSelector.getCondition(); SimpleSelector simpleSelector = conditionalSelector.getSimpleSelector(); TagComponent tagComponent = XPathComponentCompilerService.compileSelector(argumentMap, simpleSelector); ConditionComponent compiledCondition = conditionToXPath(argumentMap, simpleSelector, condition); return tagComponent.cloneAndCombineTo(compiledCondition); }
public boolean isMatchingPseudoElement( final ReportElement element, final String pseudo ) { for ( int i = 0; i < activePseudoStyleRules.length; i++ ) { final ElementStyleRule activeStyleRule = activePseudoStyleRules[i]; final List<CSSSelector> selectorList = activeStyleRule.getSelectorList(); for ( int x = 0; x < selectorList.size(); x += 1 ) { final CSSSelector selector = selectorList.get( x ); if ( selector instanceof ConditionalSelector == false ) { continue; } final ConditionalSelector cs = (ConditionalSelector) selector; final Condition condition = cs.getCondition(); final AttributeCondition ac = (AttributeCondition) condition; if ( ObjectUtilities.equal( ac.getValue(), pseudo ) == false ) { continue; } final SimpleSelector simpleSelector = cs.getSimpleSelector(); if ( isMatch( element, simpleSelector ) ) { return true; } } } return false; }
public boolean isMatchingPseudoElement( final LayoutElement element, final String pseudo ) { for ( int i = 0; i < activePseudoStyleRules.length; i++ ) { final CSSStyleRule activeStyleRule = activePseudoStyleRules[ i ]; final CSSSelector selector = activeStyleRule.getSelector(); final ConditionalSelector cs = (ConditionalSelector) selector; final Condition condition = cs.getCondition(); final AttributeCondition ac = (AttributeCondition) condition; if ( ObjectUtilities.equal( ac.getValue(), pseudo ) == false ) { continue; } final SimpleSelector simpleSelector = cs.getSimpleSelector(); if ( isMatch( element, simpleSelector ) ) { return true; } } return false; }
private static ConditionalSelector createConditionSelectorWithSomePartReplaced( ConditionalSelector oldConditionSelector, String toBeReplacedSelectorName, SimpleSelector candidateSelector) { if (oldConditionSelector == null || !toString(oldConditionSelector).contains( toBeReplacedSelectorName)) { return oldConditionSelector; } SelectorFactory selectorFactory = new SelectorFactoryImpl(); if (candidateSelector instanceof ElementSelector) { return selectorFactory.createConditionalSelector(candidateSelector, oldConditionSelector.getCondition()); } if (candidateSelector instanceof ConditionalSelector) { // TODO some cases not covered. ConditionalSelector candidateConditionSelector = (ConditionalSelector) candidateSelector; Condition newCondition = createConditionWithSomePartReplaced( oldConditionSelector.getCondition(), toBeReplacedSelectorName, candidateConditionSelector.getCondition()); return selectorFactory.createConditionalSelector( oldConditionSelector.getSimpleSelector(), newCondition); } return oldConditionSelector; }
ConditionalSelector conditionalSelector = (ConditionalSelector) selector; String simpleSelectorString = toString(conditionalSelector .getSimpleSelector()); if (simpleSelectorString != null) { stringBuilder.append(simpleSelectorString);
String simpleSelector = valueOf(s.getSimpleSelector());
String simpleSelector = valueOf(s.getSimpleSelector());
@Test public void testConditionToXPath() { W3cCssSelectorListWithMap w3cCssSelectorListWithMap = W3cCssSelectorWithMapParser.parseSelector("span.a.b"); SelectorList selectorList = w3cCssSelectorListWithMap.getSelectorList(); ConditionalSelector selector = (ConditionalSelector) selectorList.item(0); ArgumentMap argumentMap = w3cCssSelectorListWithMap.getArgumentMap(); SimpleSelector simpleSelector = selector.getSimpleSelector(); TagComponent spanTagComponent = XPathComponentCompilerService.compileSelector(argumentMap, simpleSelector); CombinatorCondition combinatorCondition = (CombinatorCondition) selector.getCondition(); ConditionComponent compiledCondition = andConditionalCssSelector.conditionToXPath(argumentMap, simpleSelector, combinatorCondition); TagComponent cs = spanTagComponent.cloneAndCombineTo(compiledCondition); assertThat(cs.toXPath(), is("(.//*[self::span and contains(concat(' ', normalize-space(@class), ' '), ' a ') and contains(concat(' ', normalize-space(@class), ' '), ' b ')])")); assertThat(cs.toXPathCondition(), is("local-name() = 'span' and contains(concat(' ', normalize-space(@class), ' '), ' a ') and contains(concat(' ', normalize-space(@class), ' '), ' b ')")); }
.getSimpleSelector()) & isValidCondition(selectorName, condSelector .getCondition());
return false; if ( isMatch( node, cs.getSimpleSelector() ) == false ) { return false;
final ConditionalSelector conditional = (ConditionalSelector) selector; final Condition condition = conditional.getCondition(); return selects(conditional.getSimpleSelector(), element) && selects(condition, element); case Selector.SAC_ELEMENT_NODE_SELECTOR: final ElementSelector es = (ElementSelector) selector;
final ConditionalSelector conditional = (ConditionalSelector) selector; final Condition condition = conditional.getCondition(); return selects(conditional.getSimpleSelector(), element) && selects(condition, element); case Selector.SAC_ELEMENT_NODE_SELECTOR: final ElementSelector es = (ElementSelector) selector;
final ConditionalSelector conditional = (ConditionalSelector) selector; final Condition condition = conditional.getCondition(); return selects(conditional.getSimpleSelector(), element) && selects(condition, element); case Selector.SAC_ELEMENT_NODE_SELECTOR: final ElementSelector es = (ElementSelector) selector;
return false; if ( isMatch( node, cs.getSimpleSelector() ) == false ) { return false;