File tree Expand file tree Collapse file tree
main/java/io/github/seleniumquery/by/csstree/condition/pseudoclass/basicfilter
test/java/io/github/seleniumquery/by/csstree/condition/pseudoclass Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package io .github .seleniumquery .by .csstree .condition .pseudoclass .basicfilter ;
1818
19- import io .github .seleniumquery .by .csstree .condition .pseudoclass .SQCssPseudoClassCondition ;
20- import io .github .seleniumquery .by .csstree .condition .pseudoclass .SQCssPseudoNeverNativelySupported ;
21- import io .github .seleniumquery .by .locator .SQLocatorXPath ;
19+ import io .github .seleniumquery .by .css .pseudoclasses .PseudoClassSelector ;
2220
2321/**
2422 * :first
23+ * https://api.jquery.com/first-selector/
2524 *
2625 * @author acdcjunior
2726 * @since 0.10.0
2827 */
29- public class SQCssFirstPseudoClass extends SQCssPseudoClassCondition {
28+ public class SQCssFirstPseudoClass extends SQCssEqPseudoClass {
3029
3130 public static final String PSEUDO = "first" ;
3231
33- public SQCssPseudoNeverNativelySupported firstPseudoClassLocatorGenerationStrategy = new SQCssPseudoNeverNativelySupported () {
34- @ Override
35- public SQLocatorXPath toXPath () {
36- return SQLocatorXPath .pureXPath ("position() = 1" );
37- }
38- };
32+ public SQCssFirstPseudoClass (PseudoClassSelector pseudoClassSelector ) {
33+ super (pseudoClassSelector );
34+ }
3935
4036 @ Override
41- public SQCssPseudoNeverNativelySupported getSQCssLocatorGenerationStrategy () {
42- return firstPseudoClassLocatorGenerationStrategy ;
37+ public String getArgument () {
38+ return "0" ;
4339 }
4440
4541}
Original file line number Diff line number Diff line change 1818
1919import io .github .seleniumquery .by .css .pseudoclasses .PseudoClassSelector ;
2020import io .github .seleniumquery .by .csstree .condition .SQCssCondition ;
21- import io .github .seleniumquery .by .csstree .condition .SQCssConditionImplementedLocators ;
2221import io .github .seleniumquery .by .filter .ElementFilter ;
2322import io .github .seleniumquery .by .locator .SQLocator ;
2423import io .github .seleniumquery .by .locator .SQLocatorUtilsTest ;
3635
3736public class PseudoClassTestUtils {
3837
38+ public static final PseudoClassSelector EMPTY = new PseudoClassSelector (null , null , "" ) {
39+ @ Override
40+ public String getPseudoClassContent () {
41+ return "" ;
42+ }
43+ };
44+
3945 public static <T extends SQCssCondition > void assertPseudo (String selector , Class <T > pseudoClassClass ) {
4046 // given
4147 // selector
@@ -88,7 +94,7 @@ private static <T extends SQCssFunctionalPseudoClassCondition> void assertSelect
8894 public static void assertFilterOnlyPseudoGeneratesFilter (SQCssPseudoClassCondition pseudoClassCondition , ElementFilter pseudoClassFilter ) {
8995 SQLocator previous = SQLocatorUtilsTest .universalSelectorLocator (SQLocatorUtilsTest .createMockDriverWithoutNativeSupportFor (getSelectorForPseudoClass (pseudoClassCondition )));
9096 // when
91- SQLocator locator = (( SQCssConditionImplementedLocators ) pseudoClassCondition ) .toSQLocator (previous );
97+ SQLocator locator = pseudoClassCondition .toSQLocator (previous );
9298 // then
9399 assertThat (locator .getSqLocatorCss ().toString (), is (previous .getSqLocatorCss ().toString ()));
94100 assertThat (locator .canFetchThroughCssAlone (), is (false ));
Original file line number Diff line number Diff line change 1616
1717package io .github .seleniumquery .by .csstree .condition .pseudoclass .basicfilter ;
1818
19+ import io .github .seleniumquery .by .csstree .condition .pseudoclass .PseudoClassTestUtils ;
1920import org .junit .Test ;
2021
2122import static io .github .seleniumquery .by .csstree .condition .pseudoclass .PseudoClassAssertLocatorUtils .assertPseudoClassOnlySupportsPureXPathRegardlessOfNativeSupport ;
2425public class SQCssFirstPseudoClassTest {
2526
2627 public static final String FIRST_PSEUDO = ":first" ;
27- public static final String FIRST_XPATH_EXPRESSION = ".//*[position() = 1]" ;
28+ public static final String FIRST_XPATH_EXPRESSION = "( .//*) [position() = 1]" ;
2829
2930 @ Test
3031 public void translate () {
@@ -34,7 +35,7 @@ public void translate() {
3435 @ Test
3536 public void toSQLocator__when_driver_does_NOT_have_native_support () {
3637 assertPseudoClassOnlySupportsPureXPathRegardlessOfNativeSupport (
37- new SQCssFirstPseudoClass (),
38+ new SQCssFirstPseudoClass (PseudoClassTestUtils . EMPTY ),
3839 FIRST_PSEUDO ,
3940 FIRST_XPATH_EXPRESSION
4041 );
You can’t perform that action at this time.
0 commit comments