Programming

Writing Your First Appium Test on LambdaTest

author-img By Debamalya Mukherjee 5 Mins Read August 18, 2023

Appium Test

In the current generation, mobile applications have become direct competitors to their desktop counterparts. This is because while using mobile apps, app developers can achieve desktop-like performance on devices that can fit in their pockets. Therefore, the app developing companies have started to realize the size of the mobile market. This is one of the primary reasons why mobile app testing has become one of the most widely practiced test cases in the modern generation.

Various popular mobile app testing tools like Appium help app developers improve the quality of their mobile test cases. Moreover, platforms like LambdaTest provide a real device cloud to further improve the accuracy of the test reports. It is also possible to integrate Agile methodologies like continuous integration and continuous development while using LambdaTest.

So, with this article, we are going to guide the new application developers and testers through the process of writing their first Appium test case on LambdaTest. We will also discuss some of the major features of LambdaTest that help improve the efficiency of the Appium test cases.

Appium and Mobile Testing

Mobile applications have become one of the most widely used apps due to their flexibility and portability. Currently, the three most popular mobile platforms include iOS, Android, and Windows. In the Android platform alone, more than 2000 new devices arrive on the market annually. All of these devices are unique in terms of display resolution, screen size, and other hardware parameters. Therefore, the developers must have efficient testing infrastructure to verify the proper performance of all these elements.

With Appium, app developers can access an open-source infrastructure for verifying the proper performance of all the user interface elements present in mobile apps. Appium also allows the testing of various mobile applications like native apps, hybrid apps, and mobile-based applications. This tool also supports the execution of mobile test cases on all popular platforms like Android, iOS, and Windows. The JSON wire protocol that is utilized by the core infrastructure of Appium is similar to the Selenium JSON protocol. Appium also allows the integration of parallel test execution to further improve the efficiency of the test cases.

Accessing Real Device Cloud with LambdaTest

While working with mobile applications, real device testing plays a crucial role in understanding the effect of physical parameters on the functioning of a device. Some of the most important physical parameters include low bandwidth, battery issues, or user interaction errors. However, the process to set up and maintain a physical test lab is very expensive and hectic. Multiple cloud-based solutions allow app developers to achieve similar test results while executing all the test cases over remote servers through the Internet. LambdaTest is one such platform that allows the execution of real device clouds, the removal of geolocation barriers, and provides access to legacy devices.

Accessing Real Device Cloud with LambdaTest

This is a platform for initiating cloud-based digital experience testing on web applications.   LambdaTest supports the execution of automation test cases from Selenium, Cypress, and Playwright. You can execute the selenium test cases on more than 3000+ testing environments, including real devices. While working with Cypress and Playwright cases, the developers can run them on more than 50 different browsers. LambdaTest boosts the dependability of the test reports with the integration of parallel test execution.

The combination of real device test reports with emulation software further improves its accuracy and dependability.

Before proceeding towards the test case creation process, let us understand some of the major features available with the LambdaTest cloud:

  • This cloud platform will store information regarding all the past test cases so that the app developers can draw appropriate references whenever required.
  • In the automation section of the LambdaTest cloud, it will keep information on all the executed test cases. So, depending on the failed test reports the app developers can gather adequate information to prevent any such errors in the future.
  • Another unique feature offered by the LambdaTest cloud is the maintenance of the command logs. It will provide information about all the commands that have been executed on the system during the application testing process. The LambdaTest cloud will also store appropriate screenshots of the instances when these commands were executed.
  • Finally, while working with LambdaTest real device cloud, the application developers can integrate it with almost all the popular bug-tracking tools, communication tools, and project management tools, along with the integration of CI and CD pipelines. The Integration of Continuous Development and Continuous Integration helps boost the coordination between the development and testing teams of an app company.
Finally, while working with LambdaTest real device cloud

Writing the First Appium Test on LambdaTest

To write the first Appium test case on LambdaTest, the application developers have to go through certain prerequisites and then follow some simple steps. So, for the simplicity of the new application developers and testers, we have listed all of these steps below:

  1. The first step in this process is to set up the testing environment, which involves the installation of node.JS and npm package installer. The application developers must ensure to download all of these files from the official website to avoid any form of privacy issues.
  2. The next step is to download Appium using npm. For this process, the application developers will simply have to enter the “npm install -g Appium” command.
  3. Now it is time to sign up for a LambdaTest account in case the developers do not already have one. It is also important to purchase a relevant LambdaTest license that will provide the access key in the LambdaTest dashboard.
Now it is time to sign up for a LambdaTest account
  1. Next, the application developers have to specify a new Appium project which will have the LambdaTest real device cloud as a dependency.
  2. The application developers have to create a new folder for the Appium project and navigate into it with the following command:

