|
package appium;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.testng.annotations.BeforeClass;
import org.testng.xml.dom.Tag;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
public class APPiumTest {
AppiumDriver driver;
@BeforeClass
public void beforeClass() throws MalformedURLException {
DesiredCapabilities des = new DesiredCapabilities();
des.setCapability("deviceName", "Android Emulator");
des.setCapability("platformName", "Android");
des.setCapability("platformVersoin", "4.4.2");
des.setCapability("appPackage", "com.android.calculator2");
des.setCapability("appActivity", ".Calculator");
driver=new AndroidDriver(new URL("http://localhost:4723/wd/hub"),des);
}
@Test
public void Test() {
System.out.println("开始");
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);//隐式等待
driver.findElementById("com.android.calculator2:id/digit7").click();
driver.findElementById("com.android.calculator2:id/digit4").click();
driver.findElementById("com.android.calculator2:id/plus").click();
driver.findElementById("com.android.calculator2:id/digit1").click();
driver.findElementById("com.android.calculator2:id/digit6").click();
driver.findElementById("com.android.calculator2:id/equal").click();
String num = driver.findElementByClassName("android.widget.EditText").getText();
System.out.println(num);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
driver.findElementById("com.android.calculator2:id/digit7").click();处开始空指针 |
|