zombie

zombie是一套強大的node.js套件,原則上他可以模擬操做browser來做到許多網頁測試,也有基本的dom處以方式,透過zombie可以達到許多網頁自動化的操作唷!

Github repository

https://github.com/assaf/zombie

Installation

npm install zombie

Sample Usage

這邊展示個操作的範例:

var Browser = require("zombie");

// Load the page from localhost
browser = new Browser()
browser.visit("http://www.google.com/", function () {
  //透過browser.html()可以取回當下瀏覽器的內容
  console.log(browser.html());
  console.log('======================================');
  //執行form submit的動作
  browser.
    fill("q", "zombie"). //在q的輸入欄位中輸入zombie這個單字
    pressButton("搜尋", //點選"搜尋"這個按鈕,送出查詢
    function() {
      //列出查詢後的結果
      console.log(browser.html());
    })
});

上面範例中顯示zombie可以操作頁面上的元件,包含按按鈕的動作,即使按鈕不是針對form的方式送出,也可以正常執行...

results matching ""

    No results matching ""