Appium appium 如何在运行时该如何直接定位到我在想要运行的软件?

xuxiujin · 2014年10月17日 · 最后由 Winnie 回复于 2015年05月25日 · 2085 次阅读

现在有一个问题,就是我在运行测试的软件时录制了几个动作,分别是三个滑动的手势,两个输入 text 文本的动作,一个点击按钮的动作,最后 “replay” 的时候发现它并不能定位到我要运行目标软件,只是做了以上的几个手势就没了。
想请问各位要在下面代码中加些什么才能定位到我的目标软件呢?

import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;

public class {scriptName} {
    public static void main(String[] args) {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("appium-version", "1.0");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("deviceName", "test");
        capabilities.setCapability("app", "/Users/hipal/Desktop/hipalAndroid-1.apk");
        capabilities.setCapability("appPackage", "com.lvtech.hipal");
        capabilities.setCapability("appActivity", "LoadingActivity");
        wd = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 719); put("startY", 663); put("endX", 12); put("endY", 687); put("duration", 0.5); }});
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 722); put("startY", 652); put("endX", 9); put("endY", 656); put("duration", 0.5); }});
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 714); put("startY", 663); put("endX", 14); put("endY", 655); put("duration", 1.118691); }});
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 718); put("startY", 675); put("endX", 10); put("endY", 675); put("duration", 1.114355); }});
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 712); put("startY", 698); put("endX", 4); put("endY", 698); put("duration", 0.5); }});
(JavascriptExecutor)wd.executeScript("mobile: swipe", new HashMap<String, Double>() {{ put("touchCount", 1); put("startX", 719); put("startY", 660); put("endX", 13); put("endY", 664); put("duration", 0.5); }});

(JavascriptExecutor)wd.executeScript("mobile: tap", new HashMap<String, Double>() {{ put("tapCount", 3); put("touchCount", 4); put("duration", 1.536816); put("x", 337); put("y", 941); }});
        wd.findElement(By.xpath("//android.widget.RelativeLayout[1]/android.widget.EditText[1]")).sendKeys("527628581@qq.com");
        wd.findElement(By.xpath("//android.widget.RelativeLayout[1]/android.widget.EditText[2]")).sendKeys("123456");
(JavascriptExecutor)wd.executeScript("mobile: tap", new HashMap<String, Double>() {{ put("tapCount", 3); put("touchCount", 3); put("duration", 1.24373); put("x", 248); put("y", 490); }});
        wd.close();
    }
}```
共收到 2 条回复 时间 点赞

可以先看一下 Appium 的 Sample Code

请问你是如何录制脚本的呢?

3楼 已删除
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册