TA的每日心情 | 擦汗 10 小时前 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
问题:
appium 如何在运行时该如何直接定位到我在想要运行的软件?
现在有一个问题,就是我在运行测试的软件时录制了几个动作,分别是三个滑动的手势,
两个输入text文本的动作,一个点击按钮的动作,最后“replay”的时候发现它并不能定
位到我要运行目标软件,只是做了以上的几个手势就没了。
想请问各位要在下面代码中加些什么才能定位到我的目标软件呢?
- <div><font face="微软雅黑" size="3">import io.appium.java_client.AppiumDriver;</font></div><div><font face="微软雅黑" size="3">import org.openqa.selenium.remote.DesiredCapabilities;</font></div><div><font face="微软雅黑" size="3">import java.net.URL;</font></div><div><font face="微软雅黑" size="3">
- </font></div><div><font face="微软雅黑" size="3">public class {scriptName} {</font></div><div><font face="微软雅黑" size="3"> public static void main(String[] args) {</font></div><div><font face="微软雅黑" size="3"> DesiredCapabilities capabilities = new DesiredCapabilities();</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("appium-version", "1.0");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("platformName", "Android");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("platformVersion", "4.4");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("deviceName", "test");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("app", "/Users/hipal/Desktop/hipalAndroid-1.apk");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("appPackage", "com.lvtech.hipal");</font></div><div><font face="微软雅黑" size="3"> capabilities.setCapability("appActivity", "LoadingActivity");</font></div><div><font face="微软雅黑" size="3"> wd = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);</font></div><div><font face="微软雅黑" size="3"> wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3">
- </font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3"> wd.findElement(By.xpath("//android.widget.RelativeLayout[1]/android.widget.EditText[1]")).sendKeys("527628581@qq.com");</font></div><div><font face="微软雅黑" size="3"> wd.findElement(By.xpath("//android.widget.RelativeLayout[1]/android.widget.EditText[2]")).sendKeys("123456");</font></div><div><font face="微软雅黑" size="3">(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); }});</font></div><div><font face="微软雅黑" size="3"> wd.close();</font></div><div><font face="微软雅黑" size="3"> }</font></div><div><font face="微软雅黑" size="3">}```</font></div>
复制代码
|
|