?????????????*?1
package com.testerhome;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class Suite1 {
public String port;
public String udid;
private AndroidDriver driver;
@Test
public void switches() throws InterruptedException {
WebElement sound = driver.findElementByAndroidUIAutomator("new UiSelector().text("Sound")");
sound.click();
System.out.println("checked");
Thread.sleep(2000);
System.out.println(Thread.currentThread());
}
@BeforeSuite
@Parameters({ "port"?? "udid" })
public void beforeSuite(String port?? String udid) {
this.port = port;
this.udid = udid;
}
@BeforeClass
public void beforeClass() throws MalformedURLException{
System.out.println(port + udid);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName"??"device1");
capabilities.setCapability("automationName"??"Appium");
capabilities.setCapability("platformVersion"?? "4.4");
capabilities.setCapability("udid"?? udid);
capabilities.setCapability("appPackage"?? "com.android.settings");
capabilities.setCapability("appActivity"?? ".Settings");
driver = new AndroidDriver(new URL("http://127.0.0.1:" + port + "/wd/hub")?? capabilities);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}