I started using Browser Library on my automation. I enjoyed using it compared to selenium as this is faster. But now I encountered a bottleneck, Scroll to Element, Scroll By, and Scroll to is not working. I needed the scroll functions to continue with my automation as i need to test certain element in the middle of the webpage. I know that the selector that i used is correct because when I tried to manually scroll during automation run, the tests will pass. Here is my sample code
Translate Text
[Arguments] ${language} ${category} ${text}
${translated_text} = get_value_from_excel ${category} ${language} ${text}
Scroll To Element ${PO_${text.replace(’ ', ‘').upper()}}
${web_text} = Get Text ${PO${text.replace(’ ', ‘_’).upper()}}
Should Be Equal ${web_text} ${translated_text}
@rasjani What do you mean by call log? where can I see that?
Regarding on the behavior of the website, i notice that when i scroll down manually, new request were being sent to the backend, after that request was process, it will then show in UI. Is that the Lazy-loaded you are referring to?
Thanks for providing the link. I read and follow the instruction on how to use Scroll To but it still doesn’t work. This is my code for the Scroll To kw:
Scroll To ${None} bottom left auto
but unfortunately, I still encounter this error:
TimeoutError: locator.scrollIntoViewIfNeeded: Timeout 10000ms exceeded.
Single scroll to bottom might not be enough. I’d approach this by creating to a keyword that does that scroll to bottom and then check if element is there and if not, fail the keyword… then use Wait Until keyword succeeds to call that new keyword multiple times until element is found OR timeout/ iteration limit is reached (and thus, failing)
@jolo26 You can use something like the following example:
Lazy loading
New Browser browser=chromium headless=False
New Context
New Page url=https://www.visitflorida.com/beaches
${browserHeight} Evaluate JavaScript ${None} window.innerHeight
${pageHeight} Evaluate JavaScript ${None} document.body.scrollHeight
VAR ${selector} //img[@src="https://assets.simpleviewinc.com/simpleview/image/upload/c_fill,f_jpg,h_284,q_55,w_360/v1/clients/visitflorida/Sunset_Islamorada_Florida_Keys_ce53f890-53b3-4cf1-a0ac-4f12a5e3b7ad.jpg"]
FOR ${scroll_range} IN RANGE 0 ${pageHeight} ${browserHeight}
Mouse Wheel 0 ${browserHeight}
${element_visible} Get Element States ${selector} then bool(value & visible)
IF ${element_visible} == ${True} BREAK
END
Click ${selector}
If you disable the FOR block, the script won’t work because the element is then not present.
Still does not work on the website that Im working on. I think there are functionality that prohibits the Scroll to to work properly. But the Mouse wheel work as suggested by @falcon030 . Thanks to both of you for the help