patrol icon indicating copy to clipboard operation
patrol copied to clipboard

Have the ability to mock the device's location using XCUILocation on iOS

Open jointhejourney opened this issue 1 year ago • 1 comments

Use case

Hello,

I noticed the issue https://github.com/leancodepl/patrol/issues/1961 was recently closed, but I was wondering if there's any way we could implement mocking for the location of the phone by using XCUILocation as described here on Apple's doc?

Example:

import XCTest
import CoreLocation


final class SampleAppTests: XCTestCase {

  func testExample() throws {
    XCUIDevice.shared.location = XCUILocation(location: CLLocation(latitude: 37.334886, longitude: -122.008988))
	// Launch your app and run the test.
  }
}

Proposal

Ideally, we'd be able to use a method like await $.native.setLocation(LatLng(37.334886, -122.008988));

However if we're limited to before the app is launched, then perhaps we can pass coordinates to NativeAutomatorConfig()?

jointhejourney avatar Jan 07 '24 20:01 jointhejourney

Hi, nice find. It looks like a good starting point for implementing this feature if it's actually going to work.

piotruela avatar Jan 11 '24 07:01 piotruela