Typography

活版印字


  • Home
  • Archive
  • Categories
  • Tags
  •  

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo

第一個 WebdriverIO 自動化測試

Posted at 2016-04-23 前端測試  WebdriverIO auto testing 

實作

建立自動化測試專案

1
2
mkdir webdriverio-sandbox && cd webdriverio-sandbox
npm init -y

安裝 WebdriverIO

1
npm install webdriverio -D

撰寫第一個測試

1
2
3
4
5
6
7
8
9
10
11
12
var webdriverio = require('webdriverio');
var options = { desiredCapabilities: { browserName: 'chrome' } };
var client = webdriverio.remote(options);

client
.init()
.url('http://blog.mokayo.com/')
.getTitle().then(function(title) {
console.log('Title is: ' + title);
// Title is: 教你所想學的,用眼樂讀 - blog.mokayo.com
})
.end();

安裝 selenium standalone

因為底層是透過與 selenium 溝通去操作瀏覽器,所以請先安裝 selenium 並啟動它。

1
2
npm install selenium-standalone -g
selenium-standalone install

小提示
Selenium 執行需要 JDK

如何執行

啟動 selenium standalone

1
selenium-standalone start

啟動自動測試程式

1
node test.js

原始碼下載

相關資源

WebdriverIO 官網
Selenium standalone

Share 

 Previous post: 被討厭的勇氣 (重點 1) Next post: 自動化測試框架比較 with NodeJS 

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo