Scroll window horizontally with selenium in Java

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Scroll window horizontally with selenium in Java

derekfast2
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2a4d13a3-13ec-4939-98b4-cafa7652d2fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

ericberkly
You could do it with the javascript executor.

jsExecutor.executeScript('scroll(1000, 0)');

There's a similar question and answer here: http://forum.testproject.io/index.php?topic=55.0



On Monday, May 2, 2016 at 9:48:07 PM UTC+3, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/20c0947c-bb9b-4d93-ae39-4f9e4022d09c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

anemuday
In reply to this post by derekfast2
Hi Derek,

Below is the line of code that will scroll 500 pixels from top.

((JavascriptExecutor) driver).executeScript("window.scrollTo(0, 500)"); 0 is x-coordinate and 500 is y-coordinates from top.

Let us know if it works out.

Thanks,
Uday




On Tuesday, 3 May 2016 00:18:07 UTC+5:30, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/542fa8fd-3c53-48a1-9390-abc6385510fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

anemuday
Sorry,

You wanted scrolling horizontal right? so you can change x-coordinate to 1000 and y as 0

((JavascriptExecutor) driver).executeScript("window.scrollTo(1000, 0)");





On Tuesday, 3 May 2016 17:18:28 UTC+5:30, anemuday wrote:
Hi Derek,

Below is the line of code that will scroll 500 pixels from top.

((JavascriptExecutor) driver).executeScript("window.scrollTo(0, 500)"); 0 is x-coordinate and 500 is y-coordinates from top.

Let us know if it works out.

Thanks,
Uday
<a href="https://www.youtube.com/user/AnemUday/videos" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.youtube.com/user/AnemUday/videos&#39;;return true;" onclick="this.href=&#39;https://www.youtube.com/user/AnemUday/videos&#39;;return true;">Selenium WebDriver Videos




On Tuesday, 3 May 2016 00:18:07 UTC+5:30, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/abab5449-c67b-40d5-8a9d-4d662b5df8a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

divya
In reply to this post by derekfast2
Hi ,

I am trying to scroll the page down using java Script Executor and the code is as below :


But it doesn't Execute the script Any help is Appreciated.i am Also not sure about the pixel number to be given?



((JavascriptExecutor)driver).executeScript("scroll(0,2000)");.




On Tuesday, May 3, 2016 at 12:18:07 AM UTC+5:30, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7cc1c38d-8507-44ef-aac2-9507313c07be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

anemuday
Divya,

Your screen resolution may not have 2000 y coordinate. Generally x,y coordinates are like 1024 * 768 etc....

Try using scroll with 1000(y-coordinate) or 500 like that.
((JavascriptExecutor)driver).executeScript("scroll(0,1000)");

Thanks,
Uday

On Monday, 19 June 2017 13:57:20 UTC+5:30, divya wrote:
Hi ,

I am trying to scroll the page down using java Script Executor and the code is as below :


 
But it doesn't Execute the script Any help is Appreciated.i am Also not sure about the pixel number to be given?



((JavascriptExecutor)driver).executeScript("scroll(0,2000)");.




On Tuesday, May 3, 2016 at 12:18:07 AM UTC+5:30, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/db9d2c15-b13a-4c82-89e1-307d73c6c3e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scroll window horizontally with selenium in Java

divya
In reply to this post by divya
Hi ,

I am trying to click on an element and it is located below the page hence using scroll to move it down. the element is getting highlighted but it is not clicked.

1. Tried adding wait and also tried using Actions double click and the is displayed for element says true and I have added enough wait time also .

the xpath for the  same is:
//div[@id='overviewtab_1']//div[@class='row']/div//button[@class='btn btn-primary pull-right btn-sm']

Actually the xpath has many divs like .//*[@id='overviewtab_1']/div/div/div/div/div[2]/div/div/div/div[1]/div/div/button so modified it .

The element is highlighted when run the script but does not click . Can some one help me please.


Thanks,
Srividya.






On Mon, Jun 19, 2017 at 1:49 PM, divya <[hidden email]> wrote:
Hi ,

I am trying to scroll the page down using java Script Executor and the code is as below :


But it doesn't Execute the script Any help is Appreciated.i am Also not sure about the pixel number to be given?



((JavascriptExecutor)driver).executeScript("scroll(0,2000)");.




On Tuesday, May 3, 2016 at 12:18:07 AM UTC+5:30, [hidden email] wrote:
Is it possible to scroll the window horizontally by a small margin using selenium code ?

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/yg-UUagzAT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7cc1c38d-8507-44ef-aac2-9507313c07be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANyhun39%2B%3DKwfrfVY2Shas4WJ40tet_j%2BKzSEBLMnsO0x%2B9LQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.