How to acheive page scroll and how to verify that it is getting scrolled ?

1,940 views
Skip to first unread message

Pavithra

unread,
Apr 2, 2012, 1:49:23 AM4/2/12
to webd...@googlegroups.com
I have a scenario below, kindly let me know whether it is automatable using webdriver. If so, how ?

Scenario:
In the mail application, select the message
Scroll in the middle of the read page  --  How to do scrolling ?
Click on up arrow in keyboard

Expected result:
Verify this should move the content going up in a very short increment on read window -- How to verify this ?

Thanks,
Pavithra

Sasi kumar

unread,
Apr 2, 2012, 2:09:06 AM4/2/12
to webdriver
try this,

int pixel=500;
((JavascriptExecutor)driver).executeScript("if(window.screen)
{window.scrollBy(0,"+pixel+");};");

On Apr 2, 10:49 am, Pavithra <pavi...@gmail.com> wrote:
> I have a scenario below, kindly let me know whether it is automatable using
> webdriver. If so, how ?
>
> Scenario:
> In the mail application, select the message
> Scroll in the middle of the read page  -- * How to do scrolling ?*
> Click on up arrow in keyboard
>
> Expected result:
> Verify this should move the content going up in a very short increment on
> read window -- *How to verify this ?*
>
> Thanks,
> Pavithra

Pavithra

unread,
Apr 2, 2012, 2:15:08 AM4/2/12
to webd...@googlegroups.com
Thanks Sasi.
This is for scrolling rt ? and Is there a way to verify whether the page is getting scrolled up or down ?

And does this works for all browsers ? IE, Firefox, Chrome ?
Anyway I will try out in above browsers.

Sasi kumar

unread,
Apr 2, 2012, 2:28:04 AM4/2/12
to webdriver
I haven't tried that ,but you can use java script code to find
position after scrolling or similar and execute that in selenium.

vamsi chandra

unread,
Apr 2, 2012, 5:34:28 AM4/2/12
to webd...@googlegroups.com
Hi, this is a bit optimize code it works ...

 driver.executeScript("scroll(0,20000)");

works on win7 32-bit webdriver2 with java

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


SANTHOSH BABY

unread,
Apr 2, 2012, 1:28:23 PM4/2/12
to webd...@googlegroups.com
Usage of JavaScript is not recommended . Since it wont work in all the browsers.

Lukus

unread,
Apr 2, 2012, 2:53:01 PM4/2/12
to webd...@googlegroups.com
I use javascript across all browsers and devices and works with very little error.  Here are the commands in js.  You will have to manage the driver 

//scroll the page.. you can change the 'window' object to be another scrollable element if need be
window.scrollTo(x,y); //notice there's nothing to return in webdriver code

//return how far the page is scrolled down - returns integer to webdriver hence the return statements - change to Xoffset or scrollLeft for scrolling to the right.
if (window.pageYOffset) return window.pageYOffset;else if (window.document.documentElement.scrollTop)return window.document.documentElement.scrollTop;else return window.document.body.scrollTop;
 
Offsets will not be as expected on mobile devices for pages that are scaled down to fit the viewport.

Enjoy.

SANTHOSH BABY

unread,
Apr 2, 2012, 3:22:03 PM4/2/12
to webd...@googlegroups.com
WebDriver is designed to accurately simulate the way that a user will interact with a web application. A common approach for simulating user input is to make use of Javascript to synthesize and fire the series of events that an app would see if a real user were to perform the same interaction. This "synthesized events" approach is fraught with difficulties as each browser, and sometimes different versions of the same browser, fire slightly different events with slightly different values. To complicate matters, most browsers won't allow a user to interact in this way with form elements such as file input elements for security reasons.

Where possible WebDriver uses the alternative approach of firing events at the OS level. As these "native events" aren't generated by the browser this approach circumvents the security restrictions placed on synthesized events and, because they are OS specific, once they are working for one browser on a particular platform reusing the code in another browser is relatively easy

Thank you
Cheers.
rsz_santhosh.jpg
Santhosh Baby

Santhosh Software Automation  Engineer
 



Think GREEN. Please consider the environment before printing this email

"When The Winds of Change Blow..... Some people Build Walls & Others Windmills.... Attitude Matters...."



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/sFzmzvawxZwJ.
rsz_santhosh.jpg
image001.gif
Reply all
Reply to author
Forward
0 new messages