[英]Getting error while executing program to swipe down the screen using Appium
在执行程序以使用Appium向下滑动屏幕时出现错误。
虽然该代码对于向右或向左滑动都可以正常工作,但是在向下滑动屏幕时却出现错误。
几天我几乎要敲头了。 请帮忙。 我已附上代码和错误消息,以供您检查。
提前致谢。
public class SwipeScreen {
AndroidDriver dr;
@Test
public void testApp() throws MalformedURLException, InterruptedException{
DesiredCapabilities capabilities = new DesiredCapabilities("appWaitActivity", null, null);
File app =new File(System.getProperty("user.dir")+"\\app\\net.one97.paytm (1).apk");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "android");
capabilities.setCapability("deviceName","samsung-gt_i9060-42035bec4397 c000");
capabilities.setCapability("PlatformVersion","4.2.2");
capabilities.setCapability("PlatformName","Android");
capabilities.setCapability("app",app.getAbsolutePath());
// capabilities.setCapability("appPackage","com.android.settings");
// capabilities.setCapability("appActivity","com.android.settings.SettingsTabActivity");
dr = new AndroidDriver(new URL("http://192.168.10.165:4723/wd/hub"),capabilities);
dr.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
Thread.sleep(50000);
System.out.println(dr.manage().window().getSize().getWidth());
System.out.println(dr.manage().window().getSize().getHeight());
int screenWidth = dr.manage().window().getSize().getWidth();
int screenHeight = dr.manage().window().getSize().getHeight();
//Swipe Right
int startx = screenWidth*8/9;
int endx = screenWidth/9;
int starty = screenHeight/2;
int endy = screenHeight/2;
dr.swipe(startx, starty, endx, endy, 5000);
Thread.sleep(50000);
//Swipe Left
startx = screenWidth/9;
endx = screenWidth*8/9;
starty = screenHeight/2;
endy = screenHeight/2;
dr.swipe(startx, starty, endx, endy, 5000);
Thread.sleep(50000);
//swipe down
startx = screenWidth/2;
endx = screenWidth/2;
starty = screenHeight*6/7;
endy = screenHeight/5;
dr.swipe(startx, starty, endx, endy, 10000);
Thread.sleep(50000);
//swipe up
startx = screenWidth/2;
endx = screenWidth/2;
starty = screenHeight/6;
endy = screenHeight*5/6;
dr.swipe(startx, starty, endx, endy, 5000);
}
}
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session.
Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:58'
System info: host: 'Halcyon2-PC', ip: '192.168.140.172', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Driver info: driver.version: AndroidDriver
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.