Any updates on this issue? anyone know if it's resolved? On Wednesday, December 4, 2013 at 5:23:47 PM UTC-5, Aaron wrote: > > I believe I've found the bug. > > If you look at > https://android.googlesource.com/platform/frameworks/testing/+/jb-mr0-release%5E1/uiautomator/library/src/com/android/uiautomator/core/UiScrollable.java > > you'll get this public boolean scrollIntoView(UiSelector selector) method. > > That method calls has the code: > > if(!scrollForward()) { > return false; > } > > And if you put debugging statements into that, you'll see it fails to scroll > forwards the first time. Simply changing the if statement to the below works. > > if(!scrollForward() && x!=0) { > > Obviously this is rather a nasty hack, and I'm unsure why it's needed. > > > In more detail, I have these print statements in my overridden methods. > Note I'm simply commenting out the return statement in the if statement > above to show it failing. > > @Override > public boolean scrollIntoView(UiSelector selector) throws > UiObjectNotFoundException { > // if we happen to be on top of the text we want then return here > System.out.println("My max search swipes are: "); > System.out.println(getMaxSearchSwipes()); > if (exists(getSelector().childSelector(selector))) { > return (true); > } else { > System.out.println("It doesn't exist on this page"); > // we will need to reset the search from the beginning to > start search > scrollToBeginning(getMaxSearchSwipes()); > System.out.println("I appear to have swiped to the > beginning."); > if (exists(getSelector().childSelector(selector))) { > return (true); > } > for (int x = 0; x < getMaxSearchSwipes(); x++) { > System.out.println("I'm going forward a page: " + x); > if(!scrollForward()) { > System.out.println("Couldn't scroll forwards?"); > //return false; > } > > if(exists(getSelector().childSelector(selector))) { > return true; > } > } > } > return false; > } > > @Override > public boolean scrollForward(int steps) throws > UiObjectNotFoundException { > System.out.println("I'm scrolling forwards by these steps: " + > steps); > return super.scrollForward(steps); > } > > And if I start search for an app (that doesn't exist) in the Apps method I > get this output. Notice the Couldn't scroll forwards? at the end are > normal, since I'm trying to scroll to a page that doesn't exist. However, > the first 'Couldn't scroll forwards?' is incorrect -- it's on the first > page and therefore should be able to scroll forwards. (in fact, from > observations it does indeed seem to be scrolling the page) > > My max search swipes are: > 20 > It doesn't exist on this page > I appear to have swiped to the beginning. > I'm going forward a page: 0 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 1 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 2 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 3 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 4 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 5 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 6 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 7 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 8 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 9 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 10 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 11 > I'm scrolling forwards by these steps: 55 > I'm going forward a page: 12 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 13 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 14 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 15 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 16 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 17 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 18 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > I'm going forward a page: 19 > I'm scrolling forwards by these steps: 55 > Couldn't scroll forwards? > > It appears the public boolean scrollForward(int steps) methods is > erroneously saying it can't scroll forwards on the first attempt, whereas I > believe it is doing from my observations. > > Here's the source to my example program: > > getUiDevice().pressHome(); > > UiObject allAppsButton = new UiObject(new > UiSelector().description("Apps")); > allAppsButton.clickAndWaitForNewWindow(); > > UiObject appsTab = new UiObject(new UiSelector().text("Apps")); > appsTab.click(); > > UiScrollable appsView = new UiScrollable(new > UiSelector().scrollable(true)); > appsView.setMaxSearchSwipes(20); > appsView.setAsHorizontalList(); > UiObject settingsApp = appsView.getChildByText( > new > UiSelector().className(android.widget.TextView.class.getName()), > "xxSettings", // Intentionally failing here for the above > demonstration. > true); > settingsApp.clickAndWaitForNewWindow(); > > > On Wednesday, 4 December 2013 21:22:37 UTC, Aaron wrote: >> >> I've tested this on api 19 on KitKat using a Nexus 4. >> >> It still doesn't scroll all the way through the Apps screen (swipes to >> the left once, then once to the right, and then fails), when searching for >> the Settings app, in the case of the example of Google's Android UI testing >> homepage. >> >> On Tuesday, 26 March 2013 01:20:11 UTC, Guang Zhu wrote: >>> >>> Hi Julian, >>> >>> Thanks for looking into this! We changed how end of scroll is detected >>> in API Level 17, and this caused breakage in some cases where such events >>> fail to be properly detected. We are addressing this issue in the next >>> major platform release. >>> >>> Thanks, >>> Guang Zhu >>> >>> On Tue, Mar 5, 2013 at 1:58 PM, Julian Harty <[email protected]> wrote: >>> >>>> OK, the evidence is pointing to a bug in Android 4.2.2 - once I updated >>>> my Galaxy Nexus from 4.2.1 to 4.2.2 the test broke. As a precaution I then >>>> rebuilt the jar file and redeployed it. I'm building with a target of >>>> android-17. >>>> >>>> >>>> On Tuesday, March 5, 2013 3:35:17 PM UTC, Julian Harty wrote: >>>>> >>>>> An update: I have a Galaxy Nexus running Android 4.2.1 and the demo >>>>> code works on this phone, albeit slowly. I'm about to apply the system >>>>> update to 4.2.2 to this device and will retest once I've done so. Just >>>>> waiting for the battery to charge sufficiently :) >>>>> >>>>> >>>>> On Tuesday, March 5, 2013 2:37:49 PM UTC, Julian Harty wrote: >>>>>> >>>>>> I have been experimenting with UI Automator using a Nexus 7 tablet >>>>>> and a Nexus 4 (LG) phone, (both running Android 4.2.2) together with the >>>>>> example code from http://developer.android.com/ >>>>>> tools/testing/testing_ui.html >>>>>> >>>>>> The example works on on my Nexus 7 tablet, however it fails to scroll >>>>>> to the "Settings" app on my Nexus 4. The main relevant difference >>>>>> between >>>>>> the devices seems to be the "Settings" are on the third page of Apps on >>>>>> my >>>>>> Nexus 4, and on the second page of Apps on my Nexus 7. >>>>>> >>>>>> On the Nexus 4, the call to getChildByText(...) scrolls the list of >>>>>> Apps once then stops. It fails to find the "Settings" - on my phone >>>>>> "Settings" is on the third page of Apps. I have experimented with using >>>>>> various methods, including appViews.scrollTextIntoView("Settings"); >>>>>> which behaves similarly. I managed to get the test to work with a slight >>>>>> hack, calling appViews.scrollForward(); twice. >>>>>> >>>>>> I've checked things like: appViews.getMaxSearchSwipes() which returns >>>>>> 30 - more than sufficient to allow the scrolling to work correctly e.g. >>>>>> using scrollTextIntoView(...). >>>>>> >>>>>> My temporary workaround is to use appViews.scrollForward(); several >>>>>> times to scroll until the "Settings" is visible, then the call to >>>>>> getChildByText(...) works OK. >>>>>> >>>>>> Note: I'm viewing the source for UiScrollable.java here >>>>>> https://android.googlesource.com/platform/frameworks/testing/+/ >>>>>> f612e6a05f47b28ae0f5715545658c08dd759dd7/uiautomator/ >>>>>> library/src/com/android/uiautomator/core/UiScrollable.java - this >>>>>> may not be the same version as used on my device, however it seems like >>>>>> the >>>>>> code *should* work for the example. >>>>>> >>>>>> Let me know if you'd like me to post my code here. I'm assuming >>>>>> there's little value in doing so since I took it from the android >>>>>> example. >>>>>> >>>>>> I'd appreciate someone testing the scenario where the Settings is on >>>>>> the 3rd page of results (or later) to see if the bug is reproducible. >>>>>> Also, >>>>>> if there's a reliable and relatively straight-forward way to build the >>>>>> UIAutomator library and deploy it to my devices I'd be happy to do some >>>>>> more testing of newer versions of the codebase, etc. >>>>>> >>>>>> Thanks >>>>>> >>>>>> Julian Harty >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "adt-dev" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Guang Zhu >>> Android Test Engineering >>> Google Inc. >>> >>> Please keep all discussions on related Google Groups, no direct emails. >>> Thanks! >>> >>
-- You received this message because you are subscribed to the Google Groups "adt-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
