Unable to scroll down text using scrollToText

Hi!
I tried to scroll text down using scrollToText:

Mobile.verifyElementVisible(findTestObject(‘Object Repository/TermsAndConditionsPage/TRUE’), 0)

Mobile.tap(findTestObject(‘Object Repository/TermsAndConditionsPage/TRUE’), 0)

Mobile.scrollToText(‘Partner’)

Mobile.verifyElementVisible(findTestObject(‘Object Repository/TermsAndConditionsPage/CheckBox’), 0) //Failed

TRUE element is

//hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.ScrollView[1]

While running test - Console says, that scroll is “Passed”

but Android Studio emulator don’t scrolling (Tried Android 7.0 and 8.0 Nexus 6p and Pixel 2l)

3.1 Version of Katalon studio

still actual

Did u get the solution for your query? I am also facing the same issue.

Gaurav Mishra said:

Did u get the solution for your query? I am also facing the same issue.

No :frowning: I decided to learn Selenium + Appium + Java + Jenkins stack, works fine:)

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 for the sample code):

Create a new keyword file:

package com.my.keywords.androidimport com.kms.katalon.core.annotation.Keywordimport com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactoryimport io.appium.java_client.AppiumDriverimport io.appium.java_client.TouchActionclass 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.CheckedTextView")		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.CheckedTextView")			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:

CustomKeywords.'com.my.keywords.android.swiping.scrollListToElementWithText'('My Label')
1 Like

Qawka said:

Hi!
I tried to scroll text down using scrollToText:

Mobile.verifyElementVisible(findTestObject(‘Object Repository/TermsAndConditionsPage/TRUE’), 0)

Mobile.tap(findTestObject(‘Object Repository/TermsAndConditionsPage/TRUE’), 0)

Mobile.scrollToText(‘Partner’)

Mobile.verifyElementVisible(findTestObject(‘Object Repository/TermsAndConditionsPage/CheckBox’), 0) //Failed

TRUE element is

//hierarchy/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.ScrollView[1]

While running test - Console says, that scroll is “Passed”

but Android Studio emulator don’t scrolling (Tried Android 7.0 and 8.0 Nexus 6p and Pixel 2l)

3.1 Version of Katalon studio

I have same problem now,

I’ve create and run my test script and run well before
then I re-execute my test script, and katalon can’t scroll page but console says is passed
is no change on app and my test script

so, is this a katalon’s issue?

Chris Trevarthen said:

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 for the sample code):

Create a new keyword file:

package com.my.keywords.androidimport com.kms.katalon.core.annotation.Keywordimport com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactoryimport io.appium.java_client.AppiumDriverimport io.appium.java_client.TouchActionclass 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.CheckedTextView")		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.CheckedTextView")			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:  
  

CustomKeywords.‘com.my.keywords.android.swiping.scrollListToElementWithText’(‘My Label’)


  

  

Hi Chris,

This is same
passes on katalon’s log, but the app can’t scrolling

Hi Joko,

In the above code, I don’t think there is any validation that the scrolling occurred, so if it doesn’t scroll, the test continues. If you were to verify that the element is visible (or try to tap on it) after you do the scrolling, the test should fail. Something like:

Mobile.verifyElementVisible(findTestObject('Object Repository/My Test Object'), 20)

I had trouble with getting scrolling to work as well when I first started using Katalon Studio. There seem to be a lot of tricks based on the platform you’re using. If you don’t mind adding an external library .jar to your test project, this open source library I have been working on might help:

https://github.com/detroit-labs/katalon-mobile-util#scrolling

The library itself is available at:

https://github.com/detroit-labs/katalon-mobile-util#installation

For info on how to add an external library to your testing project, see the Katalon docs:

https://www.katalon.com/resources-center/tutorials/import-java-library/

Hope this helps,

Chris

1 Like

bonjour est ce que quelqu’un peux me dire comment je fais pour SCROLLER vers le BAS dans un MOBILE

Hello, anyone can tell me please how to SCROLL DOWN in a Mobile - Emulator