Guest User

Untitled

a guest
Mar 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. let statusBar = XCUIApplication().statusBars.elementBoundByIndex(0)
  2. statusBar.swipeDown()
  3.  
  4. let iconFrame = icon.frame // App icon on the springboard
  5. let springboardFrame = springboard.frame // The springboard (homescreen)
  6. icon.pressForDuration(1.3) // tap and hold
  7.  
  8. // Tap the little "X" button at approximately where it is. The X is not exposed directly
  9. springboard.coordinateWithNormalizedOffset(CGVectorMake((iconFrame.minX + 3) / springboardFrame.maxX, (iconFrame.minY + 3) / springboardFrame.maxY)).tap()
  10.  
  11. let myElementFrame = myElement.frame
  12. let appFrame = XCUIApplication().frame
  13. let middleOfElementVector = CGVectorMake(iconFrame.midX / appFrame.maxX, iconFrame.midY / appFrame.maxY)
  14.  
  15. // Tap element from the app-level at the given coordinate
  16. XCUIApplication().coordinateWithNormalizedOffset(middleOfElementVector).tap()
  17.  
  18. let springboard = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.springboard")
  19. springboard.resolve()
  20.  
  21. @interface XCUIApplication (Private) {
  22. - (id)initPrivateWithPath:(id)arg1 bundleID:(id)arg2;
  23. }
  24.  
  25. @interface XCUIElement (Private) {
  26. - (void) resolve;
  27. }
  28.  
  29. let bottomPoint = app.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 2))
  30. app.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).press(forDuration: 0.1, thenDragTo: bottomPoint)
  31. let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
  32. springboard.scrollViews.firstMatch.swipeRight()
  33.  
  34. let editButton = springboard.buttons["Edit"]
Add Comment
Please, Sign In to add comment