我有一个简单的Appium自动化测试,我的代码如下:
public class Android {
public static AppiumDriver<AndroidElement> driver;
public AppiumDriver<AndroidElement> setDriver() throws MalformedURLException {
File appPath= new File("src");
File app = new File(appPath,"myApp-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "myDevice");
capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
capabilities.setCapability("autoGrantPermissions",true);
capabilities.setCapability("appWaitActivity","com.xxx.yyy.ui.launch.LaunchActivity");
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
return Android.driver;
}
我想简单地单击应用程序首页上的链接。这是我点击的代码:
public class LaunchPageTest extends Android {
@Test
public void f() throws MalformedURLException {
//LaunchPageObject lp = new LaunchPageObject(setDriver());
//lp.Click_SigninNow();
Android a=new Android();
a.setDriver().findElement(MobileBy.AndroidUIAutomator("text(\"Sign in now\")")).click();
}
驱动程序打开我的应用程序,但没有单击链接。我不明白怎么了! 预先谢谢你
P.S。这是我的Appium日志:
[debug] [W3C] Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","app":"D:\\xxx\\src\\xx-debug.apk","appWaitActivity":"com.yy.xx.ui.launch.LaunchActivity","autoGrantPermissions":true,"deviceName":"myDevice"},"platformName":"android","app":"D:\\xxx\\src\\xx-debug.apk","appWaitActivity":"com.yy.xx.ui.launch.LaunchActivity","autoGrantPermissions":true,"deviceName":"emulator-5554","deviceUDID":"emulator-5554","platformVersion":"9","deviceScreenSize":"1080x1920","deviceModel":"Android SDK built for x86","deviceManufacturer":"Google","appPackage":"com.xx.yy","appWaitPackage":"com.xx.yy","appActivity":"com.yy.xx.xx"}}
[HTTP] <-- POST /wd/hub/session 200 6428 ms - 1010
[HTTP]
[HTTP] --> GET /wd/hub/session/d9a3338e-31e9-44e1-b4f4-fcf540d41ae5
[HTTP] {}
[debug] [W3C] Calling AppiumDriver.getSession() with args: ["d9a3338e-31e9-44e1-b4f4-fcf540d41ae5"]
[debug] [W3C] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"android","app":"D:\\xx\\src\\xx-debug.apk","appWaitActivity":"com.yy.xx.ui.launch.LaunchActivity","autoGrantPermissions":true,"deviceName":"myDevice"},"platformName":"android","app":"D:\\xx\\src\\xx-debug.apk","appWaitActivity":"com.yy.xx.ui.launch.LaunchActivity","autoGrantPermissions":true,"deviceName":"emulator-5554","deviceUDID":"emulator-5554","platformVersion":"9","deviceScreenSize":"1080x1920","deviceModel":"Android SDK built for x86","deviceManufacturer":"Google","appPackage":"com.xx.yy","appWaitPackage":"com.xx.yy","appActivity":"com.yy.xx.xx"}
[HTTP] <-- GET /wd/hub/session/d9a3338e-31e9-44e1-b4f4-fcf540d41ae5 200 10 ms - 942
答案 0 :(得分:1)
我通过将 commons-lang3-3.7.jar 添加到我引用的库中来解决此问题。现在工作正常。