calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Expose DeviceAgent.clear_text as public method #1168

Open jmoody opened 8 years ago

jmoody commented 8 years ago

Reported by @wellsinator

Is the view you are trying interact with a SafariWebViewController?

Thanks!

AlexWellsHS commented 8 years ago

My app has a button to "Sign Up with Facebook". When it is touched, the app opens a Safari webview. The one element with type:"TextView" in the webview can be queried with device_agent.query({type:"TextField"}), but device_agent.query({type:"TextField", index:0}) returns nil. The only time I could get the webview to "flash" was by using flash("* marked:'RemoteViewBridge'"). The element's class is "_UIRemoteView", and falls in the tree: [UITransitionView] [UIView] [UIView] [_UISizeTrackingView] [_UIRemoteView] [id:RemoteViewBridge]

I have not yet found the exact name/type of the webview, but I can investigate more.

edited: changed "style" to "type"

AlexWellsHS commented 8 years ago

Previous to iOS 10, i used methods very similar to the ones used in https://github.com/calabash/calabash-ios/issues/861 I am trying to migrate commands from UIA to device_agent, and got a noMethod error when trying to use device_agent.clear_text({type:"TextField"})

edited: changed "marked" to "type" in clear_text method

jmoody commented 8 years ago

style:

I hope you mean type:

jmoody commented 8 years ago
# Do not filter by visibility
device_agent.query({type: "TextField", all: true})

The visibility heuristic is a WIP.

AlexWellsHS commented 8 years ago

My apologies, but I do not understand the relevance of visibility filtering for this issue... only been at this for a few months...

jmoody commented 8 years ago

@AlexWellsHS

visibility

DeviceAgent is based on Apple's XCUITest. When you query with DeviceAgent, we rely on XCUITest to tell us whether or not a view is visible - we inspect the XCUIElement attributes to determine if the view is visible to the user. XCUITest is very inconsistent about return good information about visibility. In this case, I believe the view is visible to the user and XCUITest is saying the view is not visible. I am suggesting that you disable the visibility filter and just ask for the all results using the query specifier: :all => true.

This is similar to using:

query("all UITextField")

to return all text fields regardless of whether or not Calabash has determined the view is visible to the users.

Docs

http://calabashapi.xamarin.com/ios/Calabash/Cucumber/DeviceAgent.html#query-instance_method

AlexWellsHS commented 8 years ago

I believe this issue was originally created for the discrepancy with: keyboard_visible? returns false device_agent.keyboard_visible? returns true while looking at this webview, with the keyboard visible the issue is better described here: https://github.com/calabash/calabash-ios/issues/1166

jmoody commented 8 years ago

Cannot be part of 0.20.3 release - there are some problems that are still being resolved on the DeviceAgent regarding the clear_text gesture.

ATTN: @jescriba - DeviceAgent 1.0.2 does not contain our clear_text changes.

https://github.com/calabash/DeviceAgent.iOS/pull/170