Include an extra library from Maven into an Android Project

To include an extra dependency into an Android project we need to:

  1. Go to file and select “Project Structure”:
    Android studio file project structure
  2. Next step it is to select the app section and then the Dependencies tap.
    Open the app tap
  3. At this point we click on the plus sign at the bottom of the window and then we select add library dependency:
    Add library dependency
  4. The last step it is to add the dependency we’re looking for, in my case it is to include the apache commons, so I search for org.apache.commons.io and I select on the package I am interested to and click OK.
    Add external library dependency into project android studio

Converting a Maven Project to a Gradle one

Working with Android Studio means that we need to use gradle projects, however it might happen that some of our old projects were made in pure Java and with Maven, this is actually quite likely.
Converting a project from one format to another is though quite easy to be done through the command line and the built init plugin.
In particular this tool allows us to convert not just from Maven but also from grails, java and scala.
Anyway, to move from Maven to gradle we just need to:


cd project
gradle init --type pom

At this point we can import the project into Android Studio quite easily.

Java Design Patterns: Implementing a singleton for Selenium WebDriver

What is a Singleton? A singleton is a class which should only be initialized once, provide a way to allow multiple instances of that class to be used, and finally to be the central point of access for that class.

Typical use cases of a singleton are classes accessing to system resources. In my scenario I want for example to create a singleton for Selendroid, since I really want to create just one instance of Selendroid to run all my tests.

Continue reading Java Design Patterns: Implementing a singleton for Selenium WebDriver

Adding Maven to a project in IntelliJ

Previously I used the jar libraries for the Selenium/Selendroid project to work fine, however the method is not really ideal. Project dependencies should be imported automatically with a dependency sistem of some sort. Here I am going to add Maven to the project and manage the dependenices through it. Here I am going to add selenium-java and selendroid-standalone, but this is of course valid for any other library.
Continue reading Adding Maven to a project in IntelliJ

Getting ready to write our first Selenium Test in IntelliJ

Before getting into using Seledroid, it is probably a good idea to see if my old understandings of Selenium still apply. I haven’t used it in ages, so as a first step I will configure an IntelliJ project using Selenium.
Continue reading Getting ready to write our first Selenium Test in IntelliJ

Mobile Testing in Android with selendroid

It is always a problem automating testing in the mobile world, because the technologies used in the desktop world are not capable of the same level of testing, therefore we are looking for technologies that will allow us to at least do some level of mobile testing.

Selendroid

seledroid-logoThe first tool we are going to try is Selendroid, which seems to be the standard tool when it comes to Android mobile testing.

Selendroid uses the JSON Wire protocol, ready for Selenium 3. It makes possible to test native, hybrid applications and the mobile web. In our scenario we’re interested to the last two. Also Selendroid supports simulated devices as well as real ones.

How to add crosswalk project or any library to an Android Studio Project

How do you add a library to an Android Studio project?

In my case I need to add Crosswalk-project to the application I am working on (this example is about CrossWalk but it can be applied to any other library). So first of all I download CrossWalk and extracted it.
The next step is to import it into our application.
Continue reading How to add crosswalk project or any library to an Android Studio Project

How to add a JavaScript interface to an Android CrossWalk project

A JavaScript interface allows us to have a bridge between Android and the JavaScript when working using WebViews.

How do we add support for a JavaScript interface then?

First of all we have our XWalkView object from the layout in our onCreate method:

mWebView = (XWalkView) findViewById(R.id.activity_main_webview);
mWebView.load(“http://maurizionapoleoni.de”, null);

mWebView.addJavascriptInterface(new WebAppInterface(this), "Android");

In Continue reading How to add a JavaScript interface to an Android CrossWalk project

Inserting images from the camera into the document using a WebView

The steps a user follows to insert images into the document are:

  • Tap on a file input button
  • Choose to use the camera roll
  • Read the image
  • Insert the image into the document.

Continue reading Inserting images from the camera into the document using a WebView