Skip to content

Commit 26633ff

Browse files
committed
added examples
1 parent b2449c0 commit 26633ff

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

examples/codecept.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tests": "./*_test.js",
3+
"timeout": 10000,
4+
"output": "./output",
5+
"helpers": {
6+
"WebDriverIO": {
7+
"url": "http://localhost",
8+
"browser": "firefox"
9+
}
10+
},
11+
"mocha": {},
12+
"name": "tests"
13+
}

examples/github_test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Feature('GitHub');
3+
4+
Before((I) => {
5+
I.amOnPage('https://github.com');
6+
})
7+
8+
Scenario('search', (I) => {
9+
I.fillField('Search GitHub','CodeceptJS');
10+
I.pressKey('Enter');
11+
I.see('Codeception/CodeceptJS', 'a');
12+
});
13+
14+
Scenario('signin', (I) => {
15+
I.click('Sign in');
16+
I.see('Sign in to GitHub');
17+
I.fillField('Username or email address', 'something@totest.com');
18+
I.fillField('Password', '123456');
19+
I.click('Sign in');
20+
I.see('Incorrect username or password.', '.flash-error');
21+
});

examples/pages/Admin.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
'use strict';
3+
4+
let I;
5+
6+
module.exports = {
7+
8+
_init() {
9+
I = require('codeceptjs/actor')();
10+
}
11+
12+
// insert your locators and methods here
13+
};

examples/user_helper.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
let Helper = require('../lib/helper');
3+
let assert = require('assert');
4+
5+
class User extends Helper {
6+
7+
// before/after hooks
8+
_before() {
9+
// remove if not used
10+
}
11+
12+
_after() {
13+
// remove if not used
14+
}
15+
16+
// add custom methods here
17+
// If you need to access other helpers
18+
// use: this.helpers['helperName']
19+
seeAuthentication() {
20+
return this.helpers['WebDriverIO'].browser.cookie(function (err, res) {
21+
let cookies = res.value;
22+
for (let k in cookies) {
23+
if (cookies[k].name !== 'logged_in') continue;
24+
assert.equal(cookies[k].value, 'yes');
25+
return;
26+
}
27+
assert.fail(cookies, 'logged_in', 'Auth cookie not set');
28+
});
29+
}
30+
}
31+
32+
module.exports = User;

0 commit comments

Comments
 (0)