我无法连接到我的应用。无法在appPack和appActivity中输入内容。
遵循的步骤:
我的设备已连接并在线显示。当我执行此代码时,它没有显示任何错误。
请告诉我我的剧本不正确的地方。
public class testApp {
/**
* @param args
*/
public class movein {
// TODO Auto-generated method stub
WebDriver dr;
@Test
public void testApp() throws MalformedURLException, InterruptedException{
File app = new File("F:\\Mobile-testing\\apps\abc.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Nexus 5");
capabilities.setCapability("platformVersion", "4.4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.abc");
capabilities.setCapability("appActivity", "com.abc");
dr = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
// clicking
}
}
}
我的Appium设置:
Server : 127.0.0.1 Port :4723
我的Appium信息:
info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"}
我有appPack并且也从adb日志输入了appActivity。现在我面临错误:
(org.openqa.selenium.remote.UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器的无效地址或浏览器启动失败。)
我从RemoteWebDriver
更改为AppiumDriver<>
。它正在执行,现在显示错误消息:
原始错误:'java -version'失败。错误:产生ENOENT
答案 0 :(得分:0)
将设备连接到系统后。请按照以下步骤获取活动名称和包名称。
STEPS
cmd
以打开命令提示符界面。adb devices
。它会列出你的Android设备adb shell
,以进入设备。dumpsys window windows | grep -E ‘mCurrentFocus|mFocusedApp’
您尝试评论以下命令。
capabilities.setCapability("app", app.getAbsolutePath());
您可以尝试以下示例代码;
DesiredCapabilities cap1= new DesiredCapabilities();
cap1.setCapability("deviceName", "devicename");
cap1.setCapability("platformVersion", "4.4.4");
cap1.setCapability("platformName", "Android");
cap1.setCapability("browserName", "chrome");
cap1.setCapability("appPackage", "com.android.settings");
cap1.setCapability("appActivity", "com.android.settings.Settings");
AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4888/wd/hub"), cap1);
上面的示例命令将在android设备中打开settings
答案 1 :(得分:0)
尝试这篇精彩的帖子create appium node + android driver它会帮助您设置测试所需的环境