Skip to content

Commit 6fa95e0

Browse files
Merge pull request #546 from SrinivasanTarget/TikhomirovSergeyXCUITFindBy
Addition to #545
2 parents bee9a34 + 6bd6184 commit 6fa95e0

File tree

14 files changed

+394
-144
lines changed

14 files changed

+394
-144
lines changed

.travis.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ language: java
33
jdk:
44
- oraclejdk8
55

6-
before_cache:
7-
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
8-
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
9-
cache:
10-
directories:
11-
- $HOME/.gradle/caches/
12-
- $HOME/.gradle/wrapper/
13-
14-
script:
15-
- ./gradlew clean build -x test
6+
sudo: required
7+
8+
install: true
9+
10+
script: ./gradlew clean build -x test -x signArchives

build.gradle

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apply plugin: 'java'
22
apply plugin: 'maven'
33
apply plugin: 'eclipse'
44
apply plugin: 'jacoco'
5-
apply plugin: 'maven-publish'
65
apply plugin: 'checkstyle'
6+
apply plugin: 'signing'
77

88
group 'io.appium'
99
version '5.0.0-SNAPSHOT'
@@ -122,78 +122,85 @@ tasks.withType(Checkstyle) {
122122
exclude '**/org/openqa/selenium/**'
123123
}
124124

