美文网首页
01. 什么是Nightwatch.js

01. 什么是Nightwatch.js

作者: KimYYX | 来源:发表于2017-10-16 11:11 被阅读0次

1. 介绍

Nightwatch.js 是基于 Node.jsWebDriverE2E 测试框架,以下是三段是官方给出的定义:

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.

Nightwatch.js is an automated testing framework for web applications and websites, written in Node.js and using the W3C WebDriver API (formerly Selenium WebDriver).

Nightwatch.js is a complete browser (End-to-End) testing solution which aims to simplify the process of setting up Continuous Integration and writing automated tests. Nightwatch can also be used for writing Node.js unit tests.

Keywords

2. 特点

  1. Clean syntax - 简洁的语法
  2. Built-in test runner - 自带测试环境
  3. Selenium server - 测试用的服务器,需要JRE
  4. Cloud services support - 支持云服务
  5. CSS & Xpath support - 支持CSS和XPATH选择器
  6. Continous integration support - 支持持续集成
  7. Easy to extend - 易于扩展

特点一般都是比较抽象的,不理解也没关系,我们可以从实践中慢慢体会。

3. Demo

我们来看下面的Demo找找感觉。看过之后,以前有写过测试的,应该会觉得很熟悉;没写过的,应该也能从方法名中推测出方法大体的作用。

module.exports = {
  'Demo test Google' : function (client) {
    client
      .url('http://www.google.com')
      .waitForElementVisible('body', 1000)
      .assert.title('Google')
      .assert.visible('input[type=text]')
      .setValue('input[type=text]', 'rembrandt van rijn')
      .waitForElementVisible('button[name=btnG]', 1000)
      .click('button[name=btnG]')
      .pause(1000)
      .assert.containsText('ol#rso li:first-child',
        'Rembrandt - Wikipedia')
      .end();
  }
};

在控制台执行命令后,会输出类似下面的结果


demo

4. Next

知道了 Nightwatch 的作用,下面我们去亲手搭建一个Nightwatch的Demo

相关文章

  • 01. 什么是Nightwatch.js

    1. 介绍 Nightwatch.js 是基于 Node.js 和 WebDriver 的 E2E 测试框架,以下...

  • 01.什么是RunLoop

    先上一张图,具体的runloop的解读后面再详细补充: 对于runloop的底层,GCD,timer等于runlo...

  • 01.什么是财务自由?

    阅读这篇文章你可以知道: 1、能不能毫无顾忌的选择自己喜欢的工作,不管它高薪还是底薪? 2、财务自由是什么?实现财...

  • 01. 什么是Pony ORM?

    01. 什么是Pony ORM? Pony是一个高级的对象关系映射器。ORM允许开发人员以对象的形式来处理数据库的...

  • 01.什么是领导力

    其实东西方的好多理念确实有差异,西方和你讲究理论逻辑上的,而东方更感性,所谓领导看“火候”“看气质”,不能说哪种更...

  • 01.什么是领导力 教科书

    【知识要点】 · 了解东西方对领导力的不同认识 · 掌握领导力在互联网时代的新变化 · 掌握游戏化组织的四个特征 ...

  • [区块链]01.什么是区块链

    一. 例说区块链   以前,农村里对出工或买卖种子肥料都会依靠一个账房先生来管账,但是这种一人掌握大权无人监督的情...

  • 打卡分享:01.什么是领导力

    【2018.8.30 董丹雯分享】 领导力是可以学会的。 柏拉图:逻辑教学,大前提,小前提,三段论(西方的思想)把...

  • 打卡分享01. 什么是领导力

    在我们大多数中国人的概念里,领导力是说不清道不明的,是天赋,领导力的传授要通过大量的经验实践,潜移默化,察言观色,...

  • 打卡分享. 01. 什么是领导力

    因为我自己是个不啰嗦的人,所以一直希望领导不要对我啰嗦,我也不喜欢对下属啰嗦。然而最近种种事情发生表明我交代工作时...

网友评论

      本文标题:01. 什么是Nightwatch.js

      本文链接:https://www.haomeiwen.com/subject/gohkuxtx.html