Reputation: 2859
I want to write an UI automation test that log in by using Google. The webview is embedded in the app. In Earlgrey, how can I select a text field or a button of a web view. Thanks
Upvotes: 3
Views: 1481
Reputation: 251
EarlGrey provides a great log of the UI hierarchy when a test fails. My suggestion is to write a test that navigates to the login view, and then force EarlGrey to fail. Then in the log, look for the elements you need. You should see something like:
--<WebAccessibilityObjectWrapper:0x7fbca2422fb0; AX=Y; AX.value='Email'; AX.frame={{72, 145}, {270, 38}}; AX.activationPoint={207, 164}; AX.traits='UIAccessibilityTraitNone'; AX.focused='Y'>
--<WebAccessibilityObjectWrapper:0x7fbca4e82360; AX=Y; AX.value='Password'; AX.frame={{72, 201}, {270, 38}}; AX.activationPoint={207, 220}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'>
From this log you can see that the two elements are accessible via:
EarlGrey().selectElementWithMatcher(grey_accessibilityValue("Email"))
EarlGrey().selectElementWithMatcher(grey_accessibilityValue("Password"))
Upvotes: 1