【问题标题】:How to set focus on a section of my web page then scroll down如何将焦点设置在我网页的某个部分然后向下滚动
【发布时间】:2015-06-18 01:45:07
【问题描述】:

使用量角器我想首先将焦点设置在网页的左侧面板上,然后向下滚动以单击过滤器。 知道如何使用量角器语法来做到这一点吗? 这是我的 HTML:

<section id="filters" style="height: 266px; overflow: hidden;" tabindex=
"5076">
    <div class="ng-binding" id="currentSearchTitle">
        Current search
    </div>

    <div id="currentSearch">
        <div id="searchBlock">
            <div id="jobTypeBlock">
                <div class="ng-binding" id="jobTypeTitle">
                    Filter by job type
                </div>

                <div class="ng-scope">
                    <div class="ng-scope">
                        <div class="ng-scope">
                            <div class="ng-scope">
                                <div class="ng-scope">
                                    <div class="ng-scope">
                                        <div class="ng-scope"></div>

【问题讨论】:

    标签: javascript angularjs scroll protractor


    【解决方案1】:

    要在面板上设置焦点,您可以单击它:

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

    然后滚动到您的过滤器,您可以执行客户端脚本:

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

    你可以看看webdriverjs doc

    【讨论】:

    【解决方案2】:

    您也可以使用它: browser.executeScript("arguments[0].scrollIntoView();", basePage.faqText.getWebElement());

    我在一行中施展魔法。

    basePage.faqText 是我要在此处滚动的元素。

    【讨论】:

      猜你喜欢
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多