125-
task javadocs(type: Javadoc) {
126-
source = sourceSets.main.java
127-
}
128-
129-
publishing {
130-
publications {
131-
mavenJava(MavenPublication) {
132-
pom.withXml {
133-
asNode().children().last() + {
134-
resolveStrategy = Closure.DELEGATE_FIRST
135-
name 'java-client'
136-
description 'Java client for Appium Mobile Webdriver'
137-
url 'http://appium.io'
138-
developers {
139-
developer {
140-
name 'Jonah Stiennon'
141-
142-
url 'https://github.com/jonahss'
143-
id 'jonahss'
144-
};
145-
developer {
146-
name 'Sergey Tikhomirov'
147-
148-
url 'https://github.com/TikhomirovSergey'
149-
id 'TikhomirovSergey'
150-
};
151-
developer {
152-
name 'Srinivasan Sekar'
153-
154-
url 'https://github.com/SrinivasanTarget'
155-
id 'SrinivasanTarget'
156-
};
157-
}
158-
licenses {
159-
license {
160-
name 'Apache License, Version 2.0'
161-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
162-
distribution 'repo'
163-
}
164-
}
165-
scm {
166-
url 'https://github.com/appium/java-client'
167-
connection 'scm:git:ssh://[email protected]/appium/java-client.git'
168-
developerConnection 'scm:git:ssh://[email protected]/appium/java-client.git'
169-
tag 'HEAD'
170-
}
171-
}
125+
task javadocJar(type: Jar) {
126+
classifier = 'javadoc'
127+
from javadoc
128+
}
129+
130+
task sourcesJar(type: Jar) {
131+
classifier = 'sources'
132+
from sourceSets.main.allSource
133+
}
134+
135+
artifacts {
136+
archives javadocJar, sourcesJar
137+
}
138+
139+
signing {
140+
sign configurations.archives
141+
}
142+
143+
uploadArchives {
144+
repositories {
145+
mavenDeployer {
146+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
147+
148+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
149+
authentication(userName: ossrhUsername, password: ossrhPassword)
172150
}
173-
from components.java
174-
artifact sourceJar {
175-
classifier 'sources'
151+
152+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
153+
authentication(userName: ossrhUsername, password: ossrhPassword)
176154
}
177-
artifact javadocJar {
178-
classifier 'javadoc'
155+
156+
pom.project {
157+
packaging 'jar'
158+
name 'java-client'
159+
description 'Java client for Appium Mobile Webdriver'
160+
url 'http://appium.io'
161+
developers {
162+
developer {
163+
name 'Jonah Stiennon'
164+
165+
url 'https://github.com/jonahss'
166+
id 'jonahss'
167+
};
168+
developer {
169+
name 'Sergey Tikhomirov'
170+
171+
url 'https://github.com/TikhomirovSergey'
172+
id 'TikhomirovSergey'
173+
};
174+
developer {
175+
name 'Srinivasan Sekar'
176+
177+
url 'https://github.com/SrinivasanTarget'
178+
id 'SrinivasanTarget'
179+
};
180+
}
181+
licenses {
182+
license {
183+
name 'Apache License, Version 2.0'
184+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
185+
distribution 'repo'
186+
}
187+
}
188+
scm {
189+
url 'https://github.com/appium/java-client'
190+
connection 'scm:git:ssh://[email protected]/appium/java-client.git'
191+
developerConnection 'scm:git:ssh://[email protected]/appium/java-client.git'
192+
tag 'HEAD'
193+
}
179194
}
180195
}
181196
}
182197
}
183198

184-
task sourceJar(type: Jar) {
185-
from sourceSets.main.java
186-
}
187-
188-
task javadocJar (type: Jar, dependsOn: javadoc) {
189-
from javadoc
190-
}
191-
192199
task wrapper(type: Wrapper) {
193200
gradleVersion = '2.14.1'
194201
description 'Generates the Gradle wrapper scripts.'
195202
}
196203

197204
test {
198205
useJUnit()
199-
}
206+
}

google-style.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
</module>
159159
<module name="AbbreviationAsWordInName">
160160
<property name="ignoreFinal" value="false"/>
161-
<property name="allowedAbbreviationLength" value="5"/>
161+
<property name="allowedAbbreviationLength" value="8"/>
162162
</module>
163163
<module name="OverloadMethodsDeclarationOrder"/>
164164
<module name="VariableDeclarationUsageDistance"/>

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
org.gradle.daemon=true
2+
3+
signing.keyId=YourKeyId
4+
signing.password=YourPublicKeyPassword
5+
signing.secretKeyRingFile=PathToYourKeyRingFile
6+
7+
ossrhUsername=your-jira-id
8+
ossrhPassword=your-jira-password

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static io.appium.java_client.pagefactory.utils.WebDriverUnpackUtility
2222
.unpackWebDriverFromSearchContext;
2323

24+
import com.google.common.collect.ImmutableList;
25+
2426
import io.appium.java_client.HasSessionDetails;
2527
import io.appium.java_client.MobileElement;
2628
import io.appium.java_client.TouchableElement;
@@ -58,22 +60,9 @@
5860
*/
5961
public class AppiumFieldDecorator implements FieldDecorator {
6062

61-
private static final List<Class<? extends WebElement>> availableElementClasses =
62-
new ArrayList<Class<? extends WebElement>>() {
63-
private static final long serialVersionUID = 1L;
64-
65-
{
66-
add(WebElement.class);
67-
add(RemoteWebElement.class);
68-
add(MobileElement.class);
69-
add(TouchableElement.class);
70-
add(AndroidElement.class);
71-
add(IOSElement.class);
72-
add(WindowsElement.class);
73-
}
74-
75-
};
76-
63+
private static final List<Class<? extends WebElement>> availableElementClasses = ImmutableList.of(WebElement.class,
64+
RemoteWebElement.class, MobileElement.class, TouchableElement.class, AndroidElement.class,
65+
IOSElement.class, WindowsElement.class);
7766
public static long DEFAULT_IMPLICITLY_WAIT_TIMEOUT = 1;
7867
public static TimeUnit DEFAULT_TIMEUNIT = TimeUnit.SECONDS;
7968
private final WebDriver originalDriver;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ private static By buildMobileBy(LocatorGroupStrategy locatorGroupStrategy, Annot
176176
}
177177
}
178178

179+
if (isIOSXcuit()) {
180+
iOSXCUITFindBy[] xCuitFindByArray = annotatedElement.getAnnotationsByType(iOSXCUITFindBy.class);
181+
if (xCuitFindByArray != null && xCuitFindByArray.length > 0) {
182+
return buildMobileBy(howToUseLocators != null ? howToUseLocators.iOSXCUITAutomation() : null,
183+
xCuitFindByArray);
184+
}
185+
}
186+
179187
if (isIOS()) {
180188
iOSFindBy[] iOSFindByArray = annotatedElement.getAnnotationsByType(iOSFindBy.class);
181189
//should be kept for some time

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,11 @@
5050
* or the searching by all possible locators.
5151
*/
5252
LocatorGroupStrategy windowsAutomation() default LocatorGroupStrategy.CHAIN;
53+
54+
/**
55+
* @return the strategy which defines how to use locators which are described by
56+
* the {@link iOSXCUITFindBy} annotation. These annotations can define the chained searching
57+
* or the searching by all possible locators.
58+
*/
59+
LocatorGroupStrategy iOSXCUITAutomation() default LocatorGroupStrategy.CHAIN;
5360
}

src/main/java/io/appium/java_client/pagefactory/bys/builder/AppiumByBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.appium.java_client.pagefactory.bys.builder;
1818

19+
import static io.appium.java_client.remote.AutomationName.IOS_XCUI_TEST;
1920
import static io.appium.java_client.remote.AutomationName.SELENDROID;
2021
import static io.appium.java_client.remote.MobilePlatform.ANDROID;
2122
import static io.appium.java_client.remote.MobilePlatform.IOS;
@@ -180,6 +181,10 @@ protected boolean isIOS() {
180181
return IOS.equalsIgnoreCase(platform);
181182
}
182183

184+
protected boolean isIOSXcuit() {
185+
return isIOS() && IOS_XCUI_TEST.equalsIgnoreCase(automation);
186+
}
187+
183188
protected boolean isWindows() {
184189
return WINDOWS.equalsIgnoreCase(platform);
185190
}

src/main/java/io/appium/java_client/pagefactory/bys/builder/Strategies.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ enum Strategies {
9090
return MobileBy
9191
.windowsAutomation(getValue(annotation, this));
9292
}
93+
},
94+
BY_NS_PREDICATE("iOSNsPredicate") {
95+
@Override By getBy(Annotation annotation) {
96+
return MobileBy
97+
.iOSNsPredicateString(getValue(annotation, this));
98+
}
9399
};
94100

95101
private final String valueName;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.pagefactory;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Repeatable;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE})
26+
@Repeatable(iOSXCUITFindBySet.class)
27+
public @interface iOSXCUITFindBy {
28+
29+
/**
30+
* The NSPredicate class is used to define logical conditions used to constrain
31+
* a search either for a fetch or for in-memory filtering.
32+
*/
33+
String iOSNsPredicate() default "";
34+
35+
/**
36+
* It an UI automation accessibility Id which is a convenient to iOS.
37+
* About iOS accessibility
38+
* See <a href="https://goo.gl/a3AivX">UIAccessibilityIdentification</a>
39+
*/
40+
String accessibility() default "";
41+
42+
/**
43+
* It is an id of the target element.
44+
*/
45+
String id() default "";
46+
47+
/**
48+
* It is a name of a type/class of the target element.
49+
*/
50+
String className() default "";
51+
52+
/**
53+
* It is a desired element tag.
54+
*/
55+
String tagName() default "";
56+
57+
/**
58+
* It is a xpath to the target element.
59+
*/
60+
String xpath() default "";
61+
}

0 commit comments

Comments
 (0)