Scroll To Position does not load hidden elements

I am using Chrome with version 63.0.3239.84 (Official Build) (64-bit) and Katalon Studio 5.2.0.1 on Win 10 Pro (64-bit).
I am testing web page which has a lot of elements.
Elements which are in the visible part of the window are loaded at once, others are hidden and are loaded with the mouse scroll down. I am using Scroll to Position to scroll down but the hidden elements are not shown. I also used Scroll to Element to the element, which is below the hidden elements, but the hidden elements are not shown.
(I tested the same web page with Nightwatch using window.scrollBy() and it shows hidden elements, so the issue is in the Katalon Studio Scroll functions).

5 Likes

Hi Anita,

Scroll To Position or Scroll To Element will execute javascript (arguments[0].scrollIntoView()) to scroll to its position or defined element. Your current web application does trigger showing hidden elements when using this approach, so I would like to take this issue as an improvement and will move this discussion to Features / Suggestions category instead.

3 Likes

We’re having the same issue. Using lazy loading for the pages; elements will show when the user starts scrolling. In order to verify the presence of the hidden elements, it would be a great advantage if Katalon Studio could simulate this user action.

3 Likes

+1

2 Likes

I am facing the same issue…not able to click on the hidden element when expands the list.
I have tried both scrollToElement() and scrollToPosition() methods.
Please give the solution for this.

Thank You

4 Likes

I am also facing the same issue with ag-grid, Katalon please provide a solution.

4 Likes

We are facing the same issue when using a SPA solution that implements a so called “infinite scroll” using devxpress components. I believe this is a very common web solution nowadays so really hoping such a test case can be added to Katalon soon!

I kind of faked it out by scrolling to and element I know is mid page so a lower popup menu to enable clicking on it. It’s a little cheat, but it did the trick. Maybe you can use this until such time a better solution comes along? I also added some delays so I can see what it’s doing.

Manual verson


Here’s the script version:

'Scrolling down the page so popup appears. ’

WebUI.scrollToElement(findTestObject(‘Homepage PopUp Footer/Page_Southern New Hampshire Univers/h2_NewSNHU’), 3)

WebUI.waitForElementVisible(findTestObject(‘Homepage PopUp Footer/Page_Southern New Hampshire Univers/a_Apply Now’), 3)

WebUI.click(findTestObject(‘Object Repository/Homepage PopUp Footer/Page_Southern New Hampshire Univers/a_Apply Now’))

WebUI.delay(2)

WebUI.click(findTestObject(‘Homepage PopUp Footer/Page_Southern New Hampshire Univers/a_fancybox-item fancybox-close’))

WebUI.delay(2)

WebUI.mouseOver(findTestObject(‘Homepage PopUp Footer/Page_Southern New Hampshire Univers/a_Visit SNHU’), FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘Homepage PopUp Footer/Page_Southern New Hampshire Univers/a_Visit SNHU’))

image.png

I am also facing the same issue.

1 Like

Anita said:

I am using Chrome with version 63.0.3239.84 (Official Build) (64-bit) and Katalon Studio 5.2.0.1 on Win 10 Pro (64-bit).
I am testing web page which has a lot of elements.
Elements which are in the visible part of the window are loaded at once, others are hidden and are loaded with the mouse scroll down. I am using Scroll to Position to scroll down but the hidden elements are not shown. I also used Scroll to Element to the element, which is below the hidden elements, but the hidden elements are not shown.
(I tested the same web page with Nightwatch using window.scrollBy() and it shows hidden elements, so the issue is in the Katalon Studio Scroll functions).

Hi Anita. Can you give an example AUT where this issue presents ? We are investigating this and I am wondering if your hidden elements, before being scrolled to, are already present on the page, or simply pop into existence.

Since the keyword ScrollToPosition merely emulates scrolling some amount of offsets, it is AUT-dependent whether or not such an action reveals hidden elements. I haven’t tried the aforementioned Nightwatch window.scrollBy() yet, but I think you can accomplish that by this answer. Once we understand the problem clearly we will determine if the improvement should be considered in upcoming releases.

This issue has been acknowledged and logged to Github.
Please follow up its status here: https://github.com/katalon-studio/katalon-studio/issues/10

Thanh To said:

Anita said:

I am using Chrome with version 63.0.3239.84 (Official Build) (64-bit) and Katalon Studio 5.2.0.1 on Win 10 Pro (64-bit).
I am testing web page which has a lot of elements.
Elements which are in the visible part of the window are loaded at once, others are hidden and are loaded with the mouse scroll down. I am using Scroll to Position to scroll down but the hidden elements are not shown. I also used Scroll to Element to the element, which is below the hidden elements, but the hidden elements are not shown.
(I tested the same web page with Nightwatch using window.scrollBy() and it shows hidden elements, so the issue is in the Katalon Studio Scroll functions).

