Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions docs/helpers/Appium.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
#### Parameters

- `select` field located by label|name|CSS|XPath|strict locator.
- `option` visible text or value of option.
Support only web testing!
- `option` visible text or value of option.- Supported on only for web testing!

### sendDeviceKeyEvent

Expand Down Expand Up @@ -960,6 +959,62 @@ Appium: support Android and iOS

- `actions`

### waitForElement

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

```js
I.waitForElement('.btn.continue');
I.waitForElement('.btn.continue', 5); // wait for 5 secs
```

#### Parameters

- `locator` element located by CSS|XPath|strict locator.
- `sec` (optional) time in seconds to wait, 1 by default.

### waitForInvisible

Waits for an element to be removed or 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` (optional) time in seconds to wait, 1 by default.

### waitForText

Waits for a text to appear (by default waits for 1sec).
Element can be located by CSS or XPath.
Narrow down search results by providing context.

```js
I.waitForText('Thank you, form has been submitted');
I.waitForText('Thank you, form has been submitted', 5, '#modal');
```

#### Parameters

- `text` to wait for.
- `sec` (optional) time in seconds to wait.
- `context` (optional) element located by CSS|XPath|strict locator.

### waitForVisible

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

I.waitForVisible('#popup');

#### Parameters

- `locator` element located by CSS|XPath|strict locator.
- `sec` (optional) time in seconds to wait, 1 by default.

[1]: http://codecept.io/helpers/WebDriver/

[2]: http://appium.io/
Expand Down
4 changes: 2 additions & 2 deletions docs/helpers/WebDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ I.waitForElement('.btn.continue', 5); // wait for 5 secs
#### Parameters

- `locator` element located by CSS|XPath|strict locator.
- `sec` (optional) time in seconds to wait, 1 by default.- _Appium_: supported
- `sec` (optional) time in seconds to wait, 1 by default.

### waitForEnabled

Expand Down Expand Up @@ -1385,7 +1385,7 @@ I.waitForText('Thank you, form has been submitted', 5, '#modal');

- `text` to wait for.
- `sec` (optional) time in seconds to wait.
- `context` (optional) element located by CSS|XPath|strict locator.- _Appium_: supported
- `context` (optional) element located by CSS|XPath|strict locator.

### waitForValue

Expand Down
41 changes: 39 additions & 2 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -1275,12 +1275,49 @@ class Appium extends Webdriver {

/**
* {{> ../webapi/selectOption }}
* Support only web testing!
*
* * Supported on only for web testing!
*/
async selectOption(select, option) {
if (this.isWeb) return super.selectOption(select, option);
throw new Error('Should be used only in Web context. In native context use \'click\' method instead');
}

/**
* {{> ../webapi/waitForElement }}
*
*/
async waitForElement(locator, sec = null) {
if (this.isWeb) return super.waitForElement(locator, sec);
return super.waitForElement(parseLocator.call(locator));
}

/**
* {{> ../webapi/waitForVisible }}
*
*/
async waitForVisible(locator, sec = null) {
if (this.isWeb) return super.waitForVisible(locator, sec);
return super.waitForVisible(parseLocator.call(locator));
}

/**
* {{> ../webapi/waitForInvisible }}
*
*/
async waitForInvisible(locator, sec = null) {
if (this.isWeb) return super.waitForInvisible(locator, sec);
return super.waitForInvisible(parseLocator.call(locator));
}

/**
* {{> ../webapi/waitForText }}
*
*/
async waitForText(text, sec = null, context = null) {
if (this.isWeb) return super.waitForText(text, sec, context);
return super.waitForText(text, sec, parseLocator.call(context));
}
}

function parseLocator(locator) {
Expand Down Expand Up @@ -1312,7 +1349,7 @@ function parseLocator(locator) {
}
}

locator = new Locator(locator);
locator = new Locator(locator, 'xpath');
if (locator.type === 'css' && !this.isWeb) throw new Error('Unable to use css locators in apps. Locator strategies for this request: xpath, id, class name or accessibility id');
if (locator.type === 'name' && !this.isWeb) throw new Error("Can't locate element by name in Native context. Use either ID, class name or accessibility id");
if (locator.type === 'id' && !this.isWeb && this.platform === 'android') return `//*[@resource-id='${locator.value}']`;
Expand Down
5 changes: 0 additions & 5 deletions lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1536,9 +1536,6 @@ class WebDriver extends Helper {

/**
* {{> ../webapi/waitForElement }}
*
*
* * *Appium*: supported
*/
async waitForElement(locator, sec = null) {
const aSec = sec || this.options.waitForTimeout;
Expand Down Expand Up @@ -1603,8 +1600,6 @@ class WebDriver extends Helper {
/**
* {{> ../webapi/waitForText }}
*
*
* * *Appium*: supported
*/
async waitForText(text, sec = null, context = null) {
const aSec = sec || this.options.waitForTimeout;
Expand Down