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

Error : org.w3c.dom.DOMException: android.support.v7.app.ActionBar.ˋ #11854

Closed
hiteshsh opened this Issue Dec 17, 2018 · 26 comments

Comments

Projects
None yet
3 participants
@hiteshsh
Copy link

hiteshsh commented Dec 17, 2018

The problem

I'm getting the error when I'm trying to find the below element by XPath.
@AndroidFindBy(xpath = "//android.widget.TextView[@text='MORE']")
public MobileElement moreTile;

public void test(){
wait.until(ExpectedConditions.visibilityOf(moreTile)).click();
}

I tried to print the page source and I think it can be because of the ` character.
Page source :
https://gist.github.com/hiteshsh/47183baf2f9d718c9fb35c401b2b5e0f

Environment

  • Appium version (or git revision) that exhibits the issue: v1.10.0
  • Last Appium version that did not exhibit the issue (if applicable):
  • Desktop OS/version used to run Appium: mac
  • Node.js version (unless using Appium.app|exe): v11.4.0
  • Mobile platform/version under test: Android API(28)
  • Real device or emulator/simulator: Simulator
  • Appium CLI or Appium.app|exe: Appium CLI and java client : f10393a

Link to Appium logs

https://gist.github.com/hiteshsh/9d84b2917a2ca2a015029870f81c9cbb

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 17, 2018

Please try appium@beta

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 17, 2018

tried with Appium v1.11.0-beta.2. The problem still persists.
Below are the Appium logs:
https://gist.github.com/hiteshsh/c51951a18ec0a7e60e21d8df7cee9d4e

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 17, 2018

Can you please attach the page source?

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 17, 2018

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 17, 2018

This is a bug in the standard android xpath engine implementation. I'll try to replace it with an alternative one

@mykola-mokhnach mykola-mokhnach added the Bug label Dec 17, 2018

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 17, 2018

@hiteshsh Can you please check if appium/appium-uiautomator2-server#236 works for you? Here you can read on how to build custom server apk

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 18, 2018

@mykola-mokhnach
After building and using the custom server apk, I'm still getting the error:
https://gist.github.com/hiteshsh/8e37115aa64e52dca77f78aad4a8f636

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 18, 2018

Thanks for trying. These Apache libs are driving me crazy. Let me try another one

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 18, 2018

@hiteshsh Please try if appium/appium-uiautomator2-server#237 works for you

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 18, 2018

@mykola-mokhnach Tried the above one as well. Unfortunately, it is also throwing 'org.jdom2.input.JDOMParseException' exception. Logs attached here
https://gist.github.com/hiteshsh/49bee91cc1b19163418d1d457a680c75

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 18, 2018

It should work with the recent commit.

I don't really like to perform class name replacements, but it looks like Android only supports xpath search based on Apache harmony DOM implementation, which is buggy and does not work properly with Unicode characters allowed by XMLv1 standard. Unfortunately, I don't see any other open-source Apache/BSD-license based alternatives to it.

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

@hiteshsh Have you had a chance to try the recent fix? I've also added the normalizeTagNames setting, which normalizes class names in the produced xml if no other workarounds help.

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

@mykola-mokhnach Sorry didn't look into it again as I thought there won't be any further change done on it. Anyway, I'm trying it again but I'm still getting the same error. As per your comment on the [(https://github.com/appium/appium-uiautomator2-server/pull/237)] the normalizeTagNames will be disabled by default. To enable it do I need to add it in DesiredCapabilities ?

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

I'm trying it again but I'm still getting the same error.

Are you sure you use the most recent version of the source? Can you please show the stack trace?

To enable it do I need to add it in DesiredCapabilities

No this can be enabled/disabled in runtime via appium settings interface (driver.setSetting)

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

I have performed the below steps.

  1. took the latest pull from mykola-mokhnach:jdom branch
  2. Executed command gradle clean assembleServerDebug to build the apk.
  3. Then replaced the apk in node_module->UIautomator2 folder with the one I build.

I didn't use driver.setSetting yet. But won't that require a change in java-client(Setting) as well?

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

I didn't use driver.setSetting yet. But won't that require a change in java-client(Setting) as well?

No it should not require any changes on the client side:

        CommandExecutionHelper.execute(driver, new AbstractMap.SimpleEntry<>("setSettings", prepareArguments("settings", MobileCommand.prepareArguments(settingName, settingValue))));

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

@mykola-mokhnach Yes, it worked now. I didn't get any error and it was able to find the element. Thanks for solving it.

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

It worked WITH this setting enabled or without?

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

It worked with setting enabled only.
CommandExecutionHelper.execute(driver, new AbstractMap.SimpleEntry<>("setSettings", prepareArguments("settings", prepareArguments("normalizeTagNames", true))));

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

Can you please also attach the source tree generated if this setting is on and when it is off?

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

I'm sorry I didn't understand what you meant by source tree generated?

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

I mean the output of getPageSource

@hiteshsh

This comment has been minimized.

Copy link
Author

hiteshsh commented Dec 19, 2018

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

Thank you for the assistance. The fix will be merged and published soon. After that I'll add the new setting to java client

@mykola-mokhnach

This comment has been minimized.

Copy link
Collaborator

mykola-mokhnach commented Dec 19, 2018

The change has been published in appium@beta

@syddel

This comment has been minimized.

Copy link

syddel commented Jan 4, 2019

Is it possible to set normalizeTagNames to true when starting Appium from the terminal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.