Configure Project In Eclipse For Appium

Earlier we learnt how to setup environment in windows for run appium automation project, SDK installation, usage of tools like UI Automator Viewer to locate android app elements etc. Now everything is ready and we are just step away from running appium test in android device. Before that we need to create project in eclipse so let's configure project in eclipse for appium. Bellow given steps will tell you how to setup appium project. I hope most of you already knows all these things but still let me describe you how to configure first appium project in eclipse.

PREREQUISITE : All previous 11 STEPS should be completed without any error.

Create New Project In Eclipse

Before creating new project In eclipse, You must be aware about how to download Eclipse IDE, How to create workspace for project, Creating new project and package In eclipse and adding jar files In your project's build path. I have already described all these thing In THIS POST so I will not repeat It here.
  • Start Eclipse IDE. It will ask you to set workspace If you are using It first time.
  • Set workspace.
  • Create new project(With your desired name. For me It Is MavenProject1) In eclipse with package name Android.
  • Install TestNG : I hope testng is already installed in your eclipse. View THIS POST to know how to install testng in eclipse.
Not using maven?
If you are not using maven with eclipse then follow bellow given steps in eclipse.

Download Latest Jars of WebDriver and Appium Client Libraries
We need to add latest version jar files of selenium webdriver and Appium Client Libraries in our project's build path.
  • You can download jar files for selenium webdriver from THIS PAGE. View THIS POST for more detail.
  • You can download latest version of appium client libraries(java-client-x.x.x.jar where x.x.x is current latest version of jar) from THIS PAGE. Click on Java link, It will take you on jar file download page.

  • Then click on jar link as shown bellow. It will start downloading appium client libraries jar file.
Download Latest Jar File Of google-gson
You also need google-gson's latest jar file. Current latest version Is 2.3.1. You will find google-gson download link on THIS PAGE.

Add jar files in project's build path
Now we have selenium webdriver, appium client libraries and gson jar files.

HERE you can learn how to add jar files in project's build path
  • Add selenium webdriver jar files in project's build path.
  • Add java-client-x.x.x.jar in project's build path.
  • Add gson-x.x.x.jar in project's build path.
That's it..

Using maven?
If you are using maven project management tool with eclipse then no need to add above jar files in project's build path but you have to add Selenium WebDriver, Appium Java Client Libraries and gson dependencies in pom.xml file.
  • Visit THIS PAGE to find selenium webdriver dependency.
  • Visit THIS PAGE to find Appium Java Client Libraries dependency.
  • Visit THIS PAGE to find gson dependency.
Current latest dependencies for selenium, appium java client and gson  are as bellow. It may change in future so update accordingly.

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>  
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>

This is all about appium project configuration in eclipse for maven and non maven users.

5 comments:

  1. hi, Aravind
    my eclipse gave me an alert "Error when loading the SDK", inside said things wrong in the android wear in android-22, and android 23. I delete both of 22 and 23, but the problem caused by 23 still there.
    what should I do? I will keep trying. But please tell me the solution, If you know.

    Thanks.

    Mak

    ReplyDelete
  2. Hi! Great article but I'm a little confused about the entire structure of the pom file. How and where exactly shall I add these dependencies in my pom file?

    ReplyDelete
    Replies
    1. Hi Pinaki,

      Add your dependencies inside !-- Add your dependencies here--
      For ex:



      com.google.code.gson
      gson
      2.6.2

      Delete
  3. May also need this dependency in maven (maybe this changed since you wrote this):

    org.testng
    testng
    6.8
    test

    ReplyDelete
  4. getting the following error
    FAILED CONFIGURATION: @BeforeTest setUp
    org.openqa.selenium.SessionNotCreatedException: 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.) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 974 milliseconds
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
    System info: host: 'Cerebtech', ip: '192.168.225.54', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_111'
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:158)
    at Android.SimpleAndroidCalcTest.setUp(SimpleAndroidCalcTest.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.TestRunner.beforeRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:616)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
    at org.testng.SuiteRunner.run(SuiteRunner.java:261)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
    at org.testng.TestNG.run(TestNG.java:1048)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)

    ReplyDelete