ios - XCTest Swift - How do I swipe faster or more precisely? -


i have tests in xctest using swift , trying swipe through feed until condition met. using swipeup(), problem acts human swipe , has painful animation of slowing down when lets go. doesn't try swipe again until slowing-down-animation complete. additionally, method takes no arguments. see if there calabash or shoot androids espresso there properties swipe method swipeup(fast) or swipeup(medium) or swipeup(x0,y200).

here trying in code:

    func scrolldownuntilyoufindsomething() {     while !findingsomehting.exists {         app.swipeup()     } } 

simple enough, swipeup() in xcuiapplication painfully slow. want able swipe precision , coordinate. tried use coordinate approach taken replicate pull refresh in xctest ui testing

but equally slow when put loop.

yes, can have co-ordinate based swipe in swift. can create our own swipe action using pressforduration(duration, thendragtoelement: xcelement). please see example below.

for need

  1. reference element in view.(pick 1 in section swiping action has performed, , should not draggable element).
  2. a beginning co-ordinate respect reference element.
  3. an end co-ordinate/xcuielement respect reference element.

then can have function similar below (in swift 3)

func customswipe(refelement:xcuielement,startdelxy:cgvector,enddeltaxy: cgvector){       let swipestartpoint = refelement.coordinate(withnormalizedoffset: startdelxy)       let swipeendpoint = refelement.coordinate(withnormalizedoffset: enddeltaxy)       swipestartpoint.press(forduration: 0.1, thendragto: swipeendpoint)  } 

here if startdelxy (0.0,0.0) , enddeltaxy (0.0,-ve), swipe go upward refelement. if enddeltaxy (0.0,+ve) swipe go down.this because our reference element origin, x +ve going right , y +ve going below our reference element. start smaller values of y (say -0.75) , change necessary. more difference, longer swipe.

the swipestartpoint , swipeendpoint can replaced element (if such exists in view). usually, swipeendpoint can go element in nav bar swipeup action. also, changing x can give customswipes in left , right directions.

as speed of swiping, i'm not aware of api can swipe faster/slower default rate.


Comments