简体   繁体   中英

How to scroll top of browser window from middle or bottom of browser window using javascript in protractor

I need to click the element located at bottom of page then I have to click element located at top of page.

ie scroll up which is not visible to browser.

For scroll down I've used:

browser.actions().mouseMove(element).perform()`" 

Kindly suggest solution to do this task

There are multiple ways to scroll to the very top of the page:

  1. Via window.scrollTo() :

     browser.executeScript("window.scrollTo(0, 0);"); 
  2. Locate an element on top and scroll into it's view :

     var header = element(by.tagName("header")); browser.executeScript("arguments[0].scrollIntoView();", header.getWebElement()); 
  3. Locate an element on top and move to it as you've demonstrated for the scroll down:

     var header = element(by.tagName("header")); browser.actions().mouseMove(header).perform(); 

Also see:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM