Skip to content

Commit a82e24b

Browse files
appium#234 fix and some minor changes
1 parent 6b91363 commit a82e24b

File tree

8 files changed

+133
-33
lines changed

8 files changed

+133
-33
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ If you are working on this project and use Intellij Idea, you need to change the
106106
If you are using the Eclipse IDE, make sure you are using verison Luna or later.
107107

108108
##Changelog##
109+
*3.2.0 (is coming out)*
110+
- updated the dependency on Selenium to version 2.47.1
111+
- the new dependency on commons-validator v1.4.1
112+
- the ability to start programmatically/silently an Appium node server is provided now. Details please read at #240.
113+
Historical reference: [The similar solution](https://github.com/Genium-Framework/Appium-Support) has been designed by @Hassan-Radi.
114+
The mentioned framework and the current solution use different approaches.
115+
- Throwing declarations were added to some searching methods. The __"getMouse"__ method of RemoteWebDriver was marked __Deprecated__
116+
...
109117

110118
*3.1.1*
111119
- Page-object findBy strategies are now aware of which driver (iOS or Android) you are using. For more details see the Pull Request: https://github.com/appium/java-client/pull/213

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>org.seleniumhq.selenium</groupId>
1717
<artifactId>selenium-java</artifactId>
18-
<version>2.46.0</version>
18+
<version>2.47.1</version>
1919
</dependency>
2020
<dependency>
2121
<groupId>junit</groupId>

src/main/java/io/appium/java_client/DefaultGenericMobileDriver.java

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import io.appium.java_client.MobileDriver;
44
import io.appium.java_client.generic.searchcontext.*;
55

6-
import org.openqa.selenium.By;
7-
import org.openqa.selenium.Capabilities;
8-
import org.openqa.selenium.WebElement;
6+
import org.openqa.selenium.*;
7+
import org.openqa.selenium.interactions.Mouse;
98
import org.openqa.selenium.remote.CommandExecutor;
109
import org.openqa.selenium.remote.RemoteWebDriver;
1110
import org.openqa.selenium.remote.Response;
@@ -47,19 +46,31 @@ public T findElementById(String id){
4746
return (T) super.findElementById(id);
4847
}
4948

50-
public T findElementByLinkText(String using) {
49+
/**
50+
* @throws WebDriverException his method doesn't work against native app UI.
51+
*/
52+
public T findElementByLinkText(String using) throws WebDriverException{
5153
return (T) super.findElementByLinkText(using);
5254
}
5355

54-
public List findElementsByLinkText(String using) {
56+
/**
57+
* @throws WebDriverException This method doesn't work against native app UI.
58+
*/
59+
public List findElementsByLinkText(String using) throws WebDriverException{
5560
return super.findElementsByLinkText(using);
5661
}
5762

58-
public T findElementByPartialLinkText(String using) {
63+
/**
64+
* @throws WebDriverException his method doesn't work against native app UI.
65+
*/
66+
public T findElementByPartialLinkText(String using) throws WebDriverException {
5967
return (T) super.findElementByPartialLinkText(using);
6068
}
6169

62-
public List findElementsByPartialLinkText(String using) {
70+
/**
71+
* @throws WebDriverException This method doesn't work against native app UI.
72+
*/
73+
public List findElementsByPartialLinkText(String using) throws WebDriverException {
6374
return super.findElementsByPartialLinkText(using);
6475
}
6576

@@ -87,11 +98,17 @@ public List findElementsByClassName(String using) {
8798
return super.findElementsByClassName(using);
8899
}
89100

90-
public T findElementByCssSelector(String using) {
101+
/**
102+
* @throws WebDriverException his method doesn't work against native app UI.
103+
*/
104+
public T findElementByCssSelector(String using) throws WebDriverException{
91105
return (T) super.findElementByCssSelector(using);
92106
}
93107

94-
public List findElementsByCssSelector(String using) {
108+
/**
109+
* @throws WebDriverException This method doesn't work against native app UI.
110+
*/
111+
public List findElementsByCssSelector(String using) throws WebDriverException{
95112
return super.findElementsByCssSelector(using);
96113
}
97114

@@ -104,12 +121,26 @@ public List findElementsByXPath(String using) {
104121
}
105122

106123
@Override
107-
public T findElementByAccessibilityId(String using) {
124+
/**
125+
* @throws WebDriverException This method is not applicable with browser/webview UI.
126+
*/
127+
public T findElementByAccessibilityId(String using) throws WebDriverException {
108128
return (T) findElement("accessibility id", using);
109129
}
110130

111131
@Override
112-
public List findElementsByAccessibilityId(String using) {
132+
/**
133+
* @throws WebDriverException This method is not applicable with browser/webview UI.
134+
*/
135+
public List findElementsByAccessibilityId(String using) throws WebDriverException{
113136
return (List<T>) findElements("accessibility id", using);
114137
}
138+
139+
/**
140+
* Mouse doesn't work on mobile devices and emulators
141+
*/
142+
@Deprecated
143+
public Mouse getMouse(){
144+
return super.getMouse();
145+
}
115146
}

src/main/java/io/appium/java_client/DefaultGenericMobileElement.java

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.Map;
1414

1515
import org.openqa.selenium.By;
16+
import org.openqa.selenium.WebDriverException;
1617
import org.openqa.selenium.WebElement;
1718
import org.openqa.selenium.remote.RemoteWebElement;
1819
import org.openqa.selenium.remote.Response;
@@ -47,19 +48,31 @@ public T findElementById(String id){
4748
return (T) super.findElementById(id);
4849
}
4950

50-
public T findElementByLinkText(String using) {
51+
/**
52+
* @throws WebDriverException his method doesn't work against native app UI.
53+
*/
54+
public T findElementByLinkText(String using) throws WebDriverException {
5155
return (T) super.findElementByLinkText(using);
5256
}
5357

54-
public List findElementsByLinkText(String using) {
58+
/**
59+
* @throws WebDriverException This method doesn't work against native app UI.
60+
*/
61+
public List findElementsByLinkText(String using) throws WebDriverException{
5562
return super.findElementsByLinkText(using);
5663
}
5764

58-
public T findElementByPartialLinkText(String using) {
65+
/**
66+
* @throws WebDriverException his method doesn't work against native app UI.
67+
*/
68+
public T findElementByPartialLinkText(String using) throws WebDriverException {
5969
return (T) super.findElementByPartialLinkText(using);
6070
}
6171

62-
public List findElementsByPartialLinkText(String using) {
72+
/**
73+
* @throws WebDriverException This method doesn't work against native app UI.
74+
*/
75+
public List findElementsByPartialLinkText(String using) throws WebDriverException {
6376
return super.findElementsByPartialLinkText(using);
6477
}
6578

@@ -87,11 +100,17 @@ public List findElementsByClassName(String using) {
87100
return super.findElementsByClassName(using);
88101
}
89102

90-
public T findElementByCssSelector(String using) {
103+
/**
104+
* @throws WebDriverException his method doesn't work against native app UI.
105+
*/
106+
public T findElementByCssSelector(String using) throws WebDriverException{
91107
return (T) super.findElementByCssSelector(using);
92108
}
93109

94-
public List findElementsByCssSelector(String using) {
110+
/**
111+
* @throws WebDriverException This method doesn't work against native app UI.
112+
*/
113+
public List findElementsByCssSelector(String using) throws WebDriverException{
95114
return super.findElementsByCssSelector(using);
96115
}
97116

@@ -112,4 +131,18 @@ public T findElementByAccessibilityId(String using) {
112131
public List findElementsByAccessibilityId(String using) {
113132
return (List<T>) findElements("accessibility id", using);
114133
}
134+
135+
/**
136+
* @throws WebDriverException because it may not work against native app UI.
137+
*/
138+
public void submit() throws WebDriverException{
139+
super.submit();
140+
}
141+
142+
/**
143+
* @throws WebDriverException because it may not work against native app UI.
144+
*/
145+
public String getCssValue(String propertyName) throws WebDriverException{
146+
return super.getCssValue(propertyName);
147+
}
115148
}

src/main/java/io/appium/java_client/android/AndroidDriver.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.appium.java_client.service.local.AppiumDriverLocalService;
1313
import io.appium.java_client.service.local.AppiumServiceBuilder;
1414
import org.openqa.selenium.Capabilities;
15+
import org.openqa.selenium.WebDriverException;
1516
import org.openqa.selenium.WebElement;
1617
import org.openqa.selenium.remote.Response;
1718

@@ -278,17 +279,23 @@ public void toggleLocationServices() {
278279
// Should be moved to the subclass
279280
public void ignoreUnimportantViews(Boolean compress) {
280281
setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress);
281-
}
282-
282+
}
283+
284+
/**
285+
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
286+
*/
283287
@SuppressWarnings("unchecked")
284288
@Override
285-
public RequiredElementType findElementByAndroidUIAutomator(String using) {
289+
public RequiredElementType findElementByAndroidUIAutomator(String using) throws WebDriverException {
286290
return (RequiredElementType) findElement("-android uiautomator", using);
287291
}
288292

293+
/**
294+
* @throws WebDriverException This method is not applicable with browser/webview UI.
295+
*/
289296
@SuppressWarnings("unchecked")
290297
@Override
291-
public List<RequiredElementType> findElementsByAndroidUIAutomator(String using) {
298+
public List<RequiredElementType> findElementsByAndroidUIAutomator(String using) throws WebDriverException {
292299
return (List<RequiredElementType>) findElements("-android uiautomator", using);
293300
}
294301

src/main/java/io/appium/java_client/android/AndroidElement.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.openqa.selenium.WebDriverException;
67
import org.openqa.selenium.WebElement;
78

89
import io.appium.java_client.FindsByAndroidUIAutomator;
@@ -11,14 +12,20 @@
1112

1213
public class AndroidElement extends MobileElement implements
1314
FindsByAndroidUIAutomator<MobileElement> {
14-
15+
16+
/**
17+
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
18+
*/
1519
@Override
16-
public MobileElement findElementByAndroidUIAutomator(String using) {
20+
public MobileElement findElementByAndroidUIAutomator(String using) throws WebDriverException {
1721
return (MobileElement) findElement("-android uiautomator", using);
1822
}
1923

24+
/**
25+
* @throws WebDriverException This method is not applicable with browser/webview UI.
26+
*/
2027
@Override
21-
public List<MobileElement> findElementsByAndroidUIAutomator(String using) {
28+
public List<MobileElement> findElementsByAndroidUIAutomator(String using) throws WebDriverException {
2229
List<MobileElement> result = new ArrayList<MobileElement>();
2330
List<WebElement> found = findElements("-android uiautomator", using);
2431
for (WebElement e: found)

src/main/java/io/appium/java_client/ios/IOSDriver.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.appium.java_client.service.local.AppiumDriverLocalService;
1313
import io.appium.java_client.service.local.AppiumServiceBuilder;
1414
import org.openqa.selenium.Capabilities;
15+
import org.openqa.selenium.WebDriverException;
1516
import org.openqa.selenium.WebElement;
1617

1718
import java.net.URL;
@@ -106,8 +107,8 @@ public void hideKeyboard(String keyName) {
106107
@Override
107108
public void shake() {
108109
execute(SHAKE);
109-
}
110-
110+
}
111+
111112
/**
112113
* @see GetsNamedTextField#getNamedTextField(String)
113114
*/
@@ -121,16 +122,22 @@ public RequiredElementType getNamedTextField(String name) {
121122
}
122123
return element;
123124
}
124-
125+
126+
/**
127+
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
128+
*/
125129
@SuppressWarnings("unchecked")
126130
@Override
127-
public RequiredElementType findElementByIosUIAutomation(String using) {
131+
public RequiredElementType findElementByIosUIAutomation(String using) throws WebDriverException {
128132
return (RequiredElementType) findElement("-ios uiautomation", using);
129133
}
130134

135+
/**
136+
* @throws WebDriverException This method is not applicable with browser/webview UI.
137+
*/
131138
@SuppressWarnings("unchecked")
132139
@Override
133-
public List<RequiredElementType> findElementsByIosUIAutomation(String using) {
140+
public List<RequiredElementType> findElementsByIosUIAutomation(String using) throws WebDriverException {
134141
return (List<RequiredElementType>) findElements("-ios uiautomation", using);
135142
}
136143
}

src/main/java/io/appium/java_client/ios/IOSElement.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.appium.java_client.MobileElement;
66
import io.appium.java_client.ScrollsTo;
77

8+
import org.openqa.selenium.WebDriverException;
89
import org.openqa.selenium.WebElement;
910

1011
import com.google.common.collect.ImmutableMap;
@@ -14,14 +15,20 @@
1415

1516
public class IOSElement extends MobileElement implements
1617
FindsByIosUIAutomation<MobileElement>, ScrollsTo<MobileElement> {
17-
18+
19+
/**
20+
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
21+
*/
1822
@Override
19-
public MobileElement findElementByIosUIAutomation(String using) {
23+
public MobileElement findElementByIosUIAutomation(String using) throws WebDriverException {
2024
return (IOSElement) findElement("-ios uiautomation", using);
2125
}
2226

27+
/**
28+
* @throws WebDriverException This method is not applicable with browser/webview UI.
29+
*/
2330
@Override
24-
public List<MobileElement> findElementsByIosUIAutomation(String using) {
31+
public List<MobileElement> findElementsByIosUIAutomation(String using) throws WebDriverException {
2532
List<MobileElement> result = new ArrayList<MobileElement>();
2633
List<WebElement> found = findElements("-ios uiautomation", using);
2734
for (WebElement e: found)

0 commit comments

Comments
 (0)