Skip to content

fix: Fix Android scroll_to and scroll_to_exact#638

Merged
KazuCocoa merged 2 commits intoappium:masterfrom
emen:master
Aug 19, 2017
Merged

fix: Fix Android scroll_to and scroll_to_exact#638
KazuCocoa merged 2 commits intoappium:masterfrom
emen:master

Conversation

@emen
Copy link
Copy Markdown
Contributor

@emen emen commented Aug 16, 2017

I need to use this method for some of my tests.

Fixed Android scroll_to and scroll_to_exact methods and their tests rake android['android/element/generic.rb']

@jsf-clabot
Copy link
Copy Markdown

jsf-clabot commented Aug 16, 2017

CLA assistant check
All committers have signed the CLA.

@KazuCocoa
Copy link
Copy Markdown
Member

@emen
Thanks!

Could you explain me more?
For instance, current implementations don't work for uiautomator2 or ...

@emen
Copy link
Copy Markdown
Contributor Author

emen commented Aug 16, 2017

Hi @KazuCocoa,

I ran into a couple of issues with the current implementation.

  1. rake android['android/element/generic.rb'] fails with scroll_to and scroll_to_exact
  2. Use scroll_to_exact as an example, given an element text("Test") on the screen, scroll_to("Test") scrolls to the element first, and then tries to find and scroll to an element with description "Test", and then an element with resource id "".

I tested with Appium 1.6.5 and a couple of versions of Android.

Thanks!
Emen

Copy link
Copy Markdown
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

hm...
In my environment, tests were passed 7 runs, 11 assertions, 0 failures, 0 errors, 0 skips even if I use scroll_to('Views').click. I ran with Android 6.0.
Anyway, certainly we have resource_id(text, "new UiSelector().resourceId(#{text});" is "" case. 👍

scroll_uiselector(resource_id(text, "new UiSelector().resourceId(#{text});"), scrollable_index)

find_element :uiautomator, args
rid = resource_id(text, "new UiSelector().resourceId(#{text});")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following if you'd like to ignore resource_id(text, "new UiSelector().resourceId(#{text});") is "" case?

r_id = resource_id(text, "new UiSelector().resourceId(#{text});")
args = scroll_uiselector("new UiSelector().textContains(#{text})", scrollable_index) +
        scroll_uiselector("new UiSelector().descriptionContains(#{text})", scrollable_index)
args += scroll_uiselector(r_id, scrollable_index) unless r_id.empty?

find_element :uiautomator, args

scroll_uiselector(resource_id(text, "new UiSelector().resourceId(#{text});"), scrollable_index)

find_element :uiautomator, args
rid = resource_id(text, "new UiSelector().resourceId(#{text});")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also,

      r_id = resource_id(text, "new UiSelector().resourceId(#{text});")
      args = scroll_uiselector("new UiSelector().text(#{text})", scrollable_index) +
             scroll_uiselector("new UiSelector().description(#{text})", scrollable_index)
      args += scroll_uiselector(r_id, scrollable_index) unless r_id.empty?

@KazuCocoa
Copy link
Copy Markdown
Member

@emen
Thanks for your quick reply! I posted some comments.

@emen
Copy link
Copy Markdown
Contributor Author

emen commented Aug 16, 2017

Hi @KazuCocoa,

I figured it out. The tests fail with Android 5.0.0. and 5.1.0, pass with 6.0.0 and 7.0.0. With 5.0.0 and 5.1.1, Ruby needs to check if the scroll is successful and return the element. The change you suggested unfortunately will still fail on 5.0.0 and 5.1.0

Please try and let me know.

Thanks a lot!
Emen

@KazuCocoa
Copy link
Copy Markdown
Member

@emen
Hm... I tried with Android 5.0 and 5.1 on emulators, but they work fine.
Could you check the following lines in your environment as I've reviewed? And could you attach the results, Appium side and Ruby side, as Gist?

r_id = resource_id(text, "new UiSelector().resourceId(#{text});")
args = scroll_uiselector("new UiSelector().textContains(#{text})", scrollable_index) +
        scroll_uiselector("new UiSelector().descriptionContains(#{text})", scrollable_index)
args += scroll_uiselector(r_id, scrollable_index) unless r_id.empty?

find_element :uiautomator, args

I'd like to reduce the number of request to the server, and I'd like to call find_element once as possible.

@emen
Copy link
Copy Markdown
Contributor Author

emen commented Aug 18, 2017

Thank you @KazuCocoa!

You are right. With the above change, the unit test rake android['android/element/generic.rb']will pass. But that is because in the test app, the text and the description have the same content. It still failed with my app. Here is Appium log. The element have text 'Current Environment', but description is something different. Please let me know if you need more details

Thanks!
Emen

@KazuCocoa
Copy link
Copy Markdown
Member

thanks!

@KazuCocoa KazuCocoa merged commit b7daaac into appium:master Aug 19, 2017
@KazuCocoa KazuCocoa modified the milestone: v9.6.0 Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants