如何将焦点设置我的网页的一个部分,然后向下滚动 [英] How to set focus on a section of my web page then scroll down

查看:140
本文介绍了如何将焦点设置我的网页的一个部分,然后向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用量角器

我想在我的网页第一次将焦点设置在左潘内尔那么为了点击过滤器向下滚动。
任何想法如何做到这一点使用量角器语法?
这是我的HTML:

 <节ID =过滤器的风格=高度:266px;溢出:隐藏;的tabindex =
5076>
    < D​​IV CLASS =NG结合ID =currentSearchTitle>
        当前搜索
    < / DIV>    < D​​IV ID =currentSearch>
        < D​​IV ID =searchBlock>
            < D​​IV ID =jobTypeBlock>
                < D​​IV CLASS =NG结合ID =jobTypeTitle>
                    按工作类型过滤
                < / DIV>                < D​​IV CLASS =NG-范围>
                    < D​​IV CLASS =NG-范围>
                        < D​​IV CLASS =NG-范围>
                            < D​​IV CLASS =NG-范围>
                                < D​​IV CLASS =NG-范围>
                                    < D​​IV CLASS =NG-范围>
                                        < D​​IV CLASS =NG-范围>< / DIV>


解决方案

要设置焦点的面板上你也许可以点击它:

 元素(by.id('过滤器'))点击()。

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

  VAR过滤= browser.findElement(by.id('jobTypeTitle'));
VAR scrollIntoView =功能(){
  参数[0] .scrollIntoView();
};
browser.executeScript(scrollIntoView,过滤器);

您可以看看在<一个href=\"https://$c$c.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js?name=2.34.0#398\"相对=nofollow> webdriverjs DOC 。

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 syntax? Here is my 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>

解决方案

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.

这篇关于如何将焦点设置我的网页的一个部分,然后向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