In this post we are going to build on everything that we have learnt so far about Appium to write out first automated test in our IDE. Before continuing with this post, you should have followed everything in Part 1 and Part 2 first. For this example we will be using the Intellij IDE, if you need some help getting that setup and prepared for automation then do check out my series of posts on that subject here.

Let’s get started right away by launching Intellij and clicking “Create New Project“. Choose to create a Maven project and click Next. Type anything you like for the GroupID and ArtifactID, click Next, give the project a name and set the project folder location, and finally click Finish.

When the IDE loads, remember to tick “Enable Auto Import” in the top right hand popup. You should find that your pom.xml file has loaded right away, if it hasn’t find it in the directory structure on the left hand side and open it. Add the following code to import the dependencies for Appium Java, Selenium and JUnit:

Now in your directory structure on the left, expand the SRC > TEST folders, right click on the JAVA folder and select NEW > JAVA CLASS . Name the class “MyFirstTest”. Add the following code to setup Appium:

This is a really simple test that will add the numbers 7 and 5, and check that the result is 12. OK, we are almost ready to run the test, we just need to make sure that the Appium server is running and that we have launched an AVD.

Open a command prompt and start the Appium server by typing:

appium &

Open another command prompt and start your AVD by typing

emulator @training01

Where ‘training01‘ is the name of your AVD that you created previously. Once the AVD has loaded, simply run the test through Intellij by right clicking on the myTest() class and selecting ‘Run myTest()’. The calculator app will load on the AVD and the test will execute according to the code that you specified

Congratulations! You just ran your first automated test in Appium. Obviously this test is incredibly straightforward, but hopefully this tutorial has done enough to show you how to get Appium installed and running on your machine and how you can leverage your existing Selenium automation knowledge for testing on mobile.

Tags:

James- Thanks for a great post. I copied and tried to run the exact code as mentioned. I also followed your setup series so that i have everything in place, however getting the following error when i try to run it.