How to set focus on a section of my web page then scroll down

前端 未结 2 468
梦毁少年i
梦毁少年i 2021-01-18 01:35

using protractor I would like to first set focus on a left pannel in my web page then scroll down in order to click on a filter. Any idea how to do this using protractor syn

相关标签:
2条回答
  • 2021-01-18 01:52

    You can use this too: browser.executeScript("arguments[0].scrollIntoView();", basePage.faqText.getWebElement());

    I does the magic in one line.

    basePage.faqText is the element that I want to scroll here.

    0 讨论(0)
  • 2021-01-18 02:12

    To set the focus on your panel you can maybe click on it:

    element(by.id('filters')).click();
    

    Then to scroll to your filter, you can execute a client side script:

    var filter = browser.findElement(by.id('jobTypeTitle'));
    var scrollIntoView = function () {
      arguments[0].scrollIntoView();
    };
    browser.executeScript(scrollIntoView, filter);
    

    You can have a look at the webdriverjs doc.

    0 讨论(0)
提交回复
热议问题