How to set focus on a section of my web page then scroll down(如何将焦点设置在我网页的某个部分然后向下滚动)
问题描述
使用量角器我想首先将焦点设置在网页的左侧面板上,然后向下滚动以单击过滤器.知道如何使用量角器语法来做到这一点吗?这是我的 HTML:
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);
您可以查看 webdriverjs 文档.
这篇关于如何将焦点设置在我网页的某个部分然后向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将焦点设置在我网页的某个部分然后向下滚动


基础教程推荐
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01