简体   繁体   English

在ios UI Automation中浏览多个页面

[英]Swiping through multiple pages in ios UI Automation

working in the ios UI Automation instrument and I am currently stuck. 在ios UI自动化工具中工作,我目前陷入困境。 My problem is I am trying to automate a horizontal swipe between pages in javascript and I can't seem to get it to work. 我的问题是我试图在javascript中的页面之间自动进行水平滑动,但似乎无法正常工作。

I have tried: 我努力了:

"dragInsideWithOptions" “dragInsideWithOptions”

"flickInsideWithOptions" “flickInsideWithOptions”

"dragToFromDuration" “dragToFromDuration”

"flickFromTo" “flickFromTo”

target.dragFromToForDuration({x:50.00, y:200.00}, {x:300.00, y:200.00}); target.dragFromToForDuration({x:50.00,y:200.00},{x:300.00,y:200.00});

a problem that keeps occurring is it keeps targeting the top navigation bar when I just want it to target somewhere on the window to actually change to a new page. 一直存在的问题是,当我只希望它定位到窗口上的某个位置以实际更改为新页面时,它一直定位到顶部导航栏。 The only info I saw on the references for UI automation deals with rects() and it seems that everytime i specify {x:, y:}{x:, y:} coordinates it thinks im talking about a toolbar or navigationBar. 我在UI自动化参考上看到的唯一信息是关于rects()的,似乎每当我指定{x :, y:} {x :, y:}坐标时,它就会以为我在谈论工具栏或NavigationBar。 It is not in a scroll view so I simply cannot scroll "left" or "right." 它不在滚动视图中,因此我根本无法滚动“左”或“右”。 Is there another function I can call that will allow my test to move to a different page? 我是否可以调用另一个函数,以使我的测试移至其他页面?

Try this it will works perfectly for me: 试试这个,对我来说将是完美的:

Pseudo code: 1. Identify the cell you want to perform the swipe Gesture on. 伪代码:1.标识要在其上执行手势的单元格。 Eg: Perform swipe on a Table View cell. 例如:在“表格视图”单元格上执行滑动。 2. Record the events by tapping at the starting of the cell and the ending of the cell to get the start and end offset. 2.通过在单元格的开头和单元格的结尾处点按以记录开始和结束偏移,以记录事件。

By looking at recorded tap event you can get the tap offeset when yopu choose tapWithOptions method. 通过查看记录的敲击事件,您可以在yopu选择tapWithOptions方法时获得敲击信号。

eg: you will get tapWithOptions({tapOffset:{x:1.07, y:0.65}}); 例如:您将获得tapWithOptions({tapOffset:{x:1.07,y:0.65}});

Then note down the offset as start offset. 然后记下偏移量作为起始偏移量。 eg: {startOffset:{x:0.03, y:0.44} 例如:{startOffset:{x:0.03,y:0.44}

Similarly do the above for the end offset from the end tap point. 类似地,对距末端抽头点的末端偏移量执行上述操作。

eg: endOffset:{x:0.81, y:0.50} 例如:endOffset:{x:0.81,y:0.50}

Once you get the source and the end offsets on that cell, 一旦获得了该单元的源和结束偏移量,

  1. Use the dragInsideWithOptions method on the above offsets. 在上述偏移量上使用dragInsideWithOptions方法。

dragInsideWithOptions({startOffset:{x:0.03, y:0.44}, endOffset:{x:0.81, y:0.50},duration:1} dragInsideWithOptions({startOffset:{x:0.03,y:0.44},endOffset:{x:0.81,y:0.50},持续时间:1}

Finally it looks something like below: app.mainWindow().tableViews()["UBSTableView"].cells()[0].dragInsideWithOptions({startOffset:{x:0.03, y:0.44}, endOffset:{x:0.81, y:0.50},duration:1}); 最后,它看起来像下面这样:app.mainWindow()。tableViews()[“ UBSTableView”]。cells()[0] .dragInsideWithOptions({startOffset:{x:0.03,y:0.44},endOffset:{x:0.81 ,y:0.50},持续时间:1}); app.mainWindow().tableViews()["UBSTableView"].cells()[0].buttons()[0].tap(); 。app.mainWindow()tableViews()[ “UBSTableView”]细胞()[0] .buttons()[0] .tap();

Hope that helps everyone :) 希望对大家有帮助:)

If you are using iOS7 simulator then these method wont work. 如果您使用的是iOS7模拟器,则这些方法将无效。 But these method will perfectly fine on Device. 但是这些方法将在Device上完全正常。 Try to run your code on device. 尝试在设备上运行代码。 Hope this will help you 希望这个能对您有所帮助

Try to update your dragFromToDuration call with timeout value: 尝试使用超时值更新您的dragFromToDuration调用:

target.dragFromToForDuration({x:50.00, y:200.00}, {x:300.00, y:200.00}, 3);

I hope this will help. 我希望这将有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM