-
Notifications
You must be signed in to change notification settings - Fork 743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CSS selector matcher #211
Comments
In Espresso, I can login via arbitrary CSS selectors or XPath. // Espresso
String EMAIL = "input[type=\"email\"]";
String PASSWORD = "input[type=\"password\"]";
onWebView()
.withElement(findElement(Locator.CSS_SELECTOR, EMAIL))
.perform(webKeys("some email"))
.withElement(findElement(Locator.CSS_SELECTOR, PASSWORD))
.perform(webKeys("password")) |
https://gist.github.com/tirodkar/cf4a72d98264545749b063e79838fa03 looks like a good work around until the new webview APIs are ready. |
Would adding a css selector as a matcher address this issue? If so, we could rephrase this to sound like a feature request and add the example above as a test for the feature. |
Yes. |
some notes since I've started looking into this: Espresso serializes HTML elements to a JSON ElementReference That looks like:
which is standard WebDriver. I haven't yet figured out how to create references from a located HTML element although the following code looks promising. |
Here's the code for my port of Espresso's WebView logic to Swift & EarlGrey. It's very much a proof of concept with most of the APIs not yet implemented. The approach is verified as working though. |
I pushed an update which adds element reference support & webKeys (typing text). Example usage: private let EMAIL_FIELD_CSS = "input[name=\"email\"]";
if let emailElement = DriverAtoms.findElement(locator: Locator.CSS_SELECTOR, value: EMAIL_FIELD_CSS) {
DriverAtoms.webKeys(element: emailElement, value: "[email protected]")
} |
As we spoke on Slack, could you please update the links? Maybe I'll try to implement your solution which seems to be very interesting ;) |
Do you have a matcher we could add in EG 2 as well? @bootstraponline |
I completed the experimental prototype for EarlGrey 1. I'm not sure if it works for EG2. I expect it'd need some stabilization before being mainlined. XCUITest solved the simple webview use case I cared about. I think a larger project to port espresso web for real to EarlGrey would be nice. |
Given the following
input
:Matching on title or value will fail.
Place holder matching works but it's not unique.
I think we need to allow matching on arbitrary XPath selectors since there's no way to control the content of the webview.
The text was updated successfully, but these errors were encountered: