Skip to content

Commit d447014

Browse files
#565: Repeatable complex locators
1 parent 02a1852 commit d447014

24 files changed

+276
-51
lines changed

src/main/java/io/appium/java_client/pagefactory/AndroidFindAll.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Repeatable;
2020
import java.lang.annotation.Retention;
21-
import java.lang.annotation.RetentionPolicy;
2221
import java.lang.annotation.Target;
2322

23+
import static java.lang.annotation.ElementType.FIELD;
24+
import static java.lang.annotation.ElementType.TYPE;
25+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
26+
2427
/**
2528
* Used to mark a field on a Page/Screen Object to indicate that lookup should use a
2629
* series of {@link io.appium.java_client.pagefactory.AndroidFindBy} tags
2730
* It will then search for all elements that match any criteria. Note that elements
2831
* are not guaranteed to be in document order.
2932
*/
30-
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
33+
@Retention(RUNTIME) @Target({FIELD, TYPE})
34+
@Repeatable(AndroidFindByAllSet.class)
3135
public @interface AndroidFindAll {
3236
/**
3337
* It is a set of {@link io.appium.java_client.pagefactory.AndroidFindBy} strategies which may

src/main/java/io/appium/java_client/pagefactory/AndroidFindBy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
2019
import java.lang.annotation.Repeatable;
2120
import java.lang.annotation.Retention;
22-
import java.lang.annotation.RetentionPolicy;
2321
import java.lang.annotation.Target;
2422

23+
import static java.lang.annotation.ElementType.FIELD;
24+
import static java.lang.annotation.ElementType.TYPE;
25+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
26+
2527

2628
/**
2729
* Used to mark a field on a Page Object to indicate an alternative mechanism for locating the
@@ -30,7 +32,7 @@
3032
* this allows users to quickly and easily create PageObjects.
3133
* using Android UI selectors, accessibility, id, name, class name, tag and xpath
3234
*/
33-
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
35+
@Retention(RUNTIME) @Target({FIELD, TYPE})
3436
@Repeatable(AndroidFindBySet.class)
3537
public @interface AndroidFindBy {
3638
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appium.java_client.pagefactory;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.FIELD;
7+
import static java.lang.annotation.ElementType.TYPE;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
/**
11+
* Defines set of chained/possible locators. Each one locator
12+
* should be defined with {@link AndroidFindAll}
13+
*/
14+
@Target(value = {TYPE, FIELD})
15+
@Retention(value = RUNTIME)
16+
public @interface AndroidFindByAllSet {
17+
/**
18+
* @return an array of {@link AndroidFindAll} which builds a sequence of
19+
* the chained searching for elements or a set of possible locators
20+
*/
21+
AndroidFindAll[] value();
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appium.java_client.pagefactory;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.FIELD;
7+
import static java.lang.annotation.ElementType.TYPE;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
/**
11+
* Defines set of chained/possible locators. Each one locator
12+
* should be defined with {@link io.appium.java_client.pagefactory.AndroidFindBys}
13+
*/
14+
@Target(value = {TYPE, FIELD})
15+
@Retention(value = RUNTIME)
16+
public @interface AndroidFindByChainSet {
17+
/**
18+
* @return an array of {@link io.appium.java_client.pagefactory.AndroidFindBys} which builds a sequence of
19+
* the chained searching for elements or a set of possible locators
20+
*/
21+
AndroidFindBys[] value();
22+
}

src/main/java/io/appium/java_client/pagefactory/AndroidFindBySet.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
2019
import java.lang.annotation.Retention;
21-
import java.lang.annotation.RetentionPolicy;
2220
import java.lang.annotation.Target;
2321

22+
import static java.lang.annotation.ElementType.FIELD;
23+
import static java.lang.annotation.ElementType.TYPE;
24+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
25+
2426
/**
2527
* Defines set of chained/possible locators. Each one locator
2628
* should be defined with {@link io.appium.java_client.pagefactory.AndroidFindBy}
2729
*/
28-
@Target(value = {ElementType.TYPE, ElementType.FIELD})
29-
@Retention(value = RetentionPolicy.RUNTIME)
30+
@Target(value = {TYPE, FIELD})
31+
@Retention(value = RUNTIME)
3032
public @interface AndroidFindBySet {
3133
/**
3234
* @return an array of {@link io.appium.java_client.pagefactory.AndroidFindBy} which builds a sequence of

src/main/java/io/appium/java_client/pagefactory/AndroidFindBys.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Repeatable;
2020
import java.lang.annotation.Retention;
21-
import java.lang.annotation.RetentionPolicy;
2221
import java.lang.annotation.Target;
2322

23+
import static java.lang.annotation.ElementType.FIELD;
24+
import static java.lang.annotation.ElementType.TYPE;
25+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
26+
2427
/**
2528
* Used to mark a field on a Page Object to indicate that lookup should use
2629
* a series of {@link io.appium.java_client.pagefactory.AndroidFindBy} tags.
2730
*/
28-
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
31+
@Retention(RUNTIME) @Target({FIELD, TYPE})
32+
@Repeatable(AndroidFindByChainSet.class)
2933
public @interface AndroidFindBys {
3034
/**
3135
* It is a set of {@link io.appium.java_client.pagefactory.AndroidFindBy} strategies which build

src/main/java/io/appium/java_client/pagefactory/WindowsFindAll.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
19+
import java.lang.annotation.Repeatable;
2020
import java.lang.annotation.Retention;
21-
import java.lang.annotation.RetentionPolicy;
2221
import java.lang.annotation.Target;
2322

23+
import static java.lang.annotation.ElementType.FIELD;
24+
import static java.lang.annotation.ElementType.TYPE;
25+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
26+
2427
/**
2528
* Used to mark a field on a Page/Screen Object to indicate that lookup should use a series
2629
* of {@link WindowsFindBy} tags
2730
* It will then search for all elements that match any criteria. Note that elements
2831
* are not guaranteed to be in document order.
2932
*/
30-
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
33+
@Retention(RUNTIME) @Target({FIELD, TYPE})
34+
@Repeatable(WindowsFindByAllSet.class)
3135
public @interface WindowsFindAll {
3236
/**
3337
* It is a set of {@link WindowsFindBy} strategies which may be

src/main/java/io/appium/java_client/pagefactory/WindowsFindBy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@
1616

1717
package io.appium.java_client.pagefactory;
1818

19-
import java.lang.annotation.ElementType;
2019
import java.lang.annotation.Repeatable;
2120
import java.lang.annotation.Retention;
22-
import java.lang.annotation.RetentionPolicy;
2321
import java.lang.annotation.Target;
2422

23+
import static java.lang.annotation.ElementType.FIELD;
24+
import static java.lang.annotation.ElementType.TYPE;
25+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
26+
2527
/**
2628
* Used to mark a field on a Page Object to indicate an alternative mechanism for locating the
2729
* element or a list of elements. Used in conjunction with
2830
* {@link org.openqa.selenium.support.PageFactory}
2931
* this allows users to quickly and easily create PageObjects.
3032
* using Windows automation selectors, accessibility, id, name, class name, tag and xpath
3133
*/
32-
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
34+
@Retention(RUNTIME) @Target({FIELD, TYPE})
3335
@Repeatable(WindowsFindBySet.class)
3436
public @interface WindowsFindBy {
3537

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appium.java_client.pagefactory;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.FIELD;
7+
import static java.lang.annotation.ElementType.TYPE;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
/**
11+
* Defines set of chained/possible locators. Each one locator
12+
* should be defined with {@link WindowsFindAll}
13+
*/
14+
@Target(value = {TYPE, FIELD})
15+
@Retention(value = RUNTIME)
16+
public @interface WindowsFindByAllSet {
17+
/**
18+
* @return an array of {@link WindowsFindAll} which builds a sequence of
19+
* the chained searching for elements or a set of possible locators
20+
*/
21+
WindowsFindAll[] value();
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appium.java_client.pagefactory;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.FIELD;
7+
import static java.lang.annotation.ElementType.TYPE;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
/**
11+
* Defines set of chained/possible locators. Each one locator
12+
* should be defined with {@link WindowsFindBys}
13+
*/
14+
@Target(value = {TYPE, FIELD})
15+
@Retention(value = RUNTIME)
16+
public @interface WindowsFindByChainSet {
17+
/**
18+
* @return an array of {@link WindowsFindBys} which builds a sequence of
19+
* the chained searching for elements or a set of possible locators
20+
*/
21+
WindowsFindBys[] value();
22+
}

0 commit comments

Comments
 (0)