Java-client 4.0.0 released

Hi everebody!
Long waited Java-client version 4.0.0 has been released. There are many changes. The maiin difference is that it is not compatible with Appium server v<1.5.0. Also some API was improved.

Change list:

  • all code marked @Deprecated was removed. Java client won’t support old servers (v<1.5.0)
    anymore.

  • the ability to start an activity using Android intent actions, intent categories, flags and arguments
    was added to AndroidDriver. Thanks to @saikrishna321 for the contribution.

  • scrollTo() and scrollToExact() became deprecated. They are going to be removed in the next release.

  • The interface io.appium.java_client.ios.GetsNamedTextField and the declared method T getNamedTextField(String name) are deprecated as well. They are going to be removed in the next release.

  • Methods findElements(String by, String using) and findElement(String by, String using) of org.openga.selenium.remote.RemoteWebdriver are public now. Thanks to @SrinivasanTarget.

  • the io.appium.java_client.NetworkConnectionSetting class was marked deprecated

  • the enum io.appium.java_client.android.Connection was added. All supported network bitmasks are defined there.

  • Android. Old methods which get/set connection were marked @Deprecated

  • Android. New methods which consume/return io.appium.java_client.android.Connection were added.

  • the commandRepository field is public now. The modification of the MobileCommand

  • Constructors like AppiumDriver(HttpCommandExecutor executor, Capabilities capabilities) were added to
    io.appium.java_client.android.AndroidDriver and io.appium.java_client.ios.IOSDriver

  • The refactoring of io.appium.java_client.internal.JsonToMobileElementConverter. Now it accepts
    org.openqa.selenium.remote.RemoteWebDriver as the constructor parameter. It is possible to re-use
    io.appium.java_client.android.internal.JsonToAndroidElementConverter or
    io.appium.java_client.ios.internal.JsonToIOSElementConverter by RemoteWebDriver when it is needed.

  • Constructors of the abstract io.appium.java_client.AppiumDriver were redesigned. Now they require
    a subclass of io.appium.java_client.internal.JsonToMobileElementConverter. Constructors of
    io.appium.java_client.android.AndroidDriver and io.appium.java_client.ios.IOSDriver are same still.

  • The pushFile(String remotePath, File file) was added to AndroidDriver

  • FIX of TouchAction. Instances of the TouchAction class are reusable now

  • FIX of the swiping issue (iOS, server version >= 1.5.0). Now the swiping is implemented differently by
    AndroidDriver and IOSDriver. Thanks to @truebit and @nuggit32 for the catching.

  • the project was integrated with maven-checkstyle-plugin. Thanks to @SrinivasanTarget for the work

  • source code was improved according to code style checking rules.

  • the integration with org.owasp dependency-check-maven was added. Thanks to @saikrishna321
    for the work.

  • the integration with org.jacoco jacoco-maven-plugin was added. Thanks to @SrinivasanTarget for the contribution.

Tons of thanks to @SrinivasanSekar ( @SrinivasanTarget ) for the helping and some new ideas.

Also now the project has WIKI pages. These docs are suppused to be updated according to new changes.

4 Likes

4.1.0 is supposed to be the next release. You can take a look at the general scope. 4.1.0.

Also we have the scope of changes for the further development.

2 Likes

only one question:

  • in previous version 3.4.0 swipe with iOS (Android did not check yet) use relative end_x and end_y. why now it is absolute?

logs:
x_start = 370
y_start = 365
x_end = -50
y_end = 0

[HTTP] --> POST /wd/hub/session/fae04618-1d88-4257-87fe-147a21be062d/touch/perform {“actions”:[{“action”:“press”,“options”:{“x”:370,“y”:365}},{“action”:“wait”,“options”:{“ms”:100}},{“action”:“moveTo”,“options”:{“x”:-420,“y”:-365}},{“action”:“release”,“options”:{}}]}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{“action”:“press”,“options”:{“x”:370,“y”:365}},{“action”:“wait”,“options”:{“ms”:100}},{“action”:“moveTo”,“options”:{“x”:-420,“y”:-365}},{“action”…

It had being working with absolute values until 1.5.0 was released. There is a closed issue:

Please take a look at linked issues. Now it is still woking with absolute values. They are turned into relative values by IOSDriver.

in both cases i am using 1.5.2 server. iOS Swipe with 3.4.0 is relative, with 4.0.0 is absolute.

But it seems many other users had used absolute coordinates before 1.5.0 was released. I was forced to buid and share a temporary snapshot there: https://github.com/appium/java-client/issues/350#issuecomment-212070766 in order to keep their code working

do not mind against absolute just was wonder why again changed (absolute->relative->absolute). thanks.

@SergeyTichomirov, since scrollTo is going to be obsolete method in coming release. so what is alternative to do? we need to again switch to jsExecutor?

also, driver.swipe(int i,int i,int i2,int i3,int i4); which is not provide info about which one is starting and ending co-ordinates.

@Priyank_Shah
You can use By-searches. Examples:
Android: https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidSearchingTest.java#L58
https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidElementTest.java#L68

iOS: https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/ios/IOSScrollingSearchingTest.java

Actually these methods use the same approach. But locators were hardcoded and people were complaining. It was not working for many specific cases. We could not find the generic solution, so we decided to remove these methods later and warn users now.

oh… good to hear, now we can customized Android UIAutomator with scrollableview.
Thanks for explanation.

migrated to 4.0.0 smoothly! just great. (only minor swipe iOS issue)
PS we have Android and iOS suites.

Hey guys after updating to java client 4.0.0 and Appium version 1.5.2 this no longer works.

JavascriptExecutor js = (JavascriptExecutor) this.getIOSDriver(); HashMap<String, String> scrollObject = new HashMap<String, String>(); scrollObject.put("direction", "up"); scrollObject.put("element", ((RemoteWebElement) element).getId()); js.executeScript("mobile: scroll", scrollObject);

I get a error as the following on the execute step.

org.openqa.selenium.WebDriverException: Unexpected error in -[UIATableCell_0x7fa0d2b4ec10 scrollUp], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIAutomation_Sim/UIAutomation-449.2/Framework/UIAElement.m line 1473, kAXErrorSuccess (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 941 milliseconds
Build info: version: ‘2.53.0’, revision: ‘35ae25b1534ae328c771e0856c93e187490ca824’, time: ‘2016-03-15 10:43:46’
System info: host: ‘MacBook-Pro-3.local’, ip: ‘10.93.90.89’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.4’, java.version: ‘1.8.0_60’
Driver info: io.appium.java_client.ios.IOSDriver
Capabilities [{app=/Users/tempautomation/Desktop/emulatedappfile/sapporo.ipa, networkConnectionEnabled=false, noReset=true, bundleId=com.temp.sapporo3, keepKeyChains=false, databaseEnabled=false, deviceName=iPhone 6, launchTimeout=150000, fullReset=false, platform=MAC, desired={app=/Users/tempautomation/Desktop/emulatedappfile/sapporo.ipa, noReset=true, newCommandTimeout=120, platformVersion=9.3, bundleId=com.zaid.com, browserName=, waitForAppScript=true;, keepKeyChains=false, platformName=iOS, deviceName=iPhone 6, launchTimeout=150000, fullReset=false}, newCommandTimeout=120, platformVersion=9.3, webStorageEnabled=false, locationContextEnabled=false, browserName=, takesScreenshot=true, waitForAppScript=true;, javascriptEnabled=true, platformName=iOS}]
Session ID: f8e3e73b-5fc4-4063-ab03-302df16d007c

Well, NetworkConnectionSettings now is deprecated, can someone tell me how to switch wifi off/on? Its just enum Connection, any ideas?

Hi .
so from now on , we need to write the scrollTo by using “AndroidUIAutomator” and “IosUIAutomation” only ?

You are free to use touch actions as well.