Detailed Explanation of Appium Tests with CodeceptJS

Detailed Explanation of Appium Tests with CodeceptJS

HAkcqRwGYetoe24RUV8vnwwyQCbZq sUuloaS8Lw9yY fOwzZZaNFNV8JmPrrQfLF4bFfS5oF4Qrg04O3EansU2ZQ34Rv6kJ3djYlsnn0jgsoKzrn9tylOrDlAGEvEgqYNnPNZAGXH5taF0hkKhf5AR3KntFioAzdkvkFD GotyL phxBwVBmc p1A

What is Codeceptjs?

CodeceptJS is a behavior-oriented testing tool. It uses helpers such as WebdriverIO, Protcator, Nigthmare, Puppeteer. The biggest advantage it offers us is easy writability, easy understanding, and easy backward editing with a simple Page Object structure.

First of all, we will need Appium, Appium Inspector (so that we can find the ID CLASS and XPATH of the elements while writing our tests), Android Studio, and Visual Studio Code.

  1. I assume these applications are installed on your computer and I switch to codeceptJS installation.
  2. Open an empty folder in Visual Studio.
  3. First, we need to create a package.json file. So, we run the npm init -y command in Visual Studio terminal and our package.json file is created.
  4. After that, we need to install codeceptJS-webdriver io in our file. We run the command npm install codeceptjs webdriverio --save in Visual Studio terminal.
  5. The next step, we need to install the codeceptjs-appium file, for this, we run the npx codeceptjs init command in Visual Studio terminal. After running this command codeceptJS will ask us some questions, actually, the questions here are about what we want to do.

Since we use Appium in this article, I would like to share with you the steps we need to proceed with;

W7ca6Gn bcBR UDTOpQWQM GHNdqbrx5LxoMqakam1GejEhReXnSfs44H5KiraTH3uugdUhA77qJULa5Cv9qDylDMhiicdBRg9zvsLVrnpw2926jdSkByeGpQrJrwDPyhQY

If we would like to use typescript, we type “Y”, if we don’t want it, we type “N” and then press enter.

Where do we want to save our tests?

If you want to keep it in another folder, you can write it as ./foldername/*_test.js.

We can change all the selections we have chosen here later from the codeceptjs.conf.js file. I’m leaving it here as default for now.

qdnW3ALDz4uoBBHMFk169KXeMmOqVMheD5Ttc2zX6 Y8Bg51I1i1fCkvX5zuVUYaVvZ9N0yzkcDAbEuxtyJUhALrmSqILVES8Oe4IQlPbX34 X9zzDldEdto2kYO2HmnkQDN63sIkeeQiki6q4ZZnaDg CvXFkI0Ar iLLHQ0rFEB9CEHVpqy6X 5Q

Here is asked which test tool we are working with, in this case, we choose Appium.

AVevUc uA kS8IXvgCHJIZ0HKmEDYbx5Ab6ce17awn98L7S4Lbq7ZQwx5wwu1WnN4M412eFzMRoGTHXnfISZRr4EFJsT 597YYUzScimffwMQcHEFfDcvOPF ppSeVxmN0qYJVeoVg OnYw1DAk048sbL3kypWsT61L4tFeO2qwYi4C5jnlWEig

We choose the language.

6e m32NVaF8REeKJo8vfIpeliqKa6o3qIJ6p389JIZ 2qDz78gIi VP0vtx8x0FiGio5jowqmh0WSYrKsEPnLryiAywH0UU8yyz8cQaNc6NJ6jc2STwT2jruA4zzihvMLHdrrhOfEDv2XBlG5zfAqJp0shQRJ dHFJ MlSRYa kr3HJWHiMO4N5diQ

In this screenshot it’s asked which URL to run Appium, we leave the default and will edit it later.

4muSvy7S9uPBtnwq5p8LRDRxxd Flkt8bCbP S A2qHV5wuA 1N8gOECsBSgVqd39Pk3oRGsW6J8qRzXAcoC03QoQ 0e6ih nnq9ua5bmO60 JRktYTzLEWKZJDbFVQ0CPRiPN0BVJdadbrrcn5IwfPkC4BptZfGEr7OwlV1GQ2O4g0AtDneYIhIg

We choose Android because we will work with Android Studio.

wH sJn8G0V6xqN u61SSln0GwjLBpehYiHlbTfQy5lcGlTXeOJPHhIdG1839iBaFH0RGHRhv2AaZee3189GcKOm24cM8jPPrO3Jb3CNFLfPf7hF3HFAppZNuCEafgUkg8rWibW9H1K8C9yaNk46fyi2cBdaiKAJfFe1c crg6fRBuBTvG0YpnjucNg

It asks for the name of the device we are planning to use, we leave the default and will edit it later, like in the previous step.


Now that we have completed the installation, we have a few small adjustments to make. We open our Codecept.conf.js file;


Here are the fields we need to edit:

  • app: “We give the file path of the application we will use”
  • platform: “Android”
  • device: “The name of our device”

And now we are ready to write the test!! 👋

Here is an example:

First, we put a login .apk file (it could be any app) that we found from Google into our Visual Studio file.

Let’s understand the CodeceptJS Page Object structure; Let’s create a page file with the npx codeceptjs gpo command.

cFd4SJoKH IogyOxdysnZA3NVjj3iXgc4R 1ykITYPFZpOSezks 8FAfkUC1611Tl8MXw7Pmu64h149e7OV2cOhjFCly6zLxHxUssrzz4U mpWl01bd0sMjr1gE0dC4yK7567LUi10Wfs5K9GFP6tAhbhr2keq3ad1AOrAVQ1zkCtXdJ0u53 YAEqw

Because I will run a login test here, that’s why I created a page called loginPage.

You can give any name; The purpose of this is to collect all the elements of the login screen on a single page. Creating a structure that we will not have to find these elements again in another test that we will do on the login screen later on. This is exactly the biggest advantage that CodeceptJS has given us. We can easily call the pages to our tests with the injection structure.

Now, let’s define the elements in our page file.

rGI0ruB2yoFcp5DSkwJQTqInNxiD8Qhmxb1Qkh CWCjEM0x 0BWfCOtCI2xM2nuLisyERuBiq4J2L1KiHCXTgIHa3whyeiPHdzAz 6ad514U9zI

Now let’s create our test file, we create an empty test case with the npx codeceptjs gt command and write our test case.


The code const{ loginPage } = inject(); may have confused you in the image above.

C BdK5y2ZdUyunwU5AnmrAxN1GrpxJKsCb209U0d3z qvwUHzIEzWPne4nHBgn8QJCdG8MgK 8elwkjCpt ko DPYuY9omw4r2oHAQNbsgCWg sWt6Qa 0BP0JQ 8QuPJSCoNKJl2cw2A ouH11MRHeQqySYmx mWwtHuGi2EQXRWcgJuNXsG5QFYg

Now we can run our test 🎯 with npx codeceptjs run --steps

KC4nZzgXzmA yzkUwsrgFE0H gDPD8bIHEl210y2LcczMRHbQAbkMa3 HrxIWhsSW1DiS6VWD ZH7dfkZxDLDz4J ykQL ymf1rieDJ3ehpui8U HK9 IlviElZ6vy oPeqYnv1thAQAOlmBQcczJw kgP9Np xTslKlX7oyn bsA44eAIfZMLgWw

GitHub project:

People Also Read