Skip to content

Commit 36ddcc9

Browse files
authored
make timeout override to be partial and enable enable check exclusion. (#79)
* make timeout override to be partial and enable enable check exclusion. * remove depricated bindings and update methods. add fix for #80 * move wait-on installation to last stage. * instal wait-on in bootstrap and use absolute path to run wait-on * add await for async function - getPluginProperties()
1 parent 641472a commit 36ddcc9

File tree

9 files changed

+1018
-1637
lines changed

9 files changed

+1018
-1637
lines changed

.azure-template/bootstrap.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ steps:
66
npm config delete prefix
77
npm config set prefix $NVM_DIR/versions/node/`node --version`
88
node --version
9-
npm install -g appium@next
9+
npm install -g appium@next
10+
npm install -g wait-on

README.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<br>
88
<br>
99
</h1>
10-
1110
This is an Appium plugin designed to wait for element to be present.
1211

1312
## Prerequisite
@@ -16,6 +15,15 @@ Appium version 2.0
1615

1716
Tested with appium v2.0.0-beta.42
1817

18+
### From Verion 2.0.0
19+
* Following bindings are not supported
20+
- `sessionId/waitplugin/timeout`
21+
- `sessionId/waitplugin/getTimeout`
22+
* Following command are renamed
23+
- `plugin: getWaitTimeout` is renamed to `plugin: getWaitPluginProperties`
24+
- `plugin: getWaitTimeout` is renamed to `plugin: setWaitPluginProperties`
25+
26+
1927
## Installation - Server
2028

2129
Install the plugin using Appium's plugin CLI, either as a named plugin or via NPM:
@@ -41,7 +49,8 @@ appium --use-plugins=element-wait
4149
To override the default element-wait retry
4250
1. Use appium server CLI
4351
--plugin-element-wait-timeout=30000
44-
--plugin-element-wait-interval-between-attempts=200
52+
--plugin-element-wait-interval-between-attempts=200
53+
--plugin-element-wait-element-enabled-check-exclusion-cmds-list=['click']
4554

4655

4756
2. Use appium server config file. [Refer](https://github.com/AppiumTestDistribution/appium-wait-plugin/blob/main/server-config.json).
@@ -69,23 +78,37 @@ driver.findElementByAccessibilityId("login").sendKeys('Hello');
6978
```
7079
## Configure Wait timeout in test
7180

81+
While overriding timeouts one can choose to override all or one of the below
82+
* timeout
83+
* intervalBetweenAttempts
84+
7285
WDIO Example
7386

7487
```
75-
await driver.executeScript('plugin: setWaitTimeout', [
88+
await driver.executeScript('plugin: setWaitPluginProperties', [
7689
{
7790
timeout: 1111,
7891
intervalBetweenAttempts: 11,
7992
},
8093
]);
8194
82-
await driver.executeScript('plugin: getWaitTimeout', [])
95+
await driver.executeScript('plugin: getWaitPluginProperties', [])
96+
```
97+
or
98+
```
99+
await driver.executeScript('plugin: setWaitPluginProperties', [
100+
{
101+
timeout: 1111,
102+
},
103+
]);
104+
105+
await driver.executeScript('plugin: getWaitPluginProperties', [])
83106
```
84107

85108
Java Example
86109

87110
```
88-
driver.executeScript("plugin: setWaitTimeout", ImmutableMap.of("timeout", 1111 , "intervalBetweenAttempts", 11 ));
111+
driver.executeScript("plugin: setWaitPluginProperties", ImmutableMap.of("timeout", 1111 , "intervalBetweenAttempts", 11 ));
89112
```
90113

91114
Server logs will be as below:
@@ -101,3 +124,22 @@ Server logs will be as below:
101124
[Plugin [element-wait (sessionless)]] Checking if login element is displayed
102125
[Plugin [element-wait (sessionless)]] login element is displayed.
103126
```
127+
128+
## Skip element Enabled Check for commands
129+
Before performing actions such as `click`, `setValue`, `clear` etc, plugin waits for element to be enabled.
130+
As mentioned in [#78](https://github.com/AppiumTestDistribution/appium-wait-plugin/issues/78) if there is a need to skip the `elementEnabled` check for a set of commands, `excludeEnabledCheck` can be sent along with timeout values.
131+
##### Usage
132+
wdio
133+
```
134+
await driver.executeScript('plugin: setWaitPluginProperties', [
135+
{
136+
timeout: 1111,
137+
intervalBetweenAttempts: 11,
138+
excludeEnabledCheck: ['click','setValue']
139+
},
140+
]);
141+
142+
await driver.executeScript('plugin: getWaitPluginProperties', [])
143+
```
144+
145+
By default `excludeEnabledCheck` is empty list.

__tests__/e2e/plugin.spec.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ should = chai.should();
99
let expect = chai.expect;
1010

1111
const APPIUM_HOST = '127.0.0.1';
12-
const DEFAULT_TIMEOUT_VALUE = { timeout: 10000, intervalBetweenAttempts: 500 };
12+
const DEFAULT_TIMEOUT_VALUE = {
13+
timeout: 10000,
14+
intervalBetweenAttempts: 500,
15+
excludeEnabledCheck: [],
16+
};
1317

1418
const androidApp = resolve('./build/VodQA.apk');
1519
const iosApp = resolve('./build/vodqa.zip');
@@ -34,7 +38,7 @@ const iOSCaps = {
3438
'appium:platformVersion': '16.2',
3539
'appium:app': iosApp,
3640
'appium:usePrebuiltWDA': true,
37-
'appium:wdaLaunchTimeout': 120000
41+
'appium:wdaLaunchTimeout': 120000,
3842
};
3943

4044
describe('Set Timeout', () => {
@@ -46,18 +50,18 @@ describe('Set Timeout', () => {
4650
capabilities: process.env.PLATFORM === 'android' ? androidCaps : iOSCaps,
4751
});
4852
});
49-
it('Should be able to set and get waitPlugin timeout', async () => {
50-
await driver.$('~login').click();
51-
expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include(
53+
it('Should be able to get default properties and override/get properties', async () => {
54+
expect(await driver.executeScript('plugin: getWaitPluginProperties', [])).to.deep.include(
5255
DEFAULT_TIMEOUT_VALUE
5356
);
54-
await driver.executeScript('plugin: setWaitTimeout', [
57+
await driver.$('~login').click();
58+
await driver.executeScript('plugin: setWaitPluginProperties', [
5559
{
5660
timeout: 1111,
5761
intervalBetweenAttempts: 11,
5862
},
5963
]);
60-
expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include({
64+
expect(await driver.executeScript('plugin: getWaitPluginProperties', [])).to.deep.include({
6165
timeout: 1111,
6266
intervalBetweenAttempts: 11,
6367
});

0 commit comments

Comments
 (0)