XPath OR support #242

Closed
bootstraponline opened this Issue Mar 7, 2013 · 12 comments

Comments

Projects
None yet
3 participants
@bootstraponline
Owner

bootstraponline commented Mar 7, 2013

> $driver.find_elements :xpath, "textfield | secure"
post
session/3d2dbc2d-acac-4dc2-8d3f-67559da20567/elements
{"using":"xpath","value":"textfield | secure"}
EOFError: end of file reached
)> $driver.find_elements :xpath, "//textfield | //secure" 
post
session/dd60c223-84ff-4767-a61c-776a15c0623f/elements
{"using":"xpath","value":"//textfield | //secure"}
EOFError: end of file reached

For Android compatability, I need to get all the textfields and all the secure textfields from iOS. It doesn't look like Appium's XPath implementation supports |?

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 7, 2013

Owner

This is a workaround however an empty hash is returned instead of the expected WebDriver element.

> a = $driver.execute_script "au.lookup('secure').concat(au.lookup('textfield'));"
post
session/c208210e-59b3-4e58-bbb1-47b6feb5cd38/execute
{"script":"au.lookup('secure').concat(au.lookup('textfield'));","args":[]}
=> [{}, {}]
> a.first.value
NoMethodError: undefined method `value' for {}:Hash
> a
=> [{}, {}]
> a.first
=> {}
> a.first.class
=> Hash
Owner

bootstraponline commented Mar 7, 2013

This is a workaround however an empty hash is returned instead of the expected WebDriver element.

> a = $driver.execute_script "au.lookup('secure').concat(au.lookup('textfield'));"
post
session/c208210e-59b3-4e58-bbb1-47b6feb5cd38/execute
{"script":"au.lookup('secure').concat(au.lookup('textfield'));","args":[]}
=> [{}, {}]
> a.first.value
NoMethodError: undefined method `value' for {}:Hash
> a
=> [{}, {}]
> a.first
=> {}
> a.first.class
=> Hash
@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 7, 2013

Owner

This sort of works, however it doesn't let me combine lookups.

s = %(
var e = au.lookup('textfield');
au._returnElems(e);
)

execute_script s
Owner

bootstraponline commented Mar 7, 2013

This sort of works, however it doesn't let me combine lookups.

s = %(
var e = au.lookup('textfield');
au._returnElems(e);
)

execute_script s
@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 7, 2013

Owner

I figured it out.

s = %(
var t = au.lookup('textfield');
var s = au.lookup('secure');
var r = $(t.concat(s));
au._returnElems(r);
)

execute_script s
Owner

bootstraponline commented Mar 7, 2013

I figured it out.

s = %(
var t = au.lookup('textfield');
var s = au.lookup('secure');
var r = $(t.concat(s));
au._returnElems(r);
)

execute_script s
@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 7, 2013

Owner

This is what I had to do to get textfield working cross platform.

Owner

bootstraponline commented Mar 7, 2013

This is what I had to do to get textfield working cross platform.

@jlipps

This comment has been minimized.

Show comment Hide comment
@jlipps

jlipps Mar 7, 2013

Owner

That's a clever workaround, however it would be nice to support | in the subset of xpath syntax. I'm confused why you didn't get a more meaningful error--you should have gotten something like "XPath selector could not be parsed" or something like that. That's the first thing to fix, then we can talk about adding |.

Owner

jlipps commented Mar 7, 2013

That's a clever workaround, however it would be nice to support | in the subset of xpath syntax. I'm confused why you didn't get a more meaningful error--you should have gotten something like "XPath selector could not be parsed" or something like that. That's the first thing to fix, then we can talk about adding |.

@ghost ghost assigned jlipps Mar 7, 2013

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 7, 2013

Owner

That's a clever workaround, however it would be nice to support |

I agree. I just need something working immediately.

That's the first thing to fix, then we can talk about adding |.

👍 I was surprised that it crashed.

Owner

bootstraponline commented Mar 7, 2013

That's a clever workaround, however it would be nice to support |

I agree. I just need something working immediately.

That's the first thing to fix, then we can talk about adding |.

👍 I was surprised that it crashed.

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 14, 2013

Owner

It doesn't crash anymore now.

Owner

bootstraponline commented Mar 14, 2013

It doesn't crash anymore now.

@jlipps

This comment has been minimized.

Show comment Hide comment
@jlipps

jlipps Mar 14, 2013

Owner

Does it give a nice error?

Owner

jlipps commented Mar 14, 2013

Does it give a nice error?

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 14, 2013

Owner

Does it give a nice error?

Yes. It's slightly different on iOS and Android.

Selenium::WebDriver::Error::XPathLookupError: Could not parse xpath data from //textfield | //secure vs
Selenium::WebDriver::Error::XPathLookupError: An error occurred while searching for an element by XPath.

Much better than crashing.

Owner

bootstraponline commented Mar 14, 2013

Does it give a nice error?

Yes. It's slightly different on iOS and Android.

Selenium::WebDriver::Error::XPathLookupError: Could not parse xpath data from //textfield | //secure vs
Selenium::WebDriver::Error::XPathLookupError: An error occurred while searching for an element by XPath.

Much better than crashing.

@jlipps jlipps closed this Mar 20, 2013

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Mar 20, 2013

Owner

I think it might be better to turn this into a feature request by adjusting the issue title.

Owner

bootstraponline commented Mar 20, 2013

I think it might be better to turn this into a feature request by adjusting the issue title.

@DylanLacey

This comment has been minimized.

Show comment Hide comment
@DylanLacey

DylanLacey Apr 23, 2014

Contributor

Is this closed by f78cee9 et al?

Contributor

DylanLacey commented Apr 23, 2014

Is this closed by f78cee9 et al?

@bootstraponline

This comment has been minimized.

Show comment Hide comment
@bootstraponline

bootstraponline Apr 23, 2014

Owner

Yes

Owner

bootstraponline commented Apr 23, 2014

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment