NightWatch端到端测试
NightWatch
http://nightwatchjs.org/
Nightwatch.js
Browser automated testing done easy.
Write End-to-End tests in Node.js quickly and effortlessly that run against a Selenium/WebDriver server.
Browser Automation
Nightwatch.js is an easy to use Node.js based End-to-End (E2E) testing solution for browser based apps and websites. It uses the powerful W3C WebDriver API to perform commands and assertions on DOM elements.
安装
https://github.com/nightwatchjs/nightwatch
1. Install Nightwatch
Install Node.js (together with the NPM tool) by following instructions available on nodejs.org.
From NPM:
$ npm install nightwatchFrom GitHub:
$ git clone https://github.com/nightwatchjs/nightwatch.git
$ cd nightwatch
$ npm install2. Download WebDriver
Nightwatch uses a WebDriver compatible server to control the browser. WebDriver is a W3C specification and industry standard which provides a platform and HTTP protocol to interact with a browser.
Nightwatch includes support for automatically managing the following services:
ChromeDriver
- for running tests against the Chrome browser;
- download url: https://sites.google.com/a/chromium.org/chromedriver/downloads.
Selenium Standalone Server
- allows managing multiple browser configurations in one place and also to make use of the Selenium Grid service;
- the selenium server jar file
selenium-server-standalone-3.x.x.jar
can be downloaded from the Selenium releases page: https://selenium-release.storage.googleapis.com/index.htmlIt's important to note that, while the Selenium Server was required with older Nightwatch versions (
v0.9
and prior), starting with version1.0
Selenium is no longer necessary.
安装报错解决方法:
https://github.com/nightwatchjs/nightwatch/issues/913
Nightwatch: Error retrieving a new session from the selenium server #913
https://github.com/nightwatchjs/nightwatch/issues/1390
"chromeOptions" : {
"args" : ["disable-web-security", "ignore-certificate-errors", "headless"],
}
他山之石
https://blog.risingstack.com/end-to-end-testing-with-nightwatch-js-node-js-at-scale/
th these three tools, we are going to implement the flow this diagram shows below.
自己动手
https://github.com/fanqingsong/code-snippet/tree/master/web/night_watch
package.json
{
"name": "night_watch",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "./node_modules/.bin/nightwatch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"chromedriver": "^2.41.0",
"nightwatch": "^0.9.21",
"selenium-server": "^3.14.0"
}
}
nigthwatch.json
{
"src_folders" : ["./examples/tests"],
"output_folder" : "./examples/reports", "selenium" : {
"start_process" : true,
"server_path" : "./node_modules/selenium-server/lib/runner/selenium-server-standalone-3.14.0.jar",
"log_path" : "",
"host": "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
}
}, "test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions" : {
"args" : ["disable-web-security", "ignore-certificate-errors"]
}
}
}
}
}
nightwatch.js
module.exports = {
'Find the answer.': function(client) {
// 启动浏览器并打开 bing.com.
client.url('http://www.txrjy.com'); // 确保 "body" 和输入框可以使用.
client.expect.element('body').to.be.present;
client.end();
},
};
NightWatch端到端测试的更多相关文章
- 脚手架vue-cli系列五:基于Nightwatch的端到端测试环境
不同公司和组织之间的测试效率迥异.在这个富交互和响应式处理随处可见的时代,很多组织都使用敏捷的方式来开发应用,因此测试自动化也成为软件项目的必备部分.测试自动化意味着使用软件工具来反复运行项目中的测试 ...
- 最受欢迎的5款Node.js端到端测试框架
测试,尤其是自动化测试在现代 WEB 工程中有着非常重要的角色,与交付过程集成良好的自动化测试流程可以在新版发布时帮你快速回归产品功能,也可以充当产品文档.测试因粒度不同又可以分为单元测试.接口测试. ...
- Nightwatch——自动化测试(端对端e2e)
背景: 前端页面模拟仿真操作,目的是避免每次更新相关内容重复之前的测试操作,减少不必要的时间投入,以及校验功能的可用性.但是目前元素定位是个问题(每次页面有修改都要重设某些元素定位) 测试分类: 一. ...
- nightwatch 基于Webdriver的端到端自动化测试框架
nightwatch 是使用nodejs编写的,基于Webdriver api 的端到端自动化测试框架 包含以下特性 清晰的语法,基于js 以及css 还有xpath 的选择器 内置测试runner, ...
- pc端和android端应用程序测试有什么区别?(ps面试题)
pc端和android端应用程序测试有什么区别?(ps面试题) [VIP7]大连-凭海临风(215687736) 2014/4/10 8:56:171.测试环境不同PC平台一般都是windows an ...
- 移动web开发之移动端真机测试
× 目录 [1]特性 [2]安装 [3]设置[4]移动端 前面的话 chrome的开发者工具可以很好地做好模拟工作,但毕竟模拟和实际还是有差别的.所以,真机测试是一定要做的,如何高效地进行真机测试呢. ...
- 端到端测试工具--testcafe
写在前面 随着业务的增加,复杂性的增加,我们更需要保证页面不能出错,之前需要每次上线之前需要每次人工测试,如果有好多改动,为保证业务不出错,需要耗费更多的时间来测试,所以我们需要写一些测试来保证业务的 ...
- cypress 端到端测试框架试用
cypress 包含的特性 端到端测试 集成测试 单元测试 安装 yarn add cypress --dev 运行测试项目 初始化项目 yarn init -y 安装cypress yarn add ...
- 前端端对端测试:基于PhantomJS的CasperJS
简介 Casperjs是一个基于PhantomJS和SlimerJS的前端端对端测试框架,当然你也可以使用它完成网络爬虫功能,它的特点的通过简单的脚本模拟浏览器行为, 主要有casper.tester ...
- socket服务端开发之测试使用threading和gevent框架
socket服务端开发之测试使用threading和gevent框架 话题是测试下多线程和gevent在socket服务端的小包表现能力,测试的方法不太严谨,也没有用event loop + pool ...
随机推荐
- poj 2255 Tree Recovery(求后序遍历,二叉树)
版权声明:本文为博主原创文章,未经博主同意不得转载.vasttian https://blog.csdn.net/u012860063/article/details/37699219 转载请注明出处 ...
- HTML5仿手机微信聊天界面
HTML5仿手机微信聊天界面 这篇文章主要为大家详细介绍了HTML5仿手机微信聊天界面的关键代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 给大家带来的是HTML5仿手机微信聊天界面, ...
- MySql数据库在NodeJS中简单的基本操作
阅读目录 一:连接数据库 二:数据的增删改查操作 2.1 数据库新增和查询数据 2.2 获取该数据的主键值 2.3 多语句查询 回到顶部 一:连接数据库 const mysql = require(' ...
- TPYBoard开发板搭建,实现隐秘通信
一.准备工作 lTPYBoard v102(简称v102) 1块 lTPYBoard v202(简称v202) 1块 l杜邦线.MicroUSB数据线 若干 (成本100元以内,某宝上可以买到) 附上 ...
- 在C#/.NET应用程序开发中创建一个基于Topshelf的应用程序守护进程(服务)
本文首发于:码友网--一个专注.NET/.NET Core开发的编程爱好者社区. 文章目录 C#/.NET基于Topshelf创建Windows服务的系列文章目录: C#/.NET基于Topshelf ...
- Java面试准备之JVM
介绍JVM中7个区域,然后把每个区域可能造成内存的溢出的情况说明 程序计数器:看做当前线程所执行的字节码行号指示器.是线程私有的内存,且唯一一块不报OutOfMemoryError异常. Java虚拟 ...
- vue 2.0 + ElementUI构建树形表格
解决: 本来想在网上博客找一找解决方法,奈何百度到的结果都不尽人意,思维逻辑不清,步骤复杂,代码混乱,找了半天也没找到一个满意的,所以干脆就自己动手写一个 思路: table需要的数据是array,所 ...
- 使用反射动态调用ActiveX控件
使用反射动态调用ActiveX控件 袁永福 2018-3-2 ■■■■问题描述: 目前的基于.NET平台的软件研发中仍然存在大量的对COM及ActiveX控件的调用.使用C#调用ActiveX控件时一 ...
- vue axios封装以及登录token过期跳转问题
Axios配置JWT/封装插件/发送表单数据 首先请务必已仔细阅读 Axios 文档并熟悉 JWT: 中文文档 JWT 中文文档 安装 npm install axios npm install es ...
- apply和call与this
函数本身的apply方法,改变this指向哪个对象: function getAge() { var y = new Date().getFullYear(); return y - this.bir ...