TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Appium

    Run Appium Test on Android Virtual Machine

    Appium Tutorials

    Overview

    In this tutorial, we will write a sample Appium Test and run the test on the Android Virtual machine. To set up the Test project we need some dependencies that are listed on this page.

    Android Studio

    https://www.testingdocs.com/installing-android-studio-on-windows/

    Appium Server

    Launch the Appium server.

    https://www.testingdocs.com/install-appium-desktop-server/

    Appium Architecture

    https://www.testingdocs.com/appium-architecture/

    Android Virtual Machines

    Create an Android Virtual machine.

    To run the Test on Android Virtual Machine, we need to create virtual machine using the AVD manager.

     

    AVD Manager Android Studio

    Steps to create virtual device can be found at:

    https://www.testingdocs.com/creating-android-virtual-device-with-avd-manager/

     

    Android Virtual Devices

    Maven Project

    Create a Maven project.

    https://www.testingdocs.com/create-quickstart-maven-project-in-eclipse-ide/

    Sample Appium Test

    package com.testingdocs.appium.quickstart.AppiumProject;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.testng.Assert;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;
    
    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.android.AndroidDriver;
    import io.appium.java_client.remote.MobileCapabilityType;
    
    /**
     * Sample Appium Test.
     */
    public class SampleTest {
     public static AppiumDriver<?> mDriver;
    
     @BeforeTest
     public void setup( ) throws MalformedURLException {
     DesiredCapabilities caps = new DesiredCapabilities();
     caps.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome"); 
     caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0"); 
     caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android"); 
     caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Androidemulator"); 
     caps.setCapability("avd","Nexus_5X_API_29_x86");
     mDriver = new AppiumDriver<> (new URL("http://127.0.0.1:4723/wd/hub"), caps);
     mDriver.manage().timeouts().implicitlyWait(120,TimeUnit.SECONDS); 
     }
    
     @Test
     public static void titleTest(){
     mDriver.get("https://www.testingdocs.com/");
     Assert.assertEquals(mDriver.getTitle(), "Home | TestingDocs", "Check Title");
     }
    
     @AfterTest
     public void tearDown( ){
     mDriver.quit();
     }
    }

    Run the Test

    Run As >> TestNG Test

    or

    Run asĀ  >> Maven test

    Test running on the Android virtual machine.

    Appium Test Eclipse IDE

     

    Test Logs in Appium Server

     

    Appium Server Console Logs

    POM.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
    
     <groupId>com.testingdocs.appium.quickstart</groupId>
     <artifactId>AppiumProject</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <packaging>jar</packaging>
    
     <name>AppiumProject</name>
     <url>http://maven.apache.org</url>
    
     <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
    
     <dependencies>
     <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.12</version>
     <scope>test</scope>
     </dependency>
     <dependency>
     <groupId>io.appium</groupId>
     <artifactId>java-client</artifactId>
     <version>7.3.0</version>
    </dependency>
    <dependency>
     <groupId>org.testng</groupId>
     <artifactId>testng</artifactId>
     <version>7.1.0</version>
    </dependency>
     </dependencies>
    </project>

     

    Common Error

    An unknown server-side error occurred while processing the command. Original error: No Chromedriver found that can automate Chrome

    Fix:

    As shown in the error trace, the test could not find the Chromedriver.exe to run the test on the virtual machine.

     

    Appium Tutorials:
    https://www.testingdocs.com/appium-tutorials/

    For more information on Appium Tool:
    http://appium.io/

    Related Posts

    pCloudy Device List

    Appium /

    pCloudy Continuous Testing Cloud

    Introduction to Appium

    Appium /

    Introduction to Appium

    Appium Studio for Eclipse

    Appium /

    Appium Studio for Eclipse

    Appium Architecture

    Appium /

    Appium Architecture

    Mobile Automation Setup Guide

    Appium /

    Mobile Automation Setup Guide

    ‹ Cloud Testing Service Providers› SauceLabs Credentials to run cloud tests

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com