# Unable to Scroll Up on Android. Unable to use scroll to text either

**URL:** <https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535>\
**Category:** Mobile Testing\
**Tags:** mobile-testing, katalon-studio\
**Created:** [February 26, 2018, 10:42pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535 "2018-02-26T22:42:02Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Flynn](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Patrick\_Flynn](https://forum.katalon.com/u/Patrick_Flynn)\
**Post date:** [February 26, 2018, 10:42pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/1 "2018-02-26T22:42:02Z")

</div>

Hi All,

1. I am unable to use the scroll to text function. When executed the function merely scrolls down about 100 pixels and stops. It does not scroll to the specified text.

2. I am therefore using the Swipe function to scroll down and using the following coordinates:

StartX: 1000  
StartY: 0  
EndX: 100  
EndY: 100

Using the inverse of this does not work to scroll up e.g.

StartX: 1000  
StartY: 100  
EndX: 100  
EndY: 0

Can you help me use the scroll to text function or explain what I am doing wrong with the swipe function.

Kid regards,

Patrick

Katalon 5.3.0  
Windows 10  
Testing on Android emulator BlueStacks

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [May 31, 2018, 10:23pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/2 "2018-05-31T22:23:39Z")

</div>

I found that Mobile.scrollToText(‘My Label’) didn’t work well on Android when the drop down list was longer than one screen. It would scroll a bit, then stop, never finding my required item.

To get around this, I had to extend Katalon by creating a Custom Keyword to handle scrolling - this relies on the AppiumDriver library (thanks to [Nhi Dinh](http://forum.katalon.com/profile/1694/Nhi%20Dinh) for the sample code):

Create a new keyword file:

```auto
package com.my.keywords.android

import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver

class swiping {	
	AppiumDriver driver;	
	
	swiping() {		
		this.driver = MobileDriverFactory.getDriver()	
	}	
	
	private scrollEntireList() { // very specific to android and the type of element that makes up your dropdowns		
		ArrayList listElement = driver.findElementsByClassName("android.widget.TextView")		
		TouchAction touchAction = new TouchAction(driver)		
		def bottomElement = listElement[listElement.size() - 1]		
		def topElement = listElement[0] // Press and scroll from the last element in the list all the way to the top		
		touchAction.press(bottomElement).moveTo(topElement).release().perform();	
	}	

@Keyword	
def boolean scrollListToElementWithText(String elementText) 
{		
	boolean isElementFound = false;		
	while (isElementFound == false) { // very specific to android and the type of element that makes up your dropdowns					
	
		ArrayList listElement = driver.findElementsByClassName("android.widget.TextView")			
		for (int i = 0; i<listElement.size(); i++) {				
			String textItem = listElement[i].getText()				
			if (textItem == elementText) {					
				isElementFound = true;					
				return true;				
				}			
		}			
		
		scrollEntireList()		
	}	
}}

```

Then in your test, you can use the Custom Keyword like:

```auto
CustomKeywords.'com.my.keywords.android.swiping.scrollListToElementWithText'('My Label')

```

---

<div class="post-metadata">

**Author:** ![Joko\_T\_Susilo\_Widodo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/joko_t_susilo_widodo/32/20464_2.png) [@Joko\_T\_Susilo\_Widodo](https://forum.katalon.com/u/Joko_T_Susilo_Widodo)\
**Post date:** [December 25, 2018, 1:51pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/3 "2018-12-25T13:51:23Z")

</div>

Hi chris, i’ve try that and i got this :

ERROR] - Negative array index [-1] too large for array size 0

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [January 2, 2019, 7:05pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/4 "2019-01-02T19:05:04Z")

</div>

Hi Joko,

It’s likely then that the element classes in your list aren’t of type `android.widget.CheckedTextView` as in the example code above. The index error is indicating that there are no elements found in the `listElement` array, so something on the screen doesn’t match the code.

They could possibly be `android.widget.TextView`. Can you try changing the code you pulled from above to use `android.widget.TextView` instead (make sure you change both places in the code from above)?

Alternatively, I used the code sample above as a basis for an open source library that helps with several complicated tasks in Katalon Studio tests. For example, here is a section that should make scrolling easier:

> **[GitHub - detroit-labs/katalon-mobile-util: Library of utilities to make...](https://github.com/detroit-labs/katalon-mobile-util#scrolling)**
>
> Library of utilities to make mobile UI testing in Katalon Studio easier - GitHub - detroit-labs/katalon-mobile-util: Library of utilities to make mobile UI testing in Katalon Studio easier

If you’re interested in using this library, here’s some Katalon documentation on using third party libraries:

[https://docs.katalon.com/katalon-studio/tutorials/import\_java\_library.html](https://docs.katalon.com/katalon-studio/tutorials/import_java_library.html)

You can get the library jar file at:

[https://github.com/detroit-labs/katalon-mobile-util/releases/download/1.9.0/katalon-mobile-util-1.9.0.jar](https://github.com/detroit-labs/katalon-mobile-util/releases/download/1.9.0/katalon-mobile-util-1.9.0.jar)

Hope this helps,

Chris

---

<div class="post-metadata">

**Author:** ![yudies1](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yudies1](https://forum.katalon.com/u/yudies1)\
**Post date:** [January 11, 2019, 10:04pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/5 "2019-01-11T22:04:40Z")

</div>

Hi @Chris_Trevarthen,  
I have tried using katalon-mobile-util library and I got this error:  
Test Cases/Tc\_Scroll2Bottom FAILED.  
Reason:  
com.detroitlabs.katalonmobileutil.exception.ListItemsNotFoundException:  
Could not find any list elements matching xpath: //\*[contains(@class, ‘TextView’)]  
and that exactly one label has the text: ‘Album’  
at com.detroitlabs.katalonmobileutil.touch.Scroll.scrollEntireList(Scroll.java:164)  
at com.detroitlabs.katalonmobileutil.touch.Scroll.scrollListToElementWithXPath(Scroll.java:120)  
at com.detroitlabs.katalonmobileutil.touch.Scroll.scrollListToElementWithText(Scroll.java:73)  
at com.detroitlabs.katalonmobileutil.touch.Scroll.scrollListToElementWithText(Scroll.java:41)  
at com.detroitlabs.katalonmobileutil.touch.Scroll$scrollListToElementWithText.call(Unknown Source)  
at Tc\_Scroll2Bottom.run(Tc\_Scroll2Bottom:38)  
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)  
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)  
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)  
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)  
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)  
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)  
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)  
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)  
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
at TempTestCase1547242602394.run(TempTestCase1547242602394.groovy:22)

Any ideas?  
Thanks

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [January 14, 2019, 1:21am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/6 "2019-01-14T01:21:02Z")

</div>

Hi Yudi,

From the error, it looks like the library couldn’t find a `TextView` element with the `text` ‘Album’. This could be for a couple of reasons:

1. The elements you’re trying to scroll through haven’t appeared on the screen yet
2. The element types you’re trying to scroll don’t contain the class `TextView`
3. There are other elements on the screen, like buttons, that are also detected as `TextView`, but they aren’t part of the scrolling list. If they’re static elements, like buttons, then the scroll action doesn’t work on them and the scrolling has no effect.

In any of these cases, some more info would be helpful for troubleshooting:

- Can you provide a screenshot of the screen you’re trying to test with the scrolling? A picture of what the Katalon Mobile Spy shows would be helpful, so that I can see how the elements are detected.
- Secondly, the `katalon-mobile-util` library has some built-in logging that can give a litle more info about how it’s working.

To do that, at the top of your test, import some of the `Logging` classes:

```auto
import com.detroitlabs.katalonmobileutil.logging.Logger
import com.detroitlabs.katalonmobileutil.logging.Logger.LogLevel

Logger.initialize('/tmp/mytest.log', LogLevel.DEBUG)

```

Now, if you open the file `/tmp/mytest.log`, you’ll see a running log of what `katalon-mobile-util` is doing, including the elements that it sees on the screen when doing scrolling. NOTE: You can change the log location to somewhere else that’s more convenient for you just by changing the first argument to `Logger.initialize`.

If you can provide the log and images from above, I think it will give me a better idea of why the scrolling isn’t working.

Thanks,

Chris

---

<div class="post-metadata">

**Author:** ![yudies1](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yudies1](https://forum.katalon.com/u/yudies1)\
**Post date:** [January 14, 2019, 3:40am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/7 "2019-01-14T03:40:14Z")

</div>

Hi @Chris_Trevarthen,  
Thanks for your reply.  
Please find the screenshots attached.

 ![Scroll1](https://europe1.discourse-cdn.com/katalon/original/2X/8/8889afe2be4f400adb73d7ad1426dd5453b8fb46.jpeg) ![Scroll2](https://europe1.discourse-cdn.com/katalon/original/2X/e/e8840ab8d8511f56417b377b09f420f9c793616b.jpeg) ![Scroll3](https://europe1.discourse-cdn.com/katalon/original/2X/2/207baa820e7da79b13b80cc14517ebd4eab55fd0.jpeg)

> [@Chris\_Trevarthen](#):
>
> Secondly, the `katalon-mobile-util` library has some built-in logging that can give a litle more info about how it’s working.

Here are my scripts:  
Logger.initialize(‘/tmp/katalon.log’, LogLevel.DEBUG)  
CustomKeywords.‘utils.Swiping.scrollListToElementWithText’(‘Album’)

I got an error as follows:

> Blockquote  
> java.io.FileNotFoundException: \tmp\katalon.log (The system cannot find the path specified)  
> at com.detroitlabs.katalonmobileutil.logging.Logger.initialize(Logger.java:28)  
> at com.detroitlabs.katalonmobileutil.logging.Logger$initialize.call(Unknown Source)  
> at Verify that user can scroll to bottom of the screen.run(Verify that user can scroll to bottom of the screen:31)  
> at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)  
> at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)  
> at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)  
> at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)  
> at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)  
> at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)  
> at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)  
> at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)  
> at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)  
> at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)  
> at TempTestCase1547435641312.run(TempTestCase1547435641312.groovy:22)

How can I get the log path for ‘/tmp/katalon.log’ ?

Thanks,  
Yudi

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [January 14, 2019, 3:53am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/8 "2019-01-14T03:53:24Z")

</div>

Hi Yudi,

Sorry, I assumed you were on a Mac. If you’re on Windows, you should be able to set the path for the log to something like: `Logger.initialize('c:\mytest.log', LogLevel.DEBUG)`. Let me know if that works any better.

– Chris

---

<div class="post-metadata">

**Author:** ![yudies1](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yudies1](https://forum.katalon.com/u/yudies1)\
**Post date:** [January 14, 2019, 4:39am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/9 "2019-01-14T04:39:53Z")

</div>

Hi @Chris_Trevarthen,  
Thanks for prompt reply.  
Please find the log file attached.  
[mytest.log](https://europe1.discourse-cdn.com/katalon/original/2X/9/92441f7053978e52ebaacc65f3da19f2b0768666.log) (3.4 KB)

Cheers,  
Yudi

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [January 15, 2019, 3:05pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/10 "2019-01-15T15:05:53Z")

</div>

Hi Yudi,

Thanks for providing the log file and screenshots - they are very helpful. I think the issue is that the `Scroll.scrollListToElementWithText` function is made to scroll a list of similar elements, like a bunch of elements in a drop-down list. In your case, it looks like you want to scroll the entire screen until you find a certain element.

The `katalon-mobile-util` library doesn’t have anything for that (yet), but there should be ways to do it using the regular Katalon functions:

Documentation on the `Mobile.swipe` function:  
[https://docs.katalon.com/katalon-studio/docs/mobile-swipe.html#description](https://docs.katalon.com/katalon-studio/docs/mobile-swipe.html#description)

A forum post on how to get swiping to work:

> [@\*\*\*URGENT - Mobile.swipe does not execute (screen stays static) but passes in log \[Updated\]](http://forum.katalon.com/t/urgent-mobile-swipe-does-not-execute-screen-stays-static-but-passes-in-log-updated/11345/10):
>
> Hi there! This solution helped me to solve issue with vertical scroll. Maybe, it will be helpful for somebody import io.appium.java\_client.TouchAction import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory as MobileDriverFactory import io.appium.java\_client.AppiumDriver as AppiumDriver AppiumDriver\<?\> driver = MobileDriverFactory.getDriver() while ( Mobile.waitForElementPresent(categoryText, 2, FailureHandling.STOP\_ON\_FAILURE) == false){ //Mobile.swipe(300, 1430, 300, 1200) //…

Hope this helps,

Chris

---

<div class="post-metadata">

**Author:** ![yudies1](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yudies1](https://forum.katalon.com/u/yudies1)\
**Post date:** [January 15, 2019, 11:23pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/11 "2019-01-15T23:23:44Z")

</div>

Hi @Chris_Trevarthen,

Thank you so much for your help.  
I will try it today.

Cheers,  
Yudi

---

<div class="post-metadata">

**Author:** ![spulipati01](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@spulipati01](https://forum.katalon.com/u/spulipati01)\
**Post date:** [June 18, 2020, 12:02pm UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/12 "2020-06-18T12:02:06Z")

</div>

> [@Chris\_Trevarthen](#):
>
> rs on the mobile device. Parameters ParamParam TypeMandatoryDescriptionNotestartXintRequiredStarting x position startYintRequiredStarting y position endXintRequiredEnding x positionSince 5.1.0.2:Relative x…
> 
> A forum post on how to get swiping to work:

Hi @Chris_Trevarthen,

I tried all the options provided still I am not able to scroll up in andriod to a particular element. Could you please help resolve the issue.

Thanks,  
Shweta

---

<div class="post-metadata">

**Author:** ![Chris\_Trevarthen](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/chris_trevarthen/32/358_2.png) [@Chris\_Trevarthen](https://forum.katalon.com/u/Chris_Trevarthen)\
**Post date:** [June 25, 2020, 3:13am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/13 "2020-06-25T03:13:58Z")

</div>

Hi @spulipati01,

I have an open source library to help with common, but complicated, things like scrolling. You can check out the documentation on scrolling in particular, here:

> **[detroit-labs/katalon-mobile-util](https://github.com/detroit-labs/katalon-mobile-util#scrolling)**
>
> Library of utilities to make mobile UI testing in Katalon Studio easier - detroit-labs/katalon-mobile-util

For instructions on how to install it, see here: [https://github.com/detroit-labs/katalon-mobile-util#installation](https://github.com/detroit-labs/katalon-mobile-util#installation)

If you’re still having problems, can you please share a screenshot of the screen you’re trying to scroll and the properties (taken from Mobile Spy) of the object you’re trying to scroll to.

Thanks,

Chris

---

<div class="post-metadata">

**Author:** ![innayaimran786](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/innayaimran786/32/16104_2.png) [@innayaimran786](https://forum.katalon.com/u/innayaimran786)\
**Post date:** [October 22, 2021, 11:21am UTC](https://forum.katalon.com/t/unable-to-scroll-up-on-android-unable-to-use-scroll-to-text-either/9535/14 "2021-10-22T11:21:50Z")

</div>

Hi, @Chris_Trevarthen, I tried your solution but got this error. Please help.

 ![scroll](https://europe1.discourse-cdn.com/katalon/original/3X/c/9/c9ecc8b738103e4107c038bccb24c84ad4f19de1.jpeg)
