Skip to content
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

au.getElementsByName is undefined #163

Closed
bootstraponline opened this issue Feb 12, 2013 · 6 comments
Closed

au.getElementsByName is undefined #163

bootstraponline opened this issue Feb 12, 2013 · 6 comments
Labels
Bug a problem that needs fixing

Comments

@bootstraponline
Copy link
Member

Why doesn't @driver.find_elements :name, 'Sign In' work?

> @driver.find_elements :name, 'Sign In'
post
session/842b0ebc-f720-4a0a-a991-5aaada06c7b0/elements
{"using":"name","value":"Sign In"}
Selenium::WebDriver::Error::JavascriptError: 'undefined' is not a function (evaluating 'au.getElementsByName('Sign In')')

debug: Appium request received with params: {"using":"name","value":"Sign In"}
info: [INSTSERVER] Sending command to instruments: au.getElementsByName('Sign In')
info: Pushed command to appium work queue: au.getElementsByName('Sign In')
info: [INST] 2013-02-12 17:03:12 +0000 Default: Got new command from instruments: au.getElementsByName('Sign In')
info: [INSTSERVER] Socket data received (125 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: [INSTSERVER] Got result from instruments: {"status":17,"value":"'undefined' is not a function (evaluating 'au.getElementsByName('Sign In')')"}
info: Responding to client with error: {"status":17,"value":"'undefined' is not a function (evaluating 'au.getElementsByName('Sign In')')","sessionId":"842b0ebc-f720-4a0a-a991-5aaada06c7b0"}
POST /wd/hub/session/842b0ebc-f720-4a0a-a991-5aaada06c7b0/elements 500 472ms - 164

It appears that au.getElementByName(... is defined and au.getElementsByName(... isn't.

@jlipps
Copy link
Member

jlipps commented Feb 12, 2013

In Appium-land, get element by name should really be thought of like get element by ID---names are taken to be unique since they are unique labels given to UI elements by the developer inside xcode. thus it doesn't make sense to get multiple elements by name. but:

  • I'm not sure why we get by "name" rather than "ID" in this case. @sourishkrout you worked on this, any thoughts?
  • Even if this is the way things have to stay, it seems like "name" is confusing since it doesn't imply uniqueness when that is what we really want it to mean.

@bootstraponline
Copy link
Member Author

it doesn't make sense to get multiple elements by name

It does. I have multiple Sign In buttons and I want to click the second one. I had to implement it like this. Appium finds the sign in button on the background window in addition to the foreground.

@sourishkrout
Copy link
Contributor

@jlipps: that's not quite right. The accessibility label doesn't have to be unique at all. That's the reason I choose not to use the get element by ID variant of element discovery form the WDJP spec.

It's even a little bit more messy. Apple choose to use the caption (e.g.) to pre-populate the element's name() but will overwrite it with the accessibility label if set in xcode.

I'm currently working on the get elements by name implementation. Stay tuned. Will also invest some time today to document all this.

@jlipps
Copy link
Member

jlipps commented Feb 12, 2013

Great, thanks for setting me straight, look forward to the upcoming changes.

@sourishkrout
Copy link
Contributor

Get elements by name is ready to go... Working on the documentation part of it right now.

@lock
Copy link

lock bot commented May 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot unassigned sourishkrout May 4, 2019
@lock lock bot locked and limited conversation to collaborators May 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug a problem that needs fixing
Projects
None yet
Development

No branches or pull requests

3 participants