[英]How to set focus on a section of my web page then scroll down
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 :
这是我的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 . 您可以查看webdriverjs文档 。
You can use this too: browser.executeScript("arguments[0].scrollIntoView();", basePage.faqText.getWebElement());
您也可以使用它:
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. basePage.faqText
是我想在这里滚动的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.