Hi Anita. Can you give an example AUT where this issue presents ? We are investigating this and I am wondering if your hidden elements, before being scrolled to, are already present on the page, or simply pop into existence.

Since the keyword ScrollToPosition merely emulates scrolling some amount of offsets, it is AUT-dependent whether or not such an action reveals hidden elements. I haven’t tried the aforementioned Nightwatch window.scrollBy() yet, but I think you can accomplish that by this answer. Once we understand the problem clearly we will determine if the improvement should be considered in upcoming releases.

Hi,

the hidden elements are not present on the page, they pop into existence when you scroll to the bottom of the page.
Currently, we are using next workaround

for (def j : (1..20)) {

    WebUI.sendKeys(findTestObject(null), Keys.chord(Keys.PAGE_DOWN))

}  

which loads the hidden elements and works fine for us.

2 Likes

Anita said:

Thanh To said:

Anita said:

I am using Chrome with version 63.0.3239.84 (Official Build) (64-bit) and Katalon Studio 5.2.0.1 on Win 10 Pro (64-bit).
I am testing web page which has a lot of elements.
Elements which are in the visible part of the window are loaded at once, others are hidden and are loaded with the mouse scroll down. I am using Scroll to Position to scroll down but the hidden elements are not shown. I also used Scroll to Element to the element, which is below the hidden elements, but the hidden elements are not shown.
(I tested the same web page with Nightwatch using window.scrollBy() and it shows hidden elements, so the issue is in the Katalon Studio Scroll functions).

Hi Anita. Can you give an example AUT where this issue presents ? We are investigating this and I am wondering if your hidden elements, before being scrolled to, are already present on the page, or simply pop into existence.

Since the keyword ScrollToPosition merely emulates scrolling some amount of offsets, it is AUT-dependent whether or not such an action reveals hidden elements. I haven’t tried the aforementioned Nightwatch window.scrollBy() yet, but I think you can accomplish that by this answer. Once we understand the problem clearly we will determine if the improvement should be considered in upcoming releases.

Hi,

the hidden elements are not present on the page, they pop into existence when you scroll to the bottom of the page.
Currently, we are using next workaround

for (def j : (1..20)) {

    WebUI.sendKeys(findTestObject(null), Keys.chord(Keys.PAGE_DOWN))

}  

which loads the hidden elements and works fine for us.

Hi Anita.

I see why ScrollToElement doesn’t work because there’s no element present yet to scroll to, but I tested ScrollToPosition on AirBnB which only loads elements as users scroll down too - seems to be similar to your AUT, and it works fine, as in it successfully loads element as the page moves down.

ScrollToPosition will execute Javascript: window.scrollTo(x,y) where x,y are the desired coordinates. Could you test it with a coordinates far down enough to see if it could accomplish the same thing as your workaround ? It’d be best if you could provide us with a GIF or a video to reproduce this issue.

Thanks a lot !

Hello all,

I faced this because development team using Lazy loading , so not all elements are loaded once the page is opened .
so you need to scroll until element present to verify a hidden element “Not loaded yet”.

I implemented following solution ,

1- you need to use Custom Keywords .
2- import following Java Libraries :

  • import java.awt.Robot;

  • import java.awt.event.InputEvent;
    3- Create Scroll Until element present Method as below :
    @Keyword
    def ScrollUntilElementPresent(String ObjectRepositoryPath) {

      def b = 1
      for (def i = 0; i <b; i++) {
    
      	def Status = WebUI.verifyElementPresent(findTestObject(ObjectRepositoryPath), 0, FailureHandling.OPTIONAL)
      	if (Status == false ) {
      	Robot robot = new Robot();
      	robot.mouseWheel(8)
      	b++
      				}
      				}
      
      WebUI.scrollToElement(findTestObject(ObjectRepositoryPath), 0)
      WebUI.mouseOver(findTestObject(ObjectRepositoryPath))
    

    }

4 - Now back to your script and use above method as below :
CustomKeywords.‘Shahid.ScrollUntilElementPresent’(‘Categories/Movies/Main Movies Page/firstMovieBundle’)

5- Now you have your own ScrollUntilElementPresent Method .
Hopes this will help .

1 Like

Thank for you help, i can scroll down success.
But now i have problem to scroll up.
Can you help my, pls?

Hi @vien.dat

Instead of

robot.mouseWheel(8)

Try

robot.mouseWheel(-8)

You’d probably also need to change the condition. If you’re scrolling up from where you previously scrolled down, then you would need to change the condition to checking if the element on the top of the page is visible with WebUI.verifyElementVisible

1 Like

Thank you so much, i will try it.