Scroll element into view in Galen

901 views
Skip to first unread message

te...@allrecipes.com

unread,
May 7, 2015, 2:50:54 PM5/7/15
to galen-f...@googlegroups.com
I need to scroll a page to reveal an element that is only present after scrolling. Any method that scrolls the page would work. 
I know Javascript and Selenium can do this but I haven't been able to figure out the syntax in a Galen Test Suite. Perhaps I need to import a library?

Does anybody have a solution that works with Galen?

alach...@gmail.com

unread,
May 7, 2015, 4:21:47 PM5/7/15
to galen-f...@googlegroups.com
you could inject javascript to scroll and then do your test

te...@allrecipes.com

unread,
May 7, 2015, 4:40:33 PM5/7/15
to galen-f...@googlegroups.com
Thank you for your response. I did figure that Javascript or Selenium would be required, but I can't find a syntax that works.
I'm looking for a code example that works with Galen. I'm pretty new to Galen and I don't know which objects and methods are visible within the Test Suite.

Is there an API guide?



alach...@gmail.com

unread,
May 7, 2015, 4:43:49 PM5/7/15
to galen-f...@googlegroups.com
I use jquery in Galen, try this?

te...@allrecipes.com

unread,
May 7, 2015, 5:05:09 PM5/7/15
to galen-f...@googlegroups.com
That should work, but I get an error on "$"

ReferenceError: "$" is not defined

My site is using jQuery. Is there something else required to access jQuery?

I have a simple test suite that loads the page and calls the script.
Even the simplest script chokes on the $

$( "div.footer" ).scrollTop( 300 );



Ivan Shubin

unread,
May 8, 2015, 5:25:21 AM5/8/15
to galen-f...@googlegroups.com
Do you "run" the script or actually "inject" it? There is a huge difference in these two actions in a standard test suite. The first one allows you to have a control over the WebDriver. And the "inject" is actually the one you need as it will inject your script on the client side http://galenframework.com/docs/reference-galen-test-suite-syntax/#PageActionsJavaScriptInjection

te...@allrecipes.com

unread,
May 8, 2015, 12:59:30 PM5/8/15
to galen-f...@googlegroups.com
Thank you for that clarification. I wasn't familiar with inject versus run.

My final code is: 
   $("body").scrollTop($("div.footer").offset().top - $("body").offset().top + $("body").scrollTop());
This works when I inject instead of running.

I verified that this code in Chrome Developer Tools console.
When I tried the same code in Firebug console, that line didn't work so, I wasn't surprised when it didn't work in Firefox under Galen.
Seems like a Firefox issue, not a Galen issue.

Thanks all!

Garv Mishra

unread,
Aug 13, 2020, 12:52:12 PM8/13/20
to Galen Framework
Hey are you trying to Scroll within the spec if yes can you share the peace of code

Rahul Rai

unread,
Dec 15, 2021, 9:23:30 AM12/15/21
to Galen Framework
Hi,

Did you got how to scroll a page using js file inside the gsepc file ?
Reply all
Reply to author
Forward
0 new messages