by alincode
mkdir ctjs-webdriverio-sandbox
cd ctjs-webdriverio-sandbox
npm init -y
npm i webdriverio -D
npm i wdio-selenium-standalone-service -D
./node_modules/webdriverio/bin/wdio
capabilities: [{
browserName: 'chrome'
}],
services: ['selenium-standalone'],
mochaOpts: {
timeout: 60000
},
mkdir -p ./test/specs/
mkdir -p ./errorShots/
browser.click('.open-panel');
Click
doubleClick
setValue
submitForm
var title = browser.getTitle();
getTitle
getText
getValue
getText
assert.equal(title, '教你所想學的,用眼樂讀 - blog.mokayo.com');
equal
exist
length
match
var assert = require('assert');
describe('mokayo page', function() {
it('should have the right title', function() {
browser.url('http://blog.mokayo.com');
var title = browser.getTitle();
assert.equal(title, '教你所想學的,用眼樂讀 - blog.mokayo.com');
});
});
describe('正常登入流程', function() {
it('前往登入頁', function(done) {
browser.url('/');
browser.click('.open-panel');
browser.click('[href*=login]');
browser.waitForExist('[name=identifier]');
browser.getText('.login-screen-title').should.be.equal(
'Login');
});
it('填寫登入資料並送出', function(done) {
browser.elements('[name=identifier]').setValue('demo');
browser.elements('[name=password]').setValue('11111111');
browser.click('[type=submit]');
browser.isExisting('[name=identifier]', false).should.be.equal(
true);
});
it('登入成功', function(done) {
browser.pause(2000);
browser.click('.open-panel');
browser.waitForExist('[href*=logout]');
browser.isExisting('[href*=logout]').should.be.equal(true);
});
});
前往登入頁
填寫登入資料並送出
登入成功