Java-client version 3.2.0 released

The major change for this version is that Sergey has added the ability to programmatically start/stop the appium server from the java client. It’s pretty great!

See https://github.com/appium/java-client/pull/240 for tons of information.

Basically, there are new constructors for AppiumDriver class which will allow you to specify how to start the appium server.
The current constructor didn’t change so this won’t disrupt anybody’s setup :smile:

3.2.0

  • 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. Historical reference: The similar solution has been designed by @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
  • Add replaceValue method for elements.
  • Replace SendKeyEvent() with: pressKeyCode(int key), pressKeyCode(int key, Integer metastate), longPressKeyCode(int key), longPressKeyCode(int key, Integer metastate)
6 Likes

in doc:
“Replace sendKeyEvent() method in android with pressKey() and added longPressKey() method.”

actually:

  • pressKeyCode(int key)
  • pressKeyCode(int key, Integer metastate)
  • longPressKeyCode(int key)
  • longPressKeyCode(int key, Integer metastate)
2 Likes

Congratulations on one more successful release. Great job guys Sergey and Jonahss.

Best Regards,
Vikram

This is an Awesome update.Great Job Team !!!

I just tried the new 3.2 and the appium server works absolutely fine without any issues. I have recorded a tutorial on the same if anyone needs step by step information can go through the youtube video from below link:

Thanks,
Raman
http://www.way2automation.com

5 Likes

This is the good work :+1:

I’m also going to add some new samples here

Here is a PR with sample update:

I hope it will help you to add new chapters to your tutorial :smile:

HI All,

I have upgraded my Appium from 1.4.8 to 1.4.12. Can any one help in launching appium programatically in MAC , enabling developer setting so that AppiumJS package points to the new build.

Thanks
Sunny

Check this thread.

There is one more interesting conversation

Any help would be appropriated

I need to click or tap on Go/Done button on android s3 device which running 4.3 version

I tried all sorts of option

  1. driver.pressKeyEvent(66) or driver.pressKeyEvent(AndroidKeyCode.ENTER)
  2. Driver.sendKeyEvent(66)
  3. driver.execute(“mobile:keyevent”, “keycode:66”);

I manage to click on all keys except Go/Done button

Environments
Appium version - 1.4.13
Java 1.7 appium
Maven dependency - 3.2.0

I am trying to execute the following code on “Ubuntu” but unable to execute it, getting error as below.

import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;

public class TestLatestAppiumVersion {

public static AndroidDriver<MobileElement> driver;

@Test
public void testServer() throws Exception {

    File classpathRoot = new File(System.getProperty("user.dir"));
    System.out.println(classpathRoot);
    File app = new File(classpathRoot, "whatsapp.apk");

    AppiumDriverLocalService service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
            .usingDriverExecutable(new File("/home/xxx/.linuxbrew/Cellar/node/4.2.1/bin/node"))
            .withAppiumJS(new File("/home/xxx/.linuxbrew/lib/node_modules/appium/bin/appium.js"))
            .withLogFile(new File("/home/xxx/workspace/xxx/log.txt")));

    System.out.println("Requesting to start server");
    service.start();
    System.out.println("Server has started!!!");

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "MyVirtualDevice");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.0");
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

    driver = new AndroidDriver<MobileElement>(new URL("http://127.0.1.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);

    driver.quit();
    service.stop();
    System.out.println("Server has stopped successfully!!!");
}

}

OUTPUT:

