Skip to content

Commit 7124642

Browse files
committed
updated waitUntilExists functionality
1 parent 2c6dd24 commit 7124642

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

docs/pageobjects.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,6 @@ At initialization you were asked to create custom steps file. If you accepted th
231231
See how `login` method can be added to `I`:
232232

233233
```js
234-
'use strict';
235-
// in this file you can append custom step methods to 'I' object
236-
237234
module.exports = function() {
238235
return actor({
239236

@@ -248,4 +245,36 @@ module.exports = function() {
248245

249246
Please notice that instead of `I` you should use `this` in current context.
250247

248+
## Dependency Injection
249+
250+
### Configuration
251+
252+
All objects described here are injected with Dependency Injection. The similar way it happens in AngularJS framework.
253+
If you want an object to be injected in scenario by its name add it to configuration:
254+
255+
```js
256+
"include": {
257+
"I": "./custom_steps.js",
258+
"Smth": "./pages/Smth.js",
259+
"loginPage": "./pages/Login.js",
260+
"signinFragment": "./fragments/Signin.js"
261+
}
262+
```
263+
264+
Now this objects can be retrieved by the name specified in configuration.
265+
CodeceptJS generator commands (like `codeceptjs gpo`) will update configuration for you.
266+
267+
### Dynamic Injection
268+
269+
You can inject objects per test by calling `injectDependencies` function on Scenario:
270+
271+
```js
272+
Scenario('search @grop', (I, Data) => {
273+
I.fillField('Username', Data.username);
274+
I.pressKey('Enter');
275+
}).injectDependencies({ Data: require('./data.js') });
276+
```
277+
278+
This requires `./data.js` module and assigns it to `Data` argument in a test.
279+
251280
### done()

docs/webapi/waitUntilExists.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Waits for element not to be present on page (by default waits for 1sec).
1+
Waits for element to be present on page (by default waits for 1sec).
22
Element can be located by CSS or XPath.
33

44
```js

lib/helper/WebDriverIO.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ class WebDriverIO extends Helper {
14251425
*/
14261426
async waitUntilExists(locator, sec = null) {
14271427
const aSec = sec || this.options.waitForTimeout;
1428-
return this.browser.waitForExist(locator, aSec * 1000);
1428+
return this.browser.waitForExist(withStrictLocator.call(this, locator), aSec * 1000);
14291429
}
14301430

14311431

@@ -1599,6 +1599,14 @@ class WebDriverIO extends Helper {
15991599
* Appium: support
16001600
*/
16011601
async waitForStalenessOf(locator, sec = null) {
1602+
return this.waitUntilNotExists(locator, sec);
1603+
}
1604+
1605+
/**
1606+
* {{> ../webapi/waitForStalenessOf }}
1607+
* Appium: support
1608+
*/
1609+
async waitUntilNotExists(locator, sec = null) {
16021610
const aSec = sec || this.options.waitForTimeout;
16031611
return this.browser.waitUntil(async () => {
16041612
const res = await this.browser.elements(withStrictLocator.call(this, locator));

0 commit comments

Comments
 (0)