Skip to content

Commit

Permalink
Merge pull request #3 from Codeception/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
Andrey authored Nov 23, 2016
2 parents a53b0bf + 34e701f commit dfcf5ae
Show file tree
Hide file tree
Showing 23 changed files with 473 additions and 46 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.4.9

* [SeleniumWebdriver][Protractor][WebDriverIO][Nightmare] fixed `executeScript`, `executeAsyncScript` to work and return values.
* [Protractor][SeleniumWebdriver][WebDriverIO] Added `waitForInvisible` and `waitForStalenessOf` methods by @Nighthawk14.
* Added `--config` option to `codeceptjs run` to manually specify config file by @cnworks
* [Protractor] Simplified behavior of `amOutsideAngularApp` by using `ignoreSynchronization`. Fixes #278
* Set exit code to 1 when test fails at `Before`/`After` hooks. Fixes #279


## 0.4.8

* [Protractor][SeleniumWebdriver][Nightmare] added `moveCursorTo` method.
Expand Down
25 changes: 25 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#### What are you trying to achieve?

#### What do you get instead?

> Provide console output if related. Use `--verbose` mode for more details.
```bash
# paste output here
```
> Provide test source code if related
```php
// paste test
```
### Details

* CodeceptJS version:
* NodeJS Version:
* Operating System:
* Protractor || WebDriverIO || Nightmare version (if related)
* Configuration file:

```js
# paste suite config here
```
1 change: 1 addition & 0 deletions bin/codecept.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ program.command('run [suite] [test]')
.option('--debug', 'output additional information')
.option('--verbose', 'output internal logging information')
.option('--profile [value]', 'configuration profile to be used')
.option('--config [file]', 'configuration file to be used')

// mocha options
.option('-c, --colors', 'force enabling of colors')
Expand Down
6 changes: 6 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Run test with internal logs printed (global promises, and events).
codeceptjs run . github_test.js --verbose
```

Select config file manually

```
codeceptjs run --config my.codecept.conf.js`
```

Run tests and produce xunit report:

```
Expand Down
32 changes: 32 additions & 0 deletions docs/helpers/Nightmare.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ Provided function should execute a passed callback (as first argument) to signal
**Parameters**

- `fn`
- `args` Examples for Vue.js.
In order to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).```js
I.executeAsyncScript(function(done) {
Vue.nextTick(done); // waiting for next tick
})
```By passing value to `done()` function you can return values.
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.```js
let val = yield I.executeAsyncScript(function(url, done) {
// in browser context
$.ajax(url, { success: (data) => done(data); }
}, 'http://ajax.callback.url/');
```Wrapper for asynchronous [evaluate](https://github.com/segmentio/nightmare#evaluatefn-arg1-arg2).
Unlike NightmareJS implementation calling `done` will return its first argument.
## executeScript
Expand All @@ -278,6 +291,25 @@ Pass arguments to function as additional parameters.
Will return execution result to a test.
In this case you should use generator and yield to receive results.
Example with jQuery DatePicker:
```js
// change date of jQuery DatePicker
I.executeScript(function() {
// now we are inside browser context
$('date')).datetimepicker('setDate', new Date());
});
```

Can return values. Don't forget to use `yield` to get them.

```js
let date = yield I.executeScript(function(el) {
// only basic types can be returned
return $(el)).datetimepicker('getDate').toString();
}, '#date'); // passing selector
```

**Parameters**

- `fn`
Expand Down
55 changes: 53 additions & 2 deletions docs/helpers/Protractor.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForInvisible

Waits for an element to become invisible on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForInvisible('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForStalenessOf

Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForStalenessOf('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForText

Waits for a text to appear (by default waits for 1sec).
Expand Down Expand Up @@ -354,6 +378,18 @@ Provided function should execute a passed callback (as first argument) to signal
**Parameters**

- `fn`
- `args` Examples for Vue.js.
In order to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).```js
I.executeAsyncScript(function(done) {
Vue.nextTick(done); // waiting for next tick
})
```By passing value to `done()` function you can return values.
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.```js
let val = yield I.executeAsyncScript(function(url, done) {
// in browser context
$.ajax(url, { success: (data) => done(data); }
}, 'http://ajax.callback.url/');
```
## executeScript
Expand All @@ -362,9 +398,24 @@ Pass arguments to function as additional parameters.
Will return execution result to a test.
In this case you should use generator and yield to receive results.
**Parameters**
Example with jQuery DatePicker:
- `fn`
```js
// change date of jQuery DatePicker
I.executeScript(function() {
// now we are inside browser context
$('date')).datetimepicker('setDate', new Date());
});
```

Can return values. Don't forget to use `yield` to get them.

```js
let date = yield I.executeScript(function(el) {
// only basic types can be returned
return $(el)).datetimepicker('getDate').toString();
}, '#date'); // passing selector
```

## fillField

Expand Down
56 changes: 56 additions & 0 deletions docs/helpers/SeleniumWebdriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This helper should be configured in codecept.json
- `restart` - restart browser between tests (default: true), if set to false cookies will be cleaned but browser window will be kept.
- `seleniumAddress` - Selenium address to connect (default: <http://localhost:4444/wd/hub>)
- `waitForTimeout`: (optional) sets default wait time in _ms_ for all `wait*` functions. 1000 by default;
- `scriptTimeout`: (optional) sets default timeout for scripts in `executeAsync`. 1000 by default.
- `manualStart` (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriverIO"]._startBrowser()`
- `capabilities`: {} - list of [Desired Capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities)

Expand Down Expand Up @@ -274,6 +275,18 @@ Provided function should execute a passed callback (as first argument) to signal
**Parameters**

- `fn`
- `args` Examples for Vue.js.
In order to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).```js
I.executeAsyncScript(function(done) {
Vue.nextTick(done); // waiting for next tick
})
```By passing value to `done()` function you can return values.
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.```js
let val = yield I.executeAsyncScript(function(url, done) {
// in browser context
$.ajax(url, { success: (data) => done(data); }
}, 'http://ajax.callback.url/');
```
## executeScript
Expand All @@ -282,6 +295,25 @@ Pass arguments to function as additional parameters.
Will return execution result to a test.
In this case you should use generator and yield to receive results.
Example with jQuery DatePicker:
```js
// change date of jQuery DatePicker
I.executeScript(function() {
// now we are inside browser context
$('date')).datetimepicker('setDate', new Date());
});
```

Can return values. Don't forget to use `yield` to get them.

```js
let date = yield I.executeScript(function(el) {
// only basic types can be returned
return $(el)).datetimepicker('getDate').toString();
}, '#date'); // passing selector
```

**Parameters**

- `fn`
Expand Down Expand Up @@ -622,6 +654,30 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForInvisible

Waits for an element to become invisible on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForInvisible('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForStalenessOf

Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForStalenessOf('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForText

Waits for a text to appear (by default waits for 1sec).
Expand Down
55 changes: 55 additions & 0 deletions docs/helpers/WebDriverIO.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,18 @@ Provided function should execute a passed callback (as first argument) to signal
**Parameters**

- `fn`
- `args` Examples for Vue.js.
In order to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).```js
I.executeAsyncScript(function(done) {
Vue.nextTick(done); // waiting for next tick
})
```By passing value to `done()` function you can return values.
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.```js
let val = yield I.executeAsyncScript(function(url, done) {
// in browser context
$.ajax(url, { success: (data) => done(data); }
}, 'http://ajax.callback.url/');
```
## executeScript
Expand All @@ -494,6 +506,25 @@ Pass arguments to function as additional parameters.
Will return execution result to a test.
In this case you should use generator and yield to receive results.
Example with jQuery DatePicker:
```js
// change date of jQuery DatePicker
I.executeScript(function() {
// now we are inside browser context
$('date')).datetimepicker('setDate', new Date());
});
```

Can return values. Don't forget to use `yield` to get them.

```js
let date = yield I.executeScript(function(el) {
// only basic types can be returned
return $(el)).datetimepicker('getDate').toString();
}, '#date'); // passing selector
```

**Parameters**

- `fn`
Expand Down Expand Up @@ -915,6 +946,30 @@ Element can be located by CSS or XPath.
- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForInvisible

Waits for an element to become invisible on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForInvisible('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForStalenessOf

Waits for an element to become not attached to the DOM on a page (by default waits for 1sec).
Element can be located by CSS or XPath.

I.waitForStalenessOf('#popup');

**Parameters**

- `locator` element located by CSS|XPath|strict locator
- `sec` time seconds to wait, 1 by default

## waitForText

Waits for a text to appear (by default waits for 1sec).
Expand Down
22 changes: 21 additions & 1 deletion docs/webapi/executeAsyncScript.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
Executes async script on page.
Provided function should execute a passed callback (as first argument) to signal it is finished.

@param fn
@param fn
@param args

Examples for Vue.js.
In order to make components completely rendered we are waiting for [nextTick](https://vuejs.org/v2/api/#Vue-nextTick).

```js
I.executeAsyncScript(function(done) {
Vue.nextTick(done); // waiting for next tick
})
```

By passing value to `done()` function you can return values.
Additional arguments can be passed as well, while `done` function is always last parameter in arguments list.

```js
let val = yield I.executeAsyncScript(function(url, done) {
// in browser context
$.ajax(url, { success: (data) => done(data); }
}, 'http://ajax.callback.url/');
```
21 changes: 20 additions & 1 deletion docs/webapi/executeScript.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@ Pass arguments to function as additional parameters.
Will return execution result to a test.
In this case you should use generator and yield to receive results.

@param fn
Example with jQuery DatePicker:

```js
// change date of jQuery DatePicker
I.executeScript(function() {
// now we are inside browser context
$('date')).datetimepicker('setDate', new Date());
});
```
Can return values. Don't forget to use `yield` to get them.

```js
let date = yield I.executeScript(function(el) {
// only basic types can be returned
return $(el)).datetimepicker('getDate').toString();
}, '#date'); // passing selector
```

@param `fn` function to be executed in browser context
@param `...args` args to be passed to function
Loading

0 comments on commit dfcf5ae

Please sign in to comment.