这对于那些正在学习Appium的人来说是非常有用的教程,因为刷新和滚动通常用于几乎所有移动应用程序。因此,学习使用Appium自动化它会在编写测试代码中帮助您.Below是我已经写出不同功能的代码,其中从顶部到底,从左右从左到右从左到右,从右到左使用Appium 。我们可以在我们的测试用例中进行所有这些方法来执行所需的操作。此外,我创建了一个具有详细说明的视频教程。
/** /* Method to swipe screen from Bottom to Top (Vertical) Get the size of * screen. Find swipe start and end point from screen's width and height. * Find starty point which is at bottom side of screen. Find endy point * which is at top side of screen. Find horizontal point where you wants to * swipe. It is in middle of screen width. * Time duration should be in milliseconds */ public void bottomTopswipe(int timeduration) { size = driver.manage().window().getSize(); System.out.println(size); starty = (int) (size.height * 0.50); endy = (int) (size.height * 0.20); startx = size.width / 2; System.out.println("Start swipe operation"); driver.swipe(startx, starty, startx, endy, timeduration); } /** * * Method to swipe screen from Top to Bottom (Vertical) Get the size of * screen. Find swipe start and end point from screen's width and height. * Find starty point which is at bottom side of screen. Find endy point * which is at top side of screen. Find horizontal point where you wants to * swipe. It is in middle of screen width.
* Time duration should be in milliseconds
*/ public void topBottomswipe(int timeduration) { size = driver.manage().window().getSize(); System.out.println(size); starty = (int) (size.height * 0.50); endy = (int) (size.height * 0.20); startx = size.width / 2; System.out.println("Start swipe operation"); driver.swipe(startx, endy, startx, starty, timeduration); } /** * * Method to swipe screen from right to left (Horizontal) duration should be * in milliseconds Get the size of screen. Find swipe start and end point * from screen's width and height. Find startx point which is at right side * of screen. Find endx point which is at left side of screen. Find vertical * point where you wants to swipe. It is in middle of screen height.
* Time duration should be in milliseconds
*/ public void 正确的LeftSwipe(int timeduration) { size = driver.manage().window().getSize(); System.out.println(size); startx = (int) (size.width * 0.70); endx = (int) (size.width * 0.30); starty = size.height / 2; System.out.println("Start swipe operation"); driver.swipe(startx, starty, endx, starty, timeduration); } /** * * Method to swipe screen from left to right (Horizontal) duration should be * in milliseconds Get the size of screen. Find swipe start and end point * from screen's width and height. Find startx point which is at right side * of screen. Find endx point which is at left side of screen. Find vertical * point where you wants to swipe. It is in middle of screen height.
* Time duration should be in milliseconds
*/ public void leftRightSwipe(int timeduration) { // duration should be in milliseconds size = driver.manage().window().getSize(); System.out.println(size); startx = (int) (size.width * 0.70); endx = (int) (size.width * 0.30); starty = size.height / 2; System.out.println("Start swipe operation"); driver.swipe(endx, starty, startx, starty, timeduration); }
好贴。
回复删除班加罗尔最好的Oracle培训
IEEE最后一年项目中心使最佳深度学习的最后一年的学生造成最终学生的想法 CSE的最后一年项目 培训并培养他们的深度学习体验和才能。
删除IEEE最后一年的项目 项目中心在印度 始终追捧。最后一年的学生项目拍摄他们以改善他们的娱乐,而专家喜欢干扰创新。
Chennai的企业培训 Chennai的企业培训
公司培训公司在印度 公司培训公司在印度
Chennai的企业培训公司 Chennai的企业培训公司
我读过你的博客非常有吸引力和令人印象深刻。我喜欢你的博客。 金奈数字营销公司
回复删除本文非常有用,我希望这将是所需的有用信息。继续更新这些类型的信息......
发短信API.
SMS API.
短信营销
谢谢你的精彩教程。
回复删除需要帮助。我尝试了上面的代码,但它显示了strid.swipe()的错误
"yource androiddriver的方法滑动(int,int,int,int,int)是未定义的"
你能告诉我决议吗?
如何将Swipe方法水平刷新。我能够垂直向下滑动,但水平我面临着一些问题。
回复删除是的,这些代码需要按照最新版本进行更新。等待相同。
删除嗨,我使用以下代码滑动/滚动,它是完美的。
回复删除刷新的代码
public boolean swipefromuptobottom()
{
try {
JavaScriptExecutor JS =(JavaScriptExecutor)驱动程序;
hashmap scrollobject = new hashmap();
scrollObject.put("direction", "up");
js.executeScript("mobile: scroll", scrollObject);
System.out.println("滑动成功完成。");
}
catch (Exception e)
{
System.out.println("滑动不是成功的");
}
return false;
}
代码向下滑动
公共布尔swipefrombottomtoup()
{
try {
JavaScriptExecutor JS =(JavaScriptExecutor)驱动程序;
hashmap scrollobject = new hashmap();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
System.out.println("刷下来成功完成");
}
catch (Exception e)
{
System.out.println("滑下来没有成功");
}
return false;
}
旋转木马图像的代码滑动
公共布尔SwipeImages()
{
try {
WebElement PageIndicator = Driver.FindElement(Page_Indicator);
字符串PageString = PageIndicator.getAttribute("value");
int length = pageString.Length();
String count_string = pageString.substring(长度2,长度).trim();
int count = integer.parseint(count_string);
System.out.println("可用于滑动的图像数量:"+count);
for (int i=0; i<=count; i++){
JavaScriptExecutor JS =(JavaScriptExecutor)驱动程序;
hashmap scrollobject = new hashmap();
scrollObject.put("direction", "right");
js.executeScript("mobile: scroll", scrollObject);
}
System.out.println("Swipe Successfully");
}
catch (Exception e)
{
System.out.println("图像滑动不是成功的");
}
return false;
}
谢谢Vinita.
删除此评论已被作者删除。
回复删除谢谢你的手册。一世'完成并成功
回复删除地铁冲浪者
错误: - 为Androiddriver类型滑动(int,int,int,int,int)的方法是未定义的
回复删除这个博客仍然是我现在读过的所有博客中最好的;写作伟大的写作和内容交付方式。请分享更多更新。
回复删除雅思教练在安娜纳卡尔
雅思教练在阿迪尔
雅思教练在Porur
雅思在钦奈教练
钦奈语中英语课
钦奈最佳英语课程
钦奈语中英语课
伟大的博客!!!是一个有趣的博客,概念明确。并且肯定会帮助许多人更新它们。
回复删除Chennai的反应培训
反应培训
钦奈的GST课程
钦奈的UX设计课程
反应课程
钦奈网页设计课程
钦奈的伦理黑客课程
钦奈的课程
优秀的帖子!!!您在这项技术上发布的策略帮助我进入了下一级别,并有很多信息。
回复删除班加罗尔的Java培训
好帖子,谢谢 网络安全培训
回复删除感谢您分享此信息博客
回复删除//www.digitalakash.in/web-design-development-training-in-bangalore/
谢谢你这么伟大的文章。我正在寻找相当长的时间,最后我'在你的博客上找到了它。对我来说肯定有趣,现在阅读他们的市场情况。
回复删除钦奈的甲骨文培训
在塔巴姆的甲骨文培训
钦奈的Oracle DBA培训
在塔巴姆的Oracle DBA培训
CCNA培训在钦奈
在塔巴姆培训
钦奈的SEO培训
SEO培训在塔巴姆
这个博客仍然是我现在读过的所有博客中最好的;写作伟大的写作和内容交付方式。请分享更多更新。
回复删除钦奈网页设计培训
网页设计培训在OMR中
金奈数字营销培训
OMR中的数字营销培训
钦奈的RPA培训
RPA培训OMR
钦奈的训练
在OMR中训练
非常丰富的博客和伟大的工作,
回复删除谢谢与我们分享,
钦奈数据科学培训
Porur的数据科学培训
钦奈的Android培训
Android培训在Porur
Devops在Chennai培训
Devops在Porur训练
钦奈人工智能培训
Porur的人工智能训练
很好分享谢谢你。写的很多我很感激你的工作....
回复删除钦奈的甲骨文培训
安纳诺加的Oracle培训
钦奈的Oracle DBA培训
安纳诺加的Oracle DBA培训
CCNA培训在钦奈
安娜戈尔的CCNA培训
钦奈的SEO培训
安娜戈尔的SEO培训
这是一直在寻找的信息。伟大的见解&你已经解释得很好。谢谢&期待更多这样的宝贵更新。
回复删除钦奈的甲骨文培训
甲骨文训练
钦奈的Oracle DBA培训
甲骨文DBA培训在Velachery
CCNA培训在钦奈
维拉威尔的CCNA训练
钦奈的SEO培训
在Velachery的SEO培训
伟大的博客!!!是一个有趣的博客,概念明确。
回复删除Acte评论
泰特维加拉西评论
塔巴姆举行的评论
Acte Anna Nagar评论
Acte Porur评论
Acte Omr评论
Chennai Acte Chennai评论
acte学生评论
回复删除此信息非常令人敬畏,谢谢分享最有价值的信息。
工作日工作室培训
工作日工作室在线培训
工作日课程
工作日工作室在线培训印度
工作日工作室在线培训海德拉巴
工作日工作室培训印度
aivivu - đạilývémáybay,泰国哈克
回复删除Vémáy湾đimỹbaonhiêutiền
VémỹVềviệtnam
Vémáy湾đi洛杉矶BaoNhiêuTiền
đăngký湾tì加拿大vềviệtnam
学生信息系统
回复删除学生入学管理系统
时间表管理系统
学生分配管理系统