Appium
驱动程序在通过环境变量确定平台时抛出空指针异常。
*这是我的代码*
public class AppiumBaseClass { 公共AppiumDriver驱动程序;
@BeforeClass
public void setup() throws Exception {
Properties prop = new Properties();
InputStream input = null;
String platform = System.getenv("PLATFORM");
try {
input =
new FileInputStream("/Users/piyushkumar/Desktop/Automation_Framework/HP_Signup/src/main/java/Utility/appiumSession.properties");
prop.load(input);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automation name", prop.getProperty("automation name"));
capabilities.setCapability("platform",prop.getProperty("platform"));
capabilities.setCapability("platformName", prop.getProperty("platformName"));
capabilities.setCapability("platformversion", prop.getProperty("platformversion"));
capabilities.setCapability("deviceName", prop.getProperty("deviceName"));
capabilities.setCapability("app", prop.getProperty("app"));
capabilities.setCapability("newCommandTimeout", "60");
//Checking the platform
if (platform.equals("Android")) {
driver = new AndroidDriver(
new URL("http://localhost:4723/wd/hub"), capabilities);
} else if (platform.equals("ios")) {
driver = new IOSDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
} else {
throw new Exception("Unable to read platform");
}
} catch (IOException io) {
io.printStackTrace();
Reporter.log("platform selected is "+driver);
}
}
}
appiumSession.properties
这是属性文件的内容。
automation name = Appium
platformName= Android
platformversion=5.1
deviceName=Nexus_S_API_22
app= /Users/piyushkumar/Desktop/SignUpApp-qa-release-2.6-unaligned.apk
platform =Android
任何帮助将不胜感激。