mkdir my-appium-test

cd my-appium-test

It is now time to initialize a new node.JS project using the npm package installer:

npm init -y

  1. The final step for the specification of the Appium project is the installation of the Appium and Appium client as a web driver dependency.
  2. To install Appium Client as a WebDriver dependency, the application developer simply has to install the following code in the terminal window:

npm install webdriverio @wdio/cli –save-dev

  1. For installing the Appium service for WebDriverIO, the app developers have to use the dedicated method that is mentioned below:

npm install @wdio/appium-service –save-dev

  1. Now that the application developers have conducted all the prerequisites for creating the first Appium test with LambdaTest, it is time to configure the test cases. The first step is to create a configuration file by running the following command. The application developers also have to answer a few prompted questions that will be displayed by the system:

npx wdio config

npx wdio config
  1. After creating the configuration file, it is now time to modify the parameters of ‘wdio.conf.js’ and enter the following configuration so that the Appium test case can work with LambdaTest real device cloud:

exports.config = {

  user: ‘YOUR_LAMBDATEST_USERNAME’,

  key: ‘YOUR_LAMBDATEST_ACCESS_KEY’,

  services: [‘@wdio/appium-service’],

  specs: [‘./test/specs/**/*.js’],

  exclude: [],

  maxInstances: 10,

  capabilities: [{

    platformName: ‘Android’,

    deviceName: ‘Samsung Galaxy S20’,

    browserName: ‘Chrome’,

    appiumVersion: ‘1.20.2’,

    autoGrantPermissions: true,

    name: ‘My First Appium Test’,

  }],

  logLevel: ‘info’,

  bail: 0,

  baseUrl: ‘http://localhost’,

  waitforTimeout: 10000,

  connectionRetryTimeout: 120000,

  connectionRetryCount: 3,

  framework: ‘mocha’,

  reporters: [‘dot’],

  mochaOpts: {

    ui: ‘bdd’,

    timeout: 60000

  }

};

For the understanding process, we have used certain parameters like username and access key in the sample code. However, the application developers and testers must remember to replace this data with the relevant information that will come with their LambdaTest access key.

  1. Now, it is time to write the first Appium test case with LambdaTest by creating a new folder within the project directory. The application developers can name this folder according to the requirements of the app development project. A sample code may look like:

describe(‘My First Appium Test’, () => {

  it(‘should open LambdaTest homepage’, () => {

    browser.url(‘https://www.lambdatest.com/’);

    const title = browser.getTitle();

    assert.strictEqual(title, ‘Cross Browser Testing Tool | 2000+ Real Browsers & Devices’);

  });

});

  1. After creating the folder, it is time to navigate inside the test folder and create a new file containing the test name. We would advise the application developers to name these test cases according to the target elements to prevent any confusion while working with complex applications that have thousands of different elements.
  2. Now all that is left is to run the test cases using the Appium server. In this process, the app developers should also remember to have separate terminal windows or tabs for the different parameters that will be specified in the test case file. A useful tip in this section would be to choose the correct programming language that is not only supported by Appium but also by LambdaTest. Some of the popular options include Java, JavaScript, Ruby, and many others.
  1. In case you have followed all the steps correctly, the system will execute the test case and display the final Test report. Depending on the bugs and errors that might be present in the report, the application developers have to move on to the debugging phase. We would suggest the app developers re-run these test cases when updating the apps or even changing a small element. This is because it will help to ensure that the new elements don’t harm the functioning of the previously present elements.

It is also a good idea to go through the official documentation of LambdaTest and Appium. It will provide relevant information along with visual test cases to understand various features and methods that are offered by both of these tools. This information might be useful depending on the customized requirements of the app development project.

The Conclusion

With this article, we focused on some of the most important parameters that developers must remember while writing their first Appium test case on LambdaTest. It is also important to properly integrate automation testing practices in the development test bench to utilize its full potential. The app developers should also try to collect adequate information about the requirements of the target audience base. This data will help them to customize the app and improve its audience reach and compatibility. These are some of the most important factors that will play a critical role in creating a positive brand image. Finally, it is also important to choose the correct automation testing tools that can complement the requirements of the developers and the project as a whole.

Read Also:

Share This Article:

author-img

Debamalya Mukherjee

Debamalya is a professional content writer from Kolkata, India. Constantly improving himself in this industry for more than three years, he has amassed immense knowledge regarding his niches of writing tech and gaming articles. He loves spending time with his cats, along with playing every new PC action game as soon as possible.

View All Posts

Leave a Reply

Your email address will not be published. Required fields are marked *