Skip to content

Commit

Permalink
Merge pull request #1 from devexperts/feature/addCenter
Browse files Browse the repository at this point in the history
Adds a new .center extension
  • Loading branch information
rzakhar authored Dec 23, 2022
2 parents 89108ed + 763487f commit a05796f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import XCTest
@available(iOS 9.0, *)
@available(tvOS 9.1, *)
public extension XCUIElement {
// Returns the center's coordinate of the element's frame
var center: XCUICoordinate {
coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
}

// Types delete symbols into the element.
func clearText() {
XCTContext.runActivity(named: "Clear \(self) text") { _ in
Expand All @@ -31,7 +36,7 @@ public extension XCUIElement {
// Sends a tap event at the element's coordinate. Useful if the regular .tap() fails.
func tapUnhittable() {
XCTContext.runActivity(named: "Tap \(self) by coordinate") { _ in
coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
center.tap()
}
}
#endif
Expand Down

0 comments on commit a05796f

Please sign in to comment.