Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ If you are working on this project and use Intellij Idea, you need to change the
If you are using the Eclipse IDE, make sure you are using verison Luna or later.

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

*3.1.1*
- 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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.46.0</version>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import io.appium.java_client.MobileDriver;
import io.appium.java_client.generic.searchcontext.*;

import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Mouse;
import org.openqa.selenium.remote.CommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.Response;
Expand Down Expand Up @@ -47,19 +46,31 @@ public T findElementById(String id){
return (T) super.findElementById(id);
}

public T findElementByLinkText(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByLinkText(String using) throws WebDriverException{
return (T) super.findElementByLinkText(using);
}

public List findElementsByLinkText(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByLinkText(String using) throws WebDriverException{
return super.findElementsByLinkText(using);
}

public T findElementByPartialLinkText(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByPartialLinkText(String using) throws WebDriverException {
return (T) super.findElementByPartialLinkText(using);
}

public List findElementsByPartialLinkText(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByPartialLinkText(String using) throws WebDriverException {
return super.findElementsByPartialLinkText(using);
}

Expand Down Expand Up @@ -87,11 +98,17 @@ public List findElementsByClassName(String using) {
return super.findElementsByClassName(using);
}

public T findElementByCssSelector(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByCssSelector(String using) throws WebDriverException{
return (T) super.findElementByCssSelector(using);
}

public List findElementsByCssSelector(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByCssSelector(String using) throws WebDriverException{
return super.findElementsByCssSelector(using);
}

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

@Override
public T findElementByAccessibilityId(String using) {
/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
public T findElementByAccessibilityId(String using) throws WebDriverException {
return (T) findElement("accessibility id", using);
}

@Override
public List findElementsByAccessibilityId(String using) {
/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
public List findElementsByAccessibilityId(String using) throws WebDriverException{
return (List<T>) findElements("accessibility id", using);
}

/**
* Mouse doesn't work on mobile devices and emulators
*/
@Deprecated
public Mouse getMouse(){
return super.getMouse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Map;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.remote.Response;
Expand Down Expand Up @@ -47,19 +48,31 @@ public T findElementById(String id){
return (T) super.findElementById(id);
}

public T findElementByLinkText(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByLinkText(String using) throws WebDriverException {
return (T) super.findElementByLinkText(using);
}

public List findElementsByLinkText(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByLinkText(String using) throws WebDriverException{
return super.findElementsByLinkText(using);
}

public T findElementByPartialLinkText(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByPartialLinkText(String using) throws WebDriverException {
return (T) super.findElementByPartialLinkText(using);
}

public List findElementsByPartialLinkText(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByPartialLinkText(String using) throws WebDriverException {
return super.findElementsByPartialLinkText(using);
}

Expand Down Expand Up @@ -87,11 +100,17 @@ public List findElementsByClassName(String using) {
return super.findElementsByClassName(using);
}

public T findElementByCssSelector(String using) {
/**
* @throws WebDriverException his method doesn't work against native app UI.
*/
public T findElementByCssSelector(String using) throws WebDriverException{
return (T) super.findElementByCssSelector(using);
}

public List findElementsByCssSelector(String using) {
/**
* @throws WebDriverException This method doesn't work against native app UI.
*/
public List findElementsByCssSelector(String using) throws WebDriverException{
return super.findElementsByCssSelector(using);
}

Expand All @@ -112,4 +131,18 @@ public T findElementByAccessibilityId(String using) {
public List findElementsByAccessibilityId(String using) {
return (List<T>) findElements("accessibility id", using);
}

/**
* @throws WebDriverException because it may not work against native app UI.
*/
public void submit() throws WebDriverException{
super.submit();
}

/**
* @throws WebDriverException because it may not work against native app UI.
*/
public String getCssValue(String propertyName) throws WebDriverException{
return super.getCssValue(propertyName);
}
}
15 changes: 11 additions & 4 deletions src/main/java/io/appium/java_client/android/AndroidDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.Response;

Expand Down Expand Up @@ -278,17 +279,23 @@ public void toggleLocationServices() {
// Should be moved to the subclass
public void ignoreUnimportantViews(Boolean compress) {
setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress);
}

}

/**
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
*/
@SuppressWarnings("unchecked")
@Override
public RequiredElementType findElementByAndroidUIAutomator(String using) {
public RequiredElementType findElementByAndroidUIAutomator(String using) throws WebDriverException {
return (RequiredElementType) findElement("-android uiautomator", using);
}

/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
@SuppressWarnings("unchecked")
@Override
public List<RequiredElementType> findElementsByAndroidUIAutomator(String using) {
public List<RequiredElementType> findElementsByAndroidUIAutomator(String using) throws WebDriverException {
return (List<RequiredElementType>) findElements("-android uiautomator", using);
}

Expand Down
13 changes: 10 additions & 3 deletions src/main/java/io/appium/java_client/android/AndroidElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

import io.appium.java_client.FindsByAndroidUIAutomator;
Expand All @@ -11,14 +12,20 @@

public class AndroidElement extends MobileElement implements
FindsByAndroidUIAutomator<MobileElement> {


/**
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
*/
@Override
public MobileElement findElementByAndroidUIAutomator(String using) {
public MobileElement findElementByAndroidUIAutomator(String using) throws WebDriverException {
return (MobileElement) findElement("-android uiautomator", using);
}

/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
@Override
public List<MobileElement> findElementsByAndroidUIAutomator(String using) {
public List<MobileElement> findElementsByAndroidUIAutomator(String using) throws WebDriverException {
List<MobileElement> result = new ArrayList<MobileElement>();
List<WebElement> found = findElements("-android uiautomator", using);
for (WebElement e: found)
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/io/appium/java_client/ios/IOSDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

import java.net.URL;
Expand Down Expand Up @@ -106,8 +107,8 @@ public void hideKeyboard(String keyName) {
@Override
public void shake() {
execute(SHAKE);
}
}

/**
* @see GetsNamedTextField#getNamedTextField(String)
*/
Expand All @@ -121,16 +122,22 @@ public RequiredElementType getNamedTextField(String name) {
}
return element;
}


/**
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
*/
@SuppressWarnings("unchecked")
@Override
public RequiredElementType findElementByIosUIAutomation(String using) {
public RequiredElementType findElementByIosUIAutomation(String using) throws WebDriverException {
return (RequiredElementType) findElement("-ios uiautomation", using);
}

/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
@SuppressWarnings("unchecked")
@Override
public List<RequiredElementType> findElementsByIosUIAutomation(String using) {
public List<RequiredElementType> findElementsByIosUIAutomation(String using) throws WebDriverException {
return (List<RequiredElementType>) findElements("-ios uiautomation", using);
}
}
13 changes: 10 additions & 3 deletions src/main/java/io/appium/java_client/ios/IOSElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.appium.java_client.MobileElement;
import io.appium.java_client.ScrollsTo;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;

import com.google.common.collect.ImmutableMap;
Expand All @@ -14,14 +15,20 @@

public class IOSElement extends MobileElement implements
FindsByIosUIAutomation<MobileElement>, ScrollsTo<MobileElement> {


/**
* @throws org.openqa.selenium.WebDriverException This method is not applicable with browser/webview UI.
*/
@Override
public MobileElement findElementByIosUIAutomation(String using) {
public MobileElement findElementByIosUIAutomation(String using) throws WebDriverException {
return (IOSElement) findElement("-ios uiautomation", using);
}

/**
* @throws WebDriverException This method is not applicable with browser/webview UI.
*/
@Override
public List<MobileElement> findElementsByIosUIAutomation(String using) {
public List<MobileElement> findElementsByIosUIAutomation(String using) throws WebDriverException {
List<MobileElement> result = new ArrayList<MobileElement>();
List<WebElement> found = findElements("-ios uiautomation", using);
for (WebElement e: found)
Expand Down