Skip to content

findelement byname does not work with appium 1.9.1 #1050

Closed

Description

@helenren

On a native page, my test tries to find an element via byname: command passed into driver is: findElement(By.name: EULA.agree), while I saw the command executed to the appium server is:

2018-10-25 03:23:24:329 - info: [HTTP] --> POST /wd/hub/session/22bd911d-ed10-47f6-bd77-f327b5562c48/elements
2018-10-25 03:23:24:329 - info: [HTTP] {"value":"*[name='EULA.agree']","using":"css selector"}

The same test works fine against appium 1.8.1

Environment

  • Appium version (or git revision) that exhibits the issue: 1.9.1
  • Last Appium version that did not exhibit the issue (if applicable): 1.8.1
  • Desktop OS/version used to run Appium: xcode 9.4.1, mac os version: 10.13.6
  • Node.js version (unless using Appium.app|exe):v7.1.0
  • Mobile platform/version under test: ios 9.4/9.2
  • Real device or emulator/simulator: simulator
  • java client verion: 6.1.0 and 5.0.4 both has this issue.

Activity

  1. helenren commented on Oct 25, 2018

    @helenren
    Author

    @jlipps do you aware any issue related to? thanks

  2. saikrishna321 commented on Oct 25, 2018

    @saikrishna321
    Member

    name was deprecated in favor of accessiblity id

  3. helenren commented on Oct 25, 2018

    @helenren
    Author

    so, for ios, we should use by.accessibilityid or by.id? where we can find the info on change for search property support ? @saikrishna321

  4. saikrishna321 commented on Oct 25, 2018

    @saikrishna321
    Member

    @helenren this was very old change which went through, may be in version 5.0.0 BETAX not sure though.. But for sure this change was done long back.

  5. helenren commented on Oct 25, 2018

    @helenren
    Author

    Hmm, the change that you mentioned is for page object tools. While in my test, I use By.Name directly instead of @findby annotation. I am kind lost. @saikrishna321

  6. saikrishna321 commented on Oct 25, 2018

    @saikrishna321
    Member
  7. helenren commented on Oct 26, 2018

    @helenren
    Author

    Did more try. Instead of using by.name, switch to use the xpath to find an element on a native page. Compared with java_client 6.1.0 + appium 1.8.1 and java_client 6.1.0 + appium 1.9.1, the test app, ios version are same. Successfully fin the element for java_client 6.1.0 + appium 1.8.1 , while fail to find it for java_client 6.1.0 + appium 1.9.1. One thing cannot understand is, for java_client 6.1.0 + appium 1.9.1, after finding the element, call element/sync instead of element/displayed? @saikrishna321

    Here is detail logs:
    using By.xpath("//XCUIElementTypeButton”) to find an element on a native page.

    With java_client 6.1.0 + appium 1.9.1, fail to find it. Here is the appium logs:

    2018-10-26 00:07:49:765 - [HTTP] --> GET /wd/hub/session/3ee94005-3eee-44f8-93cd-e66d78f6cf90/context
    2018-10-26 00:07:49:765 - [HTTP] {}
    2018-10-26 00:07:49:767 - [debug] [W3C] Calling AppiumDriver.getCurrentContext() with args: ["3ee94005-3eee-44f8-93cd-e66d78f6cf90"]
    2018-10-26 00:07:49:770 - [debug] [XCUITest] Executing command 'getCurrentContext'
    2018-10-26 00:07:49:775 - [debug] [W3C] Responding to client with driver.getCurrentContext() result: "NATIVE_APP"
    2018-10-26 00:07:49:775 - [HTTP] <-- GET /wd/hub/session/3ee94005-3eee-44f8-93cd-e66d78f6cf90/context 200 10 ms - 22
    2018-10-26 00:07:49:776 - [HTTP]
    2018-10-26 00:07:49:781 - [HTTP] --> POST /wd/hub/session/3ee94005-3eee-44f8-93cd-e66d78f6cf90/elements
    2018-10-26 00:07:49:781 - [HTTP] {"value":"//XCUIElementTypeButton","using":"xpath"}
    2018-10-26 00:07:49:781 - [debug] [W3C] Calling AppiumDriver.findElements() with args: ["xpath","//XCUIElementTypeButton","3ee94005-3eee-44f8-93cd-e66d78f6cf90"]
    2018-10-26 00:07:49:782 - [debug] [XCUITest] Executing command 'findElements'
    2018-10-26 00:07:49:783 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
    2018-10-26 00:07:49:785 - [debug] [BaseDriver] Waiting up to 5000 ms for condition
    2018-10-26 00:07:49:786 - [debug] [JSONWP Proxy] Matched '/elements' to command name 'findElements'
    2018-10-26 00:07:49:786 - [debug] [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8100/session/74253321-22DD-4A1E-AE54-5578A7C49E28/elements] with body: {"using":"xpath","value":"//XCUIElementTypeButton"}
    2018-10-26 00:07:53:234 - [debug] [JSONWP Proxy] Got response with status 200: {"value":[{"ELEMENT":"23000000-0000-0000-D32E-000000000000"}],"sessionId":"74253321-22DD-4A1E-AE54-5578A7C49E28","status":0}
    2018-10-26 00:07:53:235 - [debug] [W3C] Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"23000000-0000-0000-D32E-000000000000"}]
    2018-10-26 00:07:53:236 - [HTTP] <-- POST /wd/hub/session/3ee94005-3eee-44f8-93cd-e66d78f6cf90/elements 200 3455 ms - 90
    2018-10-26 00:07:53:236 - [HTTP]
    2018-10-26 00:07:53:254 - [HTTP] --> POST /wd/hub/session/3ee94005-3eee-44f8-93cd-e66d78f6cf90/execute/sync
    2018-10-26 00:07:53:255 - [HTTP] {"script":"return (function(){return function(){var k=this;function l(a){return void 0!==a}function m(a){return"string"==typeof a}function aa(a,b){a=a.split(".");var c=k;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&l(b)?c[d]=b:c[d]&&c[d]!==Object.prototype[d]?c=c[d]:c=c[d]={}}\nfunction ba(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";\nelse if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ca(
    2018-10-26 00:07:53:256 - [debug] [W3C] Calling AppiumDriver.execute() with args: ["return (function(){return function(){var k=this;function l(a){return void 0!==a}function m(a){return"string"==typeof a}function aa(a,b){a=a.split(".");var c=k;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&l(b)?c[d]=b:c[d]&&c[d]!==Object.prototype[d]?c=c[d]:c=c[d]={}}\nfunction ba(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";\nelse if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ca(a,b,c){return a.call.apply(a.b...
    2018-10-26 00:07:53:257 - [debug] [XCUITest] Executing command 'execute'
    2018-10-26 00:07:53:262 - [debug] [W3C] Encountered internal error running command: NotImplementedError: Method is not implemented

    While for java_client 6.1.0 + appium 1.8.1, successfully find the element:

    2018-10-26 00:13:47:460 - [HTTP] --> GET /wd/hub/session/ae8b670d-e4d4-4652-8982-e8ead579b404/context
    2018-10-26 00:13:47:460 - [HTTP] {}
    2018-10-26 00:13:47:462 - [debug] [W3C] Calling AppiumDriver.getCurrentContext() with args: ["ae8b670d-e4d4-4652-8982-e8ead579b404"]
    2018-10-26 00:13:47:462 - [debug] [XCUITest] Executing command 'getCurrentContext'
    2018-10-26 00:13:47:464 - [debug] [MJSONWP] Responding to client with driver.getCurrentContext() result: "NATIVE_APP"
    2018-10-26 00:13:47:465 - [HTTP] <-- GET /wd/hub/session/ae8b670d-e4d4-4652-8982-e8ead579b404/context 200 5 ms - 84
    2018-10-26 00:13:47:465 - [HTTP]
    2018-10-26 00:13:47:470 - [HTTP] --> POST /wd/hub/session/ae8b670d-e4d4-4652-8982-e8ead579b404/elements
    2018-10-26 00:13:47:470 - [HTTP] {"using":"xpath","value":"//XCUIElementTypeButton"}
    2018-10-26 00:13:47:471 - [debug] [W3C] Calling AppiumDriver.findElements() with args: ["xpath","//XCUIElementTypeButton","ae8b670d-e4d4-4652-8982-e8ead579b404"]
    2018-10-26 00:13:47:471 - [debug] [XCUITest] Executing command 'findElements'
    2018-10-26 00:13:47:472 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
    2018-10-26 00:13:47:474 - [debug] [BaseDriver] Waiting up to 0 ms for condition
    2018-10-26 00:13:47:475 - [debug] [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8100/session/B1F83BAC-99A8-4A71-B0D8-0A237EF859A8/elements] with body: {"using":"xpath","value":"//XCUIElementTypeButton"}
    2018-10-26 00:13:51:056 - [debug] [JSONWP Proxy] Got response with status 200: {"value":[{"ELEMENT":"23000000-0000-0000-C431-000000000000"}],"sessionId":"B1F83BAC-99A8-4A71-B0D8-0A237EF859A8","status":0}
    2018-10-26 00:13:51:057 - [debug] [MJSONWP] Responding to client with driver.findElements() result: [{"ELEMENT":"23000000-0000-0000-C431-000000000000"}]
    2018-10-26 00:13:51:057 - [HTTP] <-- POST /wd/hub/session/ae8b670d-e4d4-4652-8982-e8ead579b404/elements 200 3587 ms - 124
    2018-10-26 00:13:51:057 - [HTTP]
    2018-10-26 00:13:51:069 - [HTTP] --> GET /wd/hub/session/ae8b670d-e4d4-4652-8982-e8ead579b404/element/23000000-0000-0000-C431-000000000000/displayed

  8. ndeztea commented on Nov 26, 2018

    @ndeztea

    I have the similiar issue on this like this : NotImplementedError: Method is not implemented

    anyone have the simliar issue as well ?

  9. helenren commented on Nov 26, 2018

    @helenren
    Author

    after configure via using capability: MobileCapabilityType.FORCE_MJSONWP to true to still use OSS instead of the default W3C, this issue has been gone for me. @ndeztea

  10. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    Screen Shot 2020-06-04 at 1 33 32 PM
    What could be wrong?

  11. mykola-mokhnach commented on Jun 4, 2020

    @mykola-mokhnach
    Contributor

    @michaeljohndamo1 The xpath locator is invalid. It only supports double quotes as string separators.

  12. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    Hi @mykola-mokhnach sorry, i am still newbie please be patient on me. Can you please explain more? coz i really don't understand. I am still learning, btw this runs on browser but when i have changed the setup to mobile chrome. I am facing this error. I've been searching and trying all the stuff that i've searched on the internet but still no luck.

  13. mykola-mokhnach commented on Jun 4, 2020

    @mykola-mokhnach
    Contributor

    Can you please explain more? coz i really don't understand

    What exactly is not understandable?

  14. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    @mykola-mokhnach sorry i cannot understand why i am facing this error. The answer that it only supports double quotes as string separators. I've tried to comment out the xpath / button if it will still continue to send keys. But i still face the error even without the xpath

  15. shibupanda commented on Jun 4, 2020

    @shibupanda

    Hi @michaeljohndamo1 could you please go with xpath instead of id. Let's have a try.
    something like //*[@id='_username'].

  16. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    Hi @michaeljohndamo1 could you please go with xpath instead of id. Let's have a try.
    something like //*[@id='_username'].

    Okay sir will try now, thank you :)

  17. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    Screen Shot 2020-06-04 at 6 05 43 PM

    hi sir, the error has been changed. But it still cant find the xpath

  18. shibupanda commented on Jun 4, 2020

    @shibupanda

    @michaeljohndamo1 I can see the id is "username" but in code you have written "_username" please change it.

  19. michaeljohndamo1 commented on Jun 4, 2020

    @michaeljohndamo1

    @shibupanda oh sir it works! thank you so much. This is my first time participating here in github i am really desperate and thanks to you, you have solved my problem. Sir may i know why id doesn't work earlier? and have to change to xpath? is it good to ask following question here?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions