pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.hogwarts</groupId>
<artifactId>HogwartsAppiumDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<version>2.13.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.3.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<aspectj.version>1.8.10</aspectj.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.10.0</version>
<configuration>
<reportVersion>2.4.1</reportVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
AppiumSMSTest.java
package appIumdemo;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
public class AppiumToastTest {
private static AndroidDriver driver;
@BeforeAll
public static void setUp() {
try {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("platformName", "android");
desiredCapabilities.setCapability("deviceName", "emulator-5554");
desiredCapabilities.setCapability("appPackage", "io.appium.android.apis");
desiredCapabilities.setCapability("appActivity", "io.appium.android.apis.ApiDemos");
desiredCapabilities.setCapability("automationName", "UiAutomator2");
URL remoteUrl = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(remoteUrl, desiredCapabilities);
}catch ( MalformedURLException e){
e.printStackTrace();
}
}
@Test
public void sampleTest() {
MobileElement el1 = (MobileElement) this.driver.findElementByAccessibilityId("OS");
el1.click();
MobileElement el2 = (MobileElement) driver.findElementByAccessibilityId("SMS Messaging");
el2.click();
MobileElement el3 = (MobileElement) driver.findElementById("io.appium.android.apis:id/sms_recipient");
el3.sendKeys("18111111111");
MobileElement el4 = (MobileElement) driver.findElementById("io.appium.android.apis:id/sms_content");
el4.sendKeys("hogwarts");
MobileElement el5 = (MobileElement) driver.findElementByAccessibilityId("Send");
el5.click();
}
@AfterAll
public static void tearDown() {
driver.quit();
}
}