Appium 1.1.0 getPageSource() generate incorrect XML.

363 views
Skip to first unread message

green...@gmail.com

unread,
Jun 3, 2014, 6:39:08 AM6/3/14
to appium-...@googlegroups.com
Hello. I have upgraded my Appium to 1.1.0 (Cygnus) version and i received set of issues with xpaths.
With previous version of Appium getPagesSource()  returns xml that corresponds to ui structure from UIAutomatorViewer or HierarchyViewer.
After upgrading getPageSource() method returns xml with structure, that is different (pared down xml source) than xml from getPageSource() in previous version of Appium.
Is it new feature of Appium or bug?
Thank you in advance.

Pooja Shah

unread,
Jun 3, 2014, 7:25:41 AM6/3/14
to appium-...@googlegroups.com
Even I found the same (from Appium 1.0.0 ) and I assumed this is the way it will be, so modifying my locators in test script
@Jillips: Please confirm on this.

Regards,
Pooja

green...@gmail.com

unread,
Jun 3, 2014, 6:27:11 PM6/3/14
to appium-...@googlegroups.com
I have big scope of locators, so before changing xpaths i should determine, that getPageSource() works correctly now.

вторник, 3 июня 2014 г., 14:25:41 UTC+3 пользователь Pooja Shah написал:

green...@gmail.com

unread,
Jun 4, 2014, 6:04:43 PM6/4/14
to appium-...@googlegroups.com
Hello Isaac, Jonathan.
Is any information about incorrect page source generating?
Thank you in advance.   
среда, 4 июня 2014 г., 1:27:11 UTC+3 пользователь green...@gmail.com написал:

bootstrap online

unread,
Jun 4, 2014, 6:05:56 PM6/4/14
to green...@gmail.com, appium-...@googlegroups.com
What is incorrect about the XML?
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/d/optout.

green...@gmail.com

unread,
Jun 4, 2014, 6:43:17 PM6/4/14
to appium-...@googlegroups.com, green...@gmail.com
This is two xml in attachments, that getPageSource() method returns:
Before Appium upgrading getPageSource() returned xml (before.xml), that corresponds to UI hierarchy from UIAutomator viewer.
After upgrading to 1.1.0 i recieve xml with another structure in the same activity/page (after.xml).
Is it correct behaviour of getPageSource()?
Thank you in advance.


четверг, 5 июня 2014 г., 1:05:56 UTC+3 пользователь bootstraponline написал:
before.xml
after.xml

bootstrap online

unread,
Jun 4, 2014, 6:45:10 PM6/4/14
to green...@gmail.com, appium-...@googlegroups.com

Yes

green...@gmail.com

unread,
Jun 4, 2014, 7:05:52 PM6/4/14
to appium-...@googlegroups.com, green...@gmail.com
Thank you for information.
But now i lose big part of hierarchy elements (tags) and their resource ids. Should i use another locator strategy for finding elements?
четверг, 5 июня 2014 г., 1:45:10 UTC+3 пользователь bootstraponline написал:

bootstrap online

unread,
Jun 4, 2014, 7:46:01 PM6/4/14
to green...@gmail.com, appium-...@googlegroups.com
The compression is only turned on for xpath searches so all other
locators should work the same as before. uiautomatorviewer can be used
to view the uncompressed xml.

green...@gmail.com

unread,
Jun 11, 2014, 3:29:39 AM6/11/14
to appium-...@googlegroups.com, green...@gmail.com
Hello, bootstraponline.
As i understood, compressXml using as default option for searching elements by xpath.
Also compressXml removes unnecessary elements from xml source. But in my case i have set of LinearLayout tags with unique ids, and i try to use LinearLayout as parent elements for buttons, fields, etc.
After compressing of xml source i lose LinearLayouts, which i need to use. Have you a workaround for my case? Maybe disabling of 'compressXml' in driver capabilities?
Thank you in advance.


четверг, 5 июня 2014 г., 2:46:01 UTC+3 пользователь bootstraponline написал:

bootstrap online

unread,
Jun 11, 2014, 9:11:32 AM6/11/14
to green...@gmail.com, appium-...@googlegroups.com
Have you verified with uiautomatorviewer that the compressed xml has
those elements and uncompressed doesn't? What locator strategy are you
using to find them?

If compression is disabled then xpath on Android returns random
elements. That doesn't seem like a desirable trade off.

green...@gmail.com

unread,
Jun 11, 2014, 10:15:36 AM6/11/14
to appium-...@googlegroups.com, green...@gmail.com
In uiautomatorviewer i have those elements in uncompressed xml (and also i don't have those elements in compressed xml).
I want to implement mechanism, that retrieve for me list of UI elements. Page contains scrollable list of ui elements (messages, contacts, etc). I describe those elements as ui components in my java code. Each of those components has various fields, buttons, labels.
For example:

<LinearLayout>
    <EditText>
    <ImageView>
    <TextView text="text1">
</LinearLayout>
<LinearLayout>
    <EditText>
    <ImageView>
    <TextView text="text2">
</LinearLayout>
         .
         .
         .
<LinearLayout>
    <EditText>
    <ImageView>
    <TextView text="text3">
</LinearLayout>

All of those elements differs only by TextView text value. So i can find parent element only by creating such xpath - //android.widget.TextView[@text='text_n']/.. (i use By.xpath locator strategy).
With such xpath i could create my ui component, and get other controls from it (button - //android.widget.TextView[@text='text_n']/../android.widget.ImageView, text field - //android.widget.TextView[@text='text_n']/../android.widget.EditText).
But in compressed xml i don't have all LinearLayouts from example above. So, i can't create ui component and interract with it. 
  

среда, 11 июня 2014 г., 16:11:32 UTC+3 пользователь bootstraponline написал:

bootstrap online

unread,
Jun 11, 2014, 10:27:56 AM6/11/14
to green...@gmail.com, appium-...@googlegroups.com
If compression is disabled for xml search on android, then it will
return random elements.
https://github.com/appium/appium/issues/2481
https://github.com/appium/appium/issues/2598

I think enabling a toggle between mostly broken XPath and totally
broken isn't the right answer. For this specific example, I recommend
trying to locate the element using findElementByAndroidUIAutomator
which works with UiSelectors.

http://developer.android.com/tools/help/uiautomator/UiSelector.html

Another option is to properly mark those views as important to
accessibility so Android doesn't discard them in compressed mode.

green...@gmail.com

unread,
Jun 12, 2014, 9:13:52 AM6/12/14
to appium-...@googlegroups.com, green...@gmail.com
Thank you for information.
I try to get child element:

webdriver().findElement( MobileBy.AndroidUIAutomator( "new UiSelector().classNameMatches(\"android.widget.LinearLayout\").childSelector(new UISelector().text(\"REST URL\"))" ) );

or parent element:

webdriver().findElement( MobileBy.AndroidUIAutomator( "new UiSelector().classNameMatches(\"android.widget.LinearLayout\").fromParent(new UISelector().className(\"android.widget.LinearLayout\"))" ) );

But in both cases i get an exception. Is it right way of using MobileBy.AndroidUIAutomator locator strategy?

среда, 11 июня 2014 г., 17:27:56 UTC+3 пользователь bootstraponline написал:

bootstrap online

unread,
Jun 12, 2014, 9:22:30 AM6/12/14
to green...@gmail.com, appium-...@googlegroups.com
What is the exception? I think that should work.

green...@gmail.com

unread,
Jun 12, 2014, 9:46:11 AM6/12/14
to appium-...@googlegroups.com, green...@gmail.com
For example, next code:

    webdriver().findElement( MobileBy.AndroidUIAutomator( "new UiSelector().text(\"REST URL\")" ) );
works fine.

But such code:


    webdriver().findElement( MobileBy.AndroidUIAutomator( "new UiSelector().classNameMatches(\"android.widget.LinearLayout\").childSelector(new UISelector().text(\"REST URL\"))" ) );
throws org.openqa.selenium.UnsupportedCommandException

Appium log:

debug: Appium request initiated at /wd/hub/session/fb5306f1-d25b-4366-93e5-0d678
7109a0e/element
debug: Request received with params: {"using":"-android uiautomator","value":"new UiSelector().classNameMatches(\"android.widget.LinearLayout\").childSelector(new UISelector().text(\"REST URL\"))"}
info: Pushing command to appium work queue: ["find",{"strategy":"-android uiautomator","selector":"new UiSelector().classNameMatches(\"android.widget.LinearLayout\").childSelector(new UISelector().text(\"REST URL\"))","context":"","multiple":false}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().classNameMatches(\"android.widget.LinearLayout\").childSelector(new UISelector().text(\"REST URL\"))","context":"","multiple":false}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] Finding new UiSelector().classNameMatches("android.widget.LinearLayout").childSelector(new UISelector().text("REST URL")) using ANDROID_UIAUTOMATOR with the contextId:
info: Responding to client with error: {"status":9,"value":{"message":"The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.","origValue":"Could not parse UiSelector argument: new UISelector method expects an argument"},"sessionId":"fb5306f1-d25b-4366-93e5-0d6787109a0e"}POST /wd/hub/session/fb5306f1-d25b-4366-93e5-0d6787109a0e/element 500 15ms - 342b
info: [BOOTSTRAP] [info] Returning result: {"value":"Could not parse UiSelector argument: new UISelector method expects an argument","status":9}




четверг, 12 июня 2014 г., 16:22:30 UTC+3 пользователь bootstraponline написал:

bootstrap online

unread,
Jun 12, 2014, 9:50:01 AM6/12/14
to green...@gmail.com, appium-...@googlegroups.com
That's a bug. Please open an issue on GitHub so it gets fixed.
https://github.com/appium/appium/issues

green...@gmail.com

unread,
Jun 12, 2014, 9:58:58 AM6/12/14
to appium-...@googlegroups.com, green...@gmail.com
Done,
https://github.com/appium/appium/issues/2839.
Thank you.

четверг, 12 июня 2014 г., 16:50:01 UTC+3 пользователь bootstraponline написал:
Reply all
Reply to author
Forward
0 new messages