Appium For Beginner

Appium For Beginner

■ Environment settings

■ How to execute test

IDE :

  • Contained packages

Android studio :

  • Create the simulator
    1. Click Configure -> Click Access ADV Manager
    2.  Click Create Virtual Device
    3. Select Phone tab -> Pixel 2 -> Next

Start the simulator

  • Click icon Start
  • Active the simulator

Check the simulator is in debug mode

  • In command line : adb devices
  • In emulated device
  • Check Chrome browser version
    1. Open google app on simulator
    2. Click setting
    3. Click About Chrome

Appium Desktop

  • Please provide the default port
Server Address : 127.0.0.1
Server Port : 4723
  • Options selected for server’s configuration

■ How to capture elements on mobile Chrome Browser?

  1. Android Studio
    . Start simulator
    . Open Chrome
  2. Chrome Browser on Desktop
    . Open Chrome browser
    . Access "https://www.google.com/"
    . Start debug device's browser https://developers.google.com/web/tools/chrome-devtools/remote-debugging
    Or go to “chrome://inspect/devices
    . Capture elements


■ Implement test script as scenario

  • Test Scenario:
1.  Open Goolge Chorme Application
2.  Navigate to google site
3.  Input text "shift asia" then click on search button
4.  Click on the result with "https://shiftasia.com"
  • Main page
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.MalformedURLException;
import java.net.URL;

public class androidTest {

    static WebDriver driver;

    @BeforeAll
    public static void setUpClass() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "9.0.0");
        capabilities.setCapability("deviceName", "emulator-5554");
        capabilities.setCapability("browserName", "Chrome");
        capabilities.setCapability("automationName", "UiAutomator1");
        capabilities.setCapability("chromedriverExecutable", "D:\\androidTest\\drivers\\chromedriver.exe");
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }

    @Test
    public void googleTest() {
        // navigate to google site
        driver.navigate().to("https://www.google.com/");

        //Input and Search text 'ShiftAsia'
        driver.findElement(By.name("q")).sendKeys("ShiftAsia");
        driver.findElement(By.xpath("//button[@class='Tg7LZd']")).click();

        //Click link Shift Asia
   driver.findElement(By.xpath("//a[@href=\"https://shiftasia.com/\"]")).click();
    }
}