【发布时间】:2020-03-05 22:53:01
【问题描述】:
我是 Appium 的新手,并计划使用 Appium 页面工厂在 android 和 IOS 中使用相同的脚本执行我的测试,目前我正在使用 Android 设备,所以我将 IOS xpath 保持为空,当我执行我的脚本时抛出错误 "userNameTextBox=null" 。我这里有两个问题 1.根据什么标准Appium页面工厂会知道选择android还是IOS的xpath 2. 为什么在我的代码中它会抛出“userNameTextBox as Null”,尽管我使用的是 Android 驱动程序。
private AndroidDriver<AndroidElement> driver;
@AndroidFindBy(className = "android.widget.EditText")
@iOSBy(className = "")
private AndroidElement userNameTextBox;
public void login(String userName, String password) throws InterruptedException {
userNameTextBox.sendKeys(userName);
}
public static void main(String[] args) throws IOException, InvalidFormatException, InterruptedException {
LaunchApplication.launchApp("samsungtablet");--This code will launch the app based on device passed
LoginPage lp= new LoginPage();
lp.login("test", "test");---Failing here
}
【问题讨论】:
-
显示初始化和/或传递对驱动程序的引用的代码...
-
感谢您的提示,这就是问题所在,我已修复并且成功了
标签: java selenium appium appium-android