Open ewolfe123 opened 4 years ago
Can you try using GREY_REMOTE_CLASS_IN_APP() ?
On Fri, Feb 21, 2020 at 1:33 PM Ethan Wolfe notifications@github.com wrote:
I've setup EG2 using CocoaPods, and ensured the base functionality works. I then followed the instructions for the whitebox setup
https://github.com/google/EarlGrey/blob/earlgrey2/docs/swift-white-boxing.md
When attempting to interact with the target app, I get the following error: caught "NSInvalidArgumentException", "*** -[NSProxy doesNotRecognizeSelector:
] called!" With the CocoaPods setup, do I need to create the helper bundle, and add all of the linking as specified in the other instructions? Could someone add some clarity around this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/EarlGrey/issues/1201?email_source=notifications&email_token=ADRQEFKON5FULBLZAT2F27TREBCCZA5CNFSM4KZKYP22YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IPNHOOQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRQEFN6MYJ2IOL62CFOQHLREBCCZANCNFSM4KZKYP2Q .
@tirodkar Am I able to call that method from Swift? I'm unable to find any documentation around how to use that.
Also, after running the cocoapods setup, are there any steps required before trying the whitebox setup? The flow for setup is unclear when working with CocoaPods.
On Mon, Feb 24, 2020 at 9:38 AM Ethan Wolfe notifications@github.com wrote:
@tirodkar https://github.com/tirodkar Am I able to call that method from Swift? I'm unable to find any documentation around how to use that.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/EarlGrey/issues/1201?email_source=notifications&email_token=ADRQEFK5UV26CIKHHBY77J3REQAYZA5CNFSM4KZKYP22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMY2QWY#issuecomment-590456923, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRQEFJ2KIH4ZD4CD57HAW3REQAYZANCNFSM4KZKYP2Q .
@tirodkar Ok, so I tried
let targetApp = GREYRemoteClassInApp(classVal: UIApplication.self).shared
targetApp.setStatusBarOrientation(UIInterfaceOrientation.landscapeLeft, animated: false)
And got the following error:
caught "NSInvalidArgumentException", "*** -[NSProxy doesNotRecognizeSelector:grey_trackAsRootViewControllerForWindow:] called!"
I was able to perform validations, though. The following worked:
let targetApp = GREYRemoteClassInApp(classVal: UIApplication.self).shared
XCTAssertTrue(targetApp.statusBarOrientation.isPortrait)
What do I need to do enable the manipulation of the target app (ex. set the root view controller for a specific test)? Is there any setup I am missing?
@tirodkar Using EG2, are we able to modify the application under test? For example, If I would like to set a window's root view controller, or inject a mocked api client into the app, does using the remote access to the app under test allow me to do that?
I am trying to do the same thing. I have setup my targetApp (as above):
let targetApp = GREYRemoteClassInApp(classVal: UIApplication.self).shared
let scene = targetApp
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.compactMap {$0 as? UIWindowScene}
.first
However, I get a crash on filter { $0.activationState == .foregroundActive }
:
Could not cast value of type 'EDOObject' (0x10fc02af8) to 'UIScene' (0x7fff898a50b0).
2020-03-23 17:57:25.144628-0700 SandboxIntegrationTests-Runner[9153:3048750] Could not cast value of type 'EDOObject' (0x10fc02af8) to 'UIScene' (0x7fff898a50b0).
My intention is to find the keyWindow of the scene:
let window = scene?.windows.filter({ $0.isKeyWindow }).first
and then set the root controller of the window to the view I am trying to test.
Any thoughts on how to modify the application under test
similar to EarlGrey?
@tirodkar Using EG2, are we able to modify the application under test? For example, If I would like to set a window's root view controller, or inject a mocked api client into the app, does using the remote access to the app under test allow me to do that?
We
@tirodkar Ok, so I tried
let targetApp = GREYRemoteClassInApp(classVal: UIApplication.self).shared targetApp.setStatusBarOrientation(UIInterfaceOrientation.landscapeLeft, animated: false)
And got the following error:
caught "NSInvalidArgumentException", "*** -[NSProxy doesNotRecognizeSelector:grey_trackAsRootViewControllerForWindow:] called!"
I was able to perform validations, though. The following worked:
let targetApp = GREYRemoteClassInApp(classVal: UIApplication.self).shared XCTAssertTrue(targetApp.statusBarOrientation.isPortrait)
What do I need to do enable the manipulation of the target app (ex. set the root view controller for a specific test)? Is there any setup I am missing?
We are observing this behavior as well when setting up a basic project with Pods. Did you manage to find a solution?
I've setup EG2 using CocoaPods, and ensured the base functionality works. I then followed the instructions for the whitebox setup.
When attempting to interact with the target app, I get the following error:
caught "NSInvalidArgumentException", "*** -[NSProxy doesNotRecognizeSelector:<method_name>] called!"
With the CocoaPods setup, do I need to create the helper bundle, and add all of the linking as specified in the other instructions? Could someone add some clarity around this?