客户感知软件测试系统,视觉感知测试 - 软件测试 - ITPUB论坛-专业的IT技术社区...

var wd = require('wd');

var chai = require("chai");

var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);

chai.should();

var ViffClient = require('viff-client');

chaiAsPromised.transferPromiseness = wd.transferPromiseness;

describe('Github Page Test', function() {

this.timeout(100000);

var browser, buildScreenshot, prodScreenshot, buildClient, prodClient;

before(function (done) {

browser = wd.promiseChainRemote('http://localhost:4444/wd/hub');

browser.init({ browserName: 'firefox' }).nodeify(done);

buildClient = new ViffClient('http://localhost:3000', {

name: 'build',

host: 'http://localhost:8000/example/build/github.html',

capabilities: 'firefox'

});

buildScreenshot = prepareTakeScreenshot(browser, buildClient);

prodClient = new ViffClient('http://localhost:3000', {

name: 'prod',

host: 'http://localhost:8000/example/prod/github.html',

capabilities: 'firefox'

});

prodScreenshot = prepareTakeScreenshot(browser, prodClient);

});

after(function (done) {

buildClient.generateReport(function () {

browser.quit().nodeify(done);

});

});

describe('in build environment', function() {

beforeEach(function(done) {

browser

.get("http://localhost:8000/example/build/github.html")

.waitForElementByCssSelector('.repo-list-item', browser.isDisplayed())

.nodeify(done);

});

it('could go to Home Page', function(done) {

browser.title().should.become("TJ Holowaychuk's Github Repositories")

.then(function () {

buildScreenshot({ 'Home Page': ['/github.html'] }, 'screenshots/homepage.png', done);

});

});

it('should filter repo as per keyword', function(done) {

browser

.elementByCssSelector('[type="search"]').type('commander.js')

.sleep(1000)

.elementsByCssSelector('.repo-list-item')

.then(function (elements) {

elements.length.should.eql(1);

buildScreenshot({ 'Search Result': ['/github.html'] }, 'screenshots/filter.png', done);

});

});

it('should open readme file', function(done) {

browser

.elementByCssSelector('.repo-list-item:nth-child(2)').click()

.waitForElementByCssSelector('.repo-readme', browser.isDisplayed())

.elementByCssSelector('.repo-readme').text().should.eventually.contain("# Co")

.then(function () {

buildScreenshot({ 'Should open readme file': ['/github.html'] }, 'screenshots/github.png', done);

});

});

});

describe('in prod environment', function() {     beforeEach(function(done) {

browser

.get("http://localhost:8000/example/prod/github.html")

.waitForElementByCssSelector('.repo-list-item', browser.isDisplayed())

.nodeify(done);

});

it('could go to Home Page', function(done) {

browser.title().should.become("TJ Holowaychuk's Github Repositories").then(function () {

prodScreenshot({ 'Home Page': ['/github.html'] }, 'screenshots/homepage.png', done);       });

});

it('should filter repo as per keyword', function(done) {

browser.elementByCssSelector('[type="search"]').type('commander.js')

.sleep(1000)

.elementsByCssSelector('.repo-list-item')

.then(function (elements) {

elements.length.should.eql(1);

prodScreenshot({ 'Search Result': ['/github.html'] }, 'screenshots/filter.png', done);

});

});

it('should open readme file', function(done) {

browser

.elementByCssSelector('.repo-list-item:nth-child(2)').click()

.waitForElementByCssSelector('.repo-readme', browser.isDisplayed())

.elementByCssSelector('.repo-readme').text().should.eventually.contain("# Co")

.then(function () {

prodScreenshot({ 'Should open readme file': ['/github.html'] }, 'screenshots/github.png', done);         });

});

});

});

function prepareTakeScreenshot(browser, viffClient) {

return function (url, imagePath, callback) {

browser

.saveScreenshot(imagePath)

.then(function () {

viffClient.post(url, imagePath, callback);

});

};

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值