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会自动创建一个数据库,数 ...
随机推荐
- Welcome-to-Swift-22泛型(Generics)
泛型代码可以确保你写出灵活的,可重用的函数和定义出任何你所确定好的需求的类型.你可以写出避免重复的代码,并且用一种清晰的,抽象的方式表达出来. 泛型是Swift许多强大特征中的其中一个,许多Swift ...
- 【bzoj2724】[Violet 6]蒲公英 分块+STL-vector
题目描述 输入 修正一下 l = (l_0 + x - 1) mod n + 1, r = (r_0 + x - 1) mod n + 1 输出 样例输入 6 3 1 2 3 2 1 2 1 5 3 ...
- springboot中如果使用了@Autowired注入了bean,则这个类也要为spring bean,new出来注入的bean为null
https://blog.csdn.net/Mr_Runner/article/details/83684088 问题:new出来的实例中含有@Autowired注入时,注入的Bean为null: 解 ...
- phpMyAdmin操作之改管理员密码
1.登录phpMyAdmin 默认地址:http://localhost/phpmyadmin 2.点击用户按钮 3.往下拉找到修改密码 点执行就修改了 注意: 如果再次登录时报错提示: #1045 ...
- 更改 terminal 開啟時,預設的路徑
echo "cd /media" >> ~/.bashrc open a new terminal (ctrl + alt + t)
- unity3d各平台通讯原生的平台API的说明
注意:unity3d与原生代码的调用需要pro版本,此点注意了. 一.IOS平台,由于IOS平台的原生应该是objectC,所以通讯起来非常的简单, 1.原生代码调用u3d代码: 1.1.在Xcode ...
- php自动获取字符串编码函数mb_detect_encoding
当在php中使用mb_detect_encoding函数进行编码识别时,很多人都碰到过识别编码有误的问题,例如对与GB2312和UTF- 8,或者UTF-8和GBK(这里主要是对于cp936的判断), ...
- yii模板中常用变量总结
yii模板中常用的一些变量总结. 现有这样一个url:http://www.phpernote.com/demos/helloworld/index.php/xxx/xxx 则通过如下方式获取的值对应 ...
- centos 7安装golang1.10
一.安装&配置 官方下载包(一般需要梯子) https://golang.org/dl/ wget https://dl.google.com/go/go1.10.linux-amd64.ta ...
- LeetCode OJ--Median of Two Sorted Arrays ***
http://oj.leetcode.com/problems/median-of-two-sorted-arrays/ 找两个有序数组的中位数,因为有序数组,并且复杂度要求O(lg(m+n))所以想 ...