2015-10-28 12:44:38:266 - info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
2015-10-28 12:44:38:268 - info: Appium REST http interface listener started on 0.0.0.0:4723
2015-10-28 12:44:38:271 - info: [debug] Non-default server args: {“log”:"/home/grabhouse/workspace/Grabhouse/log.txt"}
2015-10-28 12:44:38:271 - info: Console LogLevel: debug
2015-10-28 12:44:38:271 - info: File LogLevel: debug
2015-10-28 12:44:38:529 - info: --> GET /wd/hub/status {}
2015-10-28 12:44:38:531 - info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}
2015-10-28 12:44:38:537 - info: <-- GET /wd/hub/status 200 7.669 ms - 105 {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}
2015-10-28 12:44:38:915 - info: --> POST /wd/hub/session {“desiredCapabilities”:{“automationName”:“Appium”,“platformVersion”:“5.0”,“app”:"/home/grabhouse/workspace/Grabhouse/whatsapp.apk",“deviceName”:“MyVirtualDevice”,“platformName”:“Android”,“browserName”:""}}
2015-10-28 12:44:38:916 - info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
2015-10-28 12:44:38:919 - info: [debug] No appActivity desired capability or server param. Parsing from apk.
2015-10-28 12:44:38:919 - info: [debug] No appPackage desired capability or server param. Parsing from apk.
2015-10-28 12:44:38:920 - info: [debug] Using local app from desired caps: /home/grabhouse/workspace/Grabhouse/whatsapp.apk
2015-10-28 12:44:38:921 - info: [debug] Creating new appium session 4bacfd6b-b7c6-42fe-996c-147689cc2e7c
2015-10-28 12:44:38:921 - info: Starting android appium
2015-10-28 12:44:38:923 - info: [debug] Getting Java version
2015-10-28 12:44:38:969 - info: Java version is: 1.7.0_79
2015-10-28 12:44:38:971 - info: [debug] Checking whether adb is present
2015-10-28 12:44:38:971 - warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
2015-10-28 12:44:38:971 - info: [debug] executing cmd: which adb
2015-10-28 12:44:38:976 - info: [debug] Cleaning up android objects
2015-10-28 12:44:38:976 - info: [debug] Cleaning up appium session
2015-10-28 12:44:38:977 - error: Failed to start an Appium session, err was: Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
2015-10-28 12:44:38:979 - info: [debug] Error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at [object Object]. (/home/grabhouse/.linuxbrew/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:126:12)
at ChildProcess.exithandler (child_process.js:210:5)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
2015-10-28 12:44:38:979 - info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.)”,“origValue”:“Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.”},“sessionId”:null}
2015-10-28 12:44:38:982 - info: <-- POST /wd/hub/session 500 67.119 ms - 342.

I had set the Environment variables in “~/.bashrc”,"~/.profile" & also “~/.bash_profile” as follows:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH

export MAVEN_HOME=/home/grabhouse/Documents/apache-maven-3.3.3
export PATH=$MAVEN_HOME/bin:$PATH

export ANDROID_HOME=/home/grabhouse/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools/
export PATH=$PATH:$ANDROID_HOME/tools/
export PATH=$PATH:$ANDROID_HOME/build-tools/

and also tried with,

export ANDROID_HOME=/home/grabhouse/Android/Sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/build-tools:$PATH

Also unable to install GUI version of “Appium on Ubuntu”, unable to open "uiautomatorviewer"

Help me in this regard,
Thanks in advance
Sandeep.

Hi Sandeep,
are you able to run adb command manually from terminal? because i m also using ubuntu but did not face this issue. But i m running appium direct from source.
And related to GUI version, this is not meant for Windows and Mac…
Ubuntu user do not have this luxury :).

Thanks,
Priyank Shah

Thanks for the reply,
i have tried by running appium server from command line, it is running fine, but the latest release of appium 3.2 has got new feature to start the appium server from code. It is not working in that way.

Use the latest java client code from git, the issue has been logged and resolved. This issue is with Nix based system when using eclipse.

Thanks for the reply,
Can you please let me know how to use the latest java client code from git? i am using maven to get the latest java client.

You need to clone git project , and build locally. After that you can add java client jar to your project.

Can you please tell me, how to build it locally & add the java client jar to your project?

  1. I had cloned the code from git, but i not aware of how to build it locally.
  2. I had already added the latest appium jar into the project.

Thanks in advance,
sandeep.

I think the new build will be published after the merging of this PR: