Want to move down using scrollbar selenium webdriver












1















I need to move down using scrollbar on a web page using selenium webdriver



I used following code



Actions dragger = new Actions(driver);
WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
int numberOfPixelsToDragTheScrollbarDown = 5000;
dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();


still its not moving down...xpath is changing as per position of scrollbar...










share|improve this question





























    1















    I need to move down using scrollbar on a web page using selenium webdriver



    I used following code



    Actions dragger = new Actions(driver);
    WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
    int numberOfPixelsToDragTheScrollbarDown = 5000;
    dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();


    still its not moving down...xpath is changing as per position of scrollbar...










    share|improve this question



























      1












      1








      1


      2






      I need to move down using scrollbar on a web page using selenium webdriver



      I used following code



      Actions dragger = new Actions(driver);
      WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
      int numberOfPixelsToDragTheScrollbarDown = 5000;
      dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();


      still its not moving down...xpath is changing as per position of scrollbar...










      share|improve this question
















      I need to move down using scrollbar on a web page using selenium webdriver



      I used following code



      Actions dragger = new Actions(driver);
      WebElement draggablePartOfScrollbar = driver.findElement(By.xpath("/html/body/section[2]/div/div[2]/div/div/div"));
      int numberOfPixelsToDragTheScrollbarDown = 5000;
      dragger.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0,numberOfPixelsToDragTheScrollbarDown).release().perform();


      still its not moving down...xpath is changing as per position of scrollbar...







      c# selenium






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 2:55









      ivan_pozdeev

      19.8k85294




      19.8k85294










      asked Dec 27 '13 at 6:36









      Prasad DinPrasad Din

      352312




      352312
























          5 Answers
          5






          active

          oldest

          votes


















          1














          If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.



          WebElement element = driver.findElement(By.id("id_of_element"));
          ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
          Thread.sleep(500);

          //do anything you want with the element





          share|improve this answer
























          • not working......

            – Prasad Din
            Dec 27 '13 at 7:36











          • what is the element you are trying to find?

            – Amith
            Dec 27 '13 at 7:44











          • its a text area....

            – Prasad Din
            Dec 27 '13 at 8:29













          • can you provide the html for this?

            – Amith
            Dec 27 '13 at 8:32






          • 1





            This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

            – djangofan
            Dec 29 '13 at 20:30





















          1














          My code is in python..hope it might help you and you can reproduce the same to java



          actionChains = ActionChains(driver)
          option=driver.find_element_by_class_name("mCSB_dragger_bar")
          actionChains.click_and_hold(option).perform()
          actionChains.move_by_offset(0,5000).perform()
          actionChains.release()


          The above code can be simplified as



          actionChains = ActionChains(driver)
          option=driver.find_element_by_class_name("mCSB_dragger_bar")
          actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()





          share|improve this answer































            0














              JavascriptExecutor js=(JavascriptExecutor)driver;
            js.executeScript("window.scrollBy(0,100)");





            share|improve this answer































              0














              By



              scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
              WebElement scrollUp = driver.findElement(scroll);
              scrollUp.sendKeys(Keys.PAGE_DOWN);
              scrollUp.sendKeys(Keys.PAGE_DOWN);
              scrollUp.sendKeys(Keys.PAGE_DOWN);
              scrollUp.sendKeys(Keys.PAGE_DOWN);


              For scroll up:



              scrollUp.sendKeys(Keys.PAGE_DOWN);





              share|improve this answer

































                0














                For Java the code is below:



                public void moveOverElement(WebElement element)
                {
                Actions actions = new Actions(driver);

                actions.clickAndHold(element).moveByOffset(0,5000).release().perform();

                }


                For definition WebElement, for the webelement you have to define only the path:



                @FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")

                private WebElement createdQABoxElement;





                share|improve this answer
























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f20796053%2fwant-to-move-down-using-scrollbar-selenium-webdriver%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  5 Answers
                  5






                  active

                  oldest

                  votes








                  5 Answers
                  5






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  1














                  If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.



                  WebElement element = driver.findElement(By.id("id_of_element"));
                  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
                  Thread.sleep(500);

                  //do anything you want with the element





                  share|improve this answer
























                  • not working......

                    – Prasad Din
                    Dec 27 '13 at 7:36











                  • what is the element you are trying to find?

                    – Amith
                    Dec 27 '13 at 7:44











                  • its a text area....

                    – Prasad Din
                    Dec 27 '13 at 8:29













                  • can you provide the html for this?

                    – Amith
                    Dec 27 '13 at 8:32






                  • 1





                    This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                    – djangofan
                    Dec 29 '13 at 20:30


















                  1














                  If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.



                  WebElement element = driver.findElement(By.id("id_of_element"));
                  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
                  Thread.sleep(500);

                  //do anything you want with the element





                  share|improve this answer
























                  • not working......

                    – Prasad Din
                    Dec 27 '13 at 7:36











                  • what is the element you are trying to find?

                    – Amith
                    Dec 27 '13 at 7:44











                  • its a text area....

                    – Prasad Din
                    Dec 27 '13 at 8:29













                  • can you provide the html for this?

                    – Amith
                    Dec 27 '13 at 8:32






                  • 1





                    This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                    – djangofan
                    Dec 29 '13 at 20:30
















                  1












                  1








                  1







                  If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.



                  WebElement element = driver.findElement(By.id("id_of_element"));
                  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
                  Thread.sleep(500);

                  //do anything you want with the element





                  share|improve this answer













                  If you are trying to locate some element by scrolling down,the following code will scroll until the element is in view.



                  WebElement element = driver.findElement(By.id("id_of_element"));
                  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
                  Thread.sleep(500);

                  //do anything you want with the element






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 27 '13 at 7:24









                  AmithAmith

                  4,91862442




                  4,91862442













                  • not working......

                    – Prasad Din
                    Dec 27 '13 at 7:36











                  • what is the element you are trying to find?

                    – Amith
                    Dec 27 '13 at 7:44











                  • its a text area....

                    – Prasad Din
                    Dec 27 '13 at 8:29













                  • can you provide the html for this?

                    – Amith
                    Dec 27 '13 at 8:32






                  • 1





                    This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                    – djangofan
                    Dec 29 '13 at 20:30





















                  • not working......

                    – Prasad Din
                    Dec 27 '13 at 7:36











                  • what is the element you are trying to find?

                    – Amith
                    Dec 27 '13 at 7:44











                  • its a text area....

                    – Prasad Din
                    Dec 27 '13 at 8:29













                  • can you provide the html for this?

                    – Amith
                    Dec 27 '13 at 8:32






                  • 1





                    This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                    – djangofan
                    Dec 29 '13 at 20:30



















                  not working......

                  – Prasad Din
                  Dec 27 '13 at 7:36





                  not working......

                  – Prasad Din
                  Dec 27 '13 at 7:36













                  what is the element you are trying to find?

                  – Amith
                  Dec 27 '13 at 7:44





                  what is the element you are trying to find?

                  – Amith
                  Dec 27 '13 at 7:44













                  its a text area....

                  – Prasad Din
                  Dec 27 '13 at 8:29







                  its a text area....

                  – Prasad Din
                  Dec 27 '13 at 8:29















                  can you provide the html for this?

                  – Amith
                  Dec 27 '13 at 8:32





                  can you provide the html for this?

                  – Amith
                  Dec 27 '13 at 8:32




                  1




                  1





                  This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                  – djangofan
                  Dec 29 '13 at 20:30







                  This answer by Amith003 is basically the right idea. You can ALSO use JavaScriptExecutor to send Key.DOWN messages to do page downs by the keyboard. That is the way I do it because I couldn't get scrollIntoView to work either...

                  – djangofan
                  Dec 29 '13 at 20:30















                  1














                  My code is in python..hope it might help you and you can reproduce the same to java



                  actionChains = ActionChains(driver)
                  option=driver.find_element_by_class_name("mCSB_dragger_bar")
                  actionChains.click_and_hold(option).perform()
                  actionChains.move_by_offset(0,5000).perform()
                  actionChains.release()


                  The above code can be simplified as



                  actionChains = ActionChains(driver)
                  option=driver.find_element_by_class_name("mCSB_dragger_bar")
                  actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()





                  share|improve this answer




























                    1














                    My code is in python..hope it might help you and you can reproduce the same to java



                    actionChains = ActionChains(driver)
                    option=driver.find_element_by_class_name("mCSB_dragger_bar")
                    actionChains.click_and_hold(option).perform()
                    actionChains.move_by_offset(0,5000).perform()
                    actionChains.release()


                    The above code can be simplified as



                    actionChains = ActionChains(driver)
                    option=driver.find_element_by_class_name("mCSB_dragger_bar")
                    actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()





                    share|improve this answer


























                      1












                      1








                      1







                      My code is in python..hope it might help you and you can reproduce the same to java



                      actionChains = ActionChains(driver)
                      option=driver.find_element_by_class_name("mCSB_dragger_bar")
                      actionChains.click_and_hold(option).perform()
                      actionChains.move_by_offset(0,5000).perform()
                      actionChains.release()


                      The above code can be simplified as



                      actionChains = ActionChains(driver)
                      option=driver.find_element_by_class_name("mCSB_dragger_bar")
                      actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()





                      share|improve this answer













                      My code is in python..hope it might help you and you can reproduce the same to java



                      actionChains = ActionChains(driver)
                      option=driver.find_element_by_class_name("mCSB_dragger_bar")
                      actionChains.click_and_hold(option).perform()
                      actionChains.move_by_offset(0,5000).perform()
                      actionChains.release()


                      The above code can be simplified as



                      actionChains = ActionChains(driver)
                      option=driver.find_element_by_class_name("mCSB_dragger_bar")
                      actionChains.click_and_hold(option).move_by_offset(0,5000).release().perform()






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Dec 27 '13 at 9:39









                      Mahesh Reddy AtlaMahesh Reddy Atla

                      301312




                      301312























                          0














                            JavascriptExecutor js=(JavascriptExecutor)driver;
                          js.executeScript("window.scrollBy(0,100)");





                          share|improve this answer




























                            0














                              JavascriptExecutor js=(JavascriptExecutor)driver;
                            js.executeScript("window.scrollBy(0,100)");





                            share|improve this answer


























                              0












                              0








                              0







                                JavascriptExecutor js=(JavascriptExecutor)driver;
                              js.executeScript("window.scrollBy(0,100)");





                              share|improve this answer













                                JavascriptExecutor js=(JavascriptExecutor)driver;
                              js.executeScript("window.scrollBy(0,100)");






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Feb 3 '14 at 11:00









                              SATYASATYA

                              373




                              373























                                  0














                                  By



                                  scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
                                  WebElement scrollUp = driver.findElement(scroll);
                                  scrollUp.sendKeys(Keys.PAGE_DOWN);
                                  scrollUp.sendKeys(Keys.PAGE_DOWN);
                                  scrollUp.sendKeys(Keys.PAGE_DOWN);
                                  scrollUp.sendKeys(Keys.PAGE_DOWN);


                                  For scroll up:



                                  scrollUp.sendKeys(Keys.PAGE_DOWN);





                                  share|improve this answer






























                                    0














                                    By



                                    scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
                                    WebElement scrollUp = driver.findElement(scroll);
                                    scrollUp.sendKeys(Keys.PAGE_DOWN);
                                    scrollUp.sendKeys(Keys.PAGE_DOWN);
                                    scrollUp.sendKeys(Keys.PAGE_DOWN);
                                    scrollUp.sendKeys(Keys.PAGE_DOWN);


                                    For scroll up:



                                    scrollUp.sendKeys(Keys.PAGE_DOWN);





                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      By



                                      scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
                                      WebElement scrollUp = driver.findElement(scroll);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);


                                      For scroll up:



                                      scrollUp.sendKeys(Keys.PAGE_DOWN);





                                      share|improve this answer















                                      By



                                      scroll=By.xpath("//*[@id='aspnetForm']/center/div/div[2]/table/tbody/tr[2]/td[1]/table/tbody");
                                      WebElement scrollUp = driver.findElement(scroll);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);
                                      scrollUp.sendKeys(Keys.PAGE_DOWN);


                                      For scroll up:



                                      scrollUp.sendKeys(Keys.PAGE_DOWN);






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Mar 27 '15 at 12:53









                                      JoelC

                                      2,46383133




                                      2,46383133










                                      answered Mar 27 '15 at 12:08









                                      chandrasekarchandrasekar

                                      1




                                      1























                                          0














                                          For Java the code is below:



                                          public void moveOverElement(WebElement element)
                                          {
                                          Actions actions = new Actions(driver);

                                          actions.clickAndHold(element).moveByOffset(0,5000).release().perform();

                                          }


                                          For definition WebElement, for the webelement you have to define only the path:



                                          @FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")

                                          private WebElement createdQABoxElement;





                                          share|improve this answer




























                                            0














                                            For Java the code is below:



                                            public void moveOverElement(WebElement element)
                                            {
                                            Actions actions = new Actions(driver);

                                            actions.clickAndHold(element).moveByOffset(0,5000).release().perform();

                                            }


                                            For definition WebElement, for the webelement you have to define only the path:



                                            @FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")

                                            private WebElement createdQABoxElement;





                                            share|improve this answer


























                                              0












                                              0








                                              0







                                              For Java the code is below:



                                              public void moveOverElement(WebElement element)
                                              {
                                              Actions actions = new Actions(driver);

                                              actions.clickAndHold(element).moveByOffset(0,5000).release().perform();

                                              }


                                              For definition WebElement, for the webelement you have to define only the path:



                                              @FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")

                                              private WebElement createdQABoxElement;





                                              share|improve this answer













                                              For Java the code is below:



                                              public void moveOverElement(WebElement element)
                                              {
                                              Actions actions = new Actions(driver);

                                              actions.clickAndHold(element).moveByOffset(0,5000).release().perform();

                                              }


                                              For definition WebElement, for the webelement you have to define only the path:



                                              @FindBy (xpath = ".//*[contains(@class, 'link-name') and text() = 'QAEbox']")

                                              private WebElement createdQABoxElement;






                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Feb 27 '18 at 12:32









                                              Marius GolbanMarius Golban

                                              13




                                              13






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f20796053%2fwant-to-move-down-using-scrollbar-selenium-webdriver%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  How to send String Array data to Server using php in android

                                                  Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                                                  Is anime1.com a legal site for watching anime?