nightwatch.js - scroll until element is visible
.getLocationInView()
Determine an element's location on the screen once it has been scrolled into view. Uses elementIdLocationInViewprotocol command.
Parameters:
| Name | Type | description |
|---|---|---|
selector |
string | The CSS/Xpath selector used to locate the element. |
callback |
function | Callback function which is called with the result value. |
Returns
| Type | description |
|---|---|
| x: number, y: number | The X and Y coordinates for the element on the page. |
this.demoTest = function (browser) {
browser.getLocationInView("#main ul li a.first", function(result) {
this.assert.equal(typeof result, "object");
this.assert.equal(result.status, 0);
this.assert.equal(result.value.x, 200);
this.assert.equal(result.value.y, 200);
});
};
|
1down voteaccepted
|
If you are using JQuery you can do it like this:
Or using plain JavaScript:
|
将屏幕滚动到底部实例:
module.exports = {
'your-test': function (browser) {
browser
.url("https://www.sohu.com/")
.pause(1000)
.waitForElementPresent('body', 2000, "Be sure that the page is loaded")
.maximizeWindow()
.pause(1000)
.execute(function() { window.scrollBy(0, 10000000); }, [])
.pause(2000)
.end();
}
}
nightwatch.js - scroll until element is visible的更多相关文章
- Nightwatch.js – 轻松实现浏览器的自动测试
Nightwatch.js 是一个易于使用的,基于 Node.js 平台的浏览器自动化测试解决方案.它使用强大的 Selenium WebDriver API 来在 DOM 元素上执行命令和断言. 语 ...
- 两个标签页定位第二个标签页元素时显示element not visible
问题描述 web页面有两个标签页, 当转换到第二个标签页定位元素时, 显示element not visible. 代码 ... //省略 WebElement ele= browser.getEle ...
- ElementNotVisibleException: Message: element not visible
selenium自动化测试中,经常会报异常: 可能会有各种疑问,元素可以定位到啊.为什么报以下异常? ElementNotVisibleException: Message: element not ...
- selenium.common.exceptions.ElementNotVisibleException: Message: element not visible处理方法:selenium针对下拉菜单事件的处理
使用Selenium爬虫时,可能会遇到一些下拉菜单,动态加载,如果直接使用find_element_by_函数会报错,显示selenium.common.exceptions.ElementNotVi ...
- 爬虫-Selenium -抱错ElementNotVisibleException: Message: element not visible
1.当使用Selenium IDE 完成了脚本的录制和回放通过后,想要将脚本转换为其他语言如java.Python等,首次使用时打开Options->Format发现没有可以转换的语言,如下: ...
- 使用Nightwatch.js做基于浏览器的web应用自动测试
1 安装 1.1 安装Node.js 在http://nodejs.org/ 上下载适合本机系统的安装包运行安装,注意安装选项中选择npm tool以用于后续依赖包的安装. 1.2 ...
- element not visible的解决方法
抛出异常主题为element not visible主要有一下三个方面的原因. 元素之间存在逻辑关系,比如你要选择地址时,中国选择完毕之后,才能选择北京.如果想直接一步到位,则会出现element n ...
- switchable css dark theme in js & html custom element
switchable css dark theme in js & html custom element dark theme / dark mode https://codepen.io/ ...
- Laravel 6.X + Vue.js 2.X + Element UI +vue-router 配置
Laravel 版本:6.X Vue 版本:2.X Laravel配置: Laravel使用的是Laragon安装 选择Laravel:接下来弹出框,输入项目名,laravel会自动创建一个数据库,数 ...
随机推荐
- 使用sami生成文档
从composer安装sami $ composer require sami/sami composer自动配置完以后,可以先测试一下是否安装成功.只要不带参数的运行一下sami,就会知道结果. $ ...
- ASP.NET配置设置-关于web.config各节点的讲解
在msdn中搜索:“ASP.NET配置设置”,可以查看各个节点的配置. httpRuntime 元素:配置 ASP.NET HTTP 运行时设置,以确定如何处理对 ASP.NET 应用程序的请求.
- Bootstrap-datepicker 用法
<div class="input-group input-daterange"> <input type="text" id="s ...
- 刷题总结——湫湫系列故事——设计风景线(hdu4514 并差集判环+树的直径)
题目: 随着杭州西湖的知名度的进一步提升,园林规划专家湫湫希望设计出一条新的经典观光线路,根据老板马小腾的指示,新的风景线最好能建成环形,如果没有条件建成环形,那就建的越长越好. 现在已经勘探 ...
- RestAssured打印日志到文件中的方法
参考https://stackoverflow.com/questions/14476112/how-to-get-rest-assured-log-into-something-printable- ...
- MGW——美团点评高性能四层负载均衡
转自美团点评技术博客:https://tech.meituan.com/MGW.html 前言 在高速发展的移动互联网时代,负载均衡有着举足轻重的地位,它是应用流量的入口,对应用的可靠性和性能起着决定 ...
- uva 10828 高斯消元求数学期望
Back to Kernighan-RitchieInput: Standard Input Output: Standard Output You must have heard the name ...
- 浅谈JS的arguments对象
在JavaScript中,arguments属于当前对象的一个内置属性,arguments非常类似于Array对象,但是又不是实例的Array.比如: Array.prototype.testArg ...
- svg格式矢量图引入方法
引入方法: span { background: url('1.svg') no-repeat; background-size: 20px 20px; background-position: 0 ...
- 重复造轮子之RSA算法(一) 大素数生成
出于无聊, 打算从头实现一遍RSA算法 第一步, 大素数生成 Java的BigInteger里, 有个现成的方法 public static BigInteger probablePrime(int ...