|
1 | 1 | import { remote } from 'webdriverio'; |
2 | | -import { command } from 'webdriver'; |
3 | 2 | import { pluginE2EHarness } from '@appium/plugin-test-support'; |
4 | 3 | import path from 'path'; |
5 | 4 | var chai = require('chai'), |
@@ -61,39 +60,17 @@ describe('Set Timeout', () => { |
61 | 60 | }); |
62 | 61 | beforeEach(async () => { |
63 | 62 | driver = await remote({ ...WDIO_PARAMS, capabilities }); |
64 | | - |
65 | | - driver.addCommand( |
66 | | - 'setWaitPluginTimeout', |
67 | | - command('POST', '/session/:sessionId/waitplugin/timeout', { |
68 | | - command: 'setWaitPluginTimeout', |
69 | | - parameters: [ |
70 | | - { |
71 | | - name: 'data', |
72 | | - type: 'object', |
73 | | - description: 'a valid parameter', |
74 | | - required: true, |
75 | | - }, |
76 | | - ], |
77 | | - }) |
78 | | - ); |
79 | | - driver.addCommand( |
80 | | - 'getWaitTimeout', |
81 | | - command('GET', '/session/:sessionId/waitplugin/getTimeout', { |
82 | | - command: 'getWaitTimeout', |
83 | | - parameters: [], |
84 | | - returns: { |
85 | | - type: 'object', |
86 | | - name: 'activity', |
87 | | - description: 'Name of the current activity', |
88 | | - }, |
89 | | - }) |
90 | | - ); |
91 | 63 | }); |
92 | 64 | it('Should be able to set and get waitPlugin timeout', async () => { |
93 | 65 | await driver.$('id=AlertButton'); |
94 | | - expect(await driver.getWaitTimeout()).to.deep.include(FAKE_ARGS); |
95 | | - await driver.setWaitPluginTimeout({ timeout: 1111, intervalBetweenAttempts: 11 }); |
96 | | - expect(await driver.getWaitTimeout()).to.deep.include({ |
| 66 | + expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include(FAKE_ARGS); |
| 67 | + await driver.executeScript('plugin: setWaitTimeout', [ |
| 68 | + { |
| 69 | + timeout: 1111, |
| 70 | + intervalBetweenAttempts: 11, |
| 71 | + }, |
| 72 | + ]); |
| 73 | + expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include({ |
97 | 74 | timeout: 1111, |
98 | 75 | intervalBetweenAttempts: 11, |
99 | 76 | }); |
@@ -129,42 +106,21 @@ describe('Set Timeout', () => { |
129 | 106 | }); |
130 | 107 | beforeEach(async () => { |
131 | 108 | driver = await remote({ ...WDIO_PARAMS, capabilities }); |
132 | | - |
133 | | - driver.addCommand( |
134 | | - 'setWaitPluginTimeout', |
135 | | - command('POST', '/session/:sessionId/waitplugin/timeout', { |
136 | | - command: 'setWaitPluginTimeout', |
137 | | - parameters: [ |
138 | | - { |
139 | | - name: 'data', |
140 | | - type: 'object', |
141 | | - description: 'a valid parameter', |
142 | | - required: true, |
143 | | - }, |
144 | | - ], |
145 | | - }) |
146 | | - ); |
147 | | - driver.addCommand( |
148 | | - 'getWaitTimeout', |
149 | | - command('GET', '/session/:sessionId/waitplugin/getTimeout', { |
150 | | - command: 'getWaitTimeout', |
151 | | - parameters: [], |
152 | | - returns: { |
153 | | - type: 'object', |
154 | | - name: 'activity', |
155 | | - description: 'Name of the current activity', |
156 | | - }, |
157 | | - }) |
158 | | - ); |
159 | 109 | }); |
| 110 | + |
160 | 111 | it('Should be able to set and get waitPlugin timeout', async () => { |
161 | 112 | await driver.$('#AlertButton'); |
162 | | - expect(await driver.getWaitTimeout()).to.deep.include({ |
| 113 | + expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include({ |
163 | 114 | timeout: 10000, |
164 | 115 | intervalBetweenAttempts: 500, |
165 | 116 | }); |
166 | | - await driver.setWaitPluginTimeout({ timeout: 1111, intervalBetweenAttempts: 11 }); |
167 | | - expect(await driver.getWaitTimeout()).to.deep.include({ |
| 117 | + await driver.executeScript('plugin: setWaitTimeout', [ |
| 118 | + { |
| 119 | + timeout: 1111, |
| 120 | + intervalBetweenAttempts: 11, |
| 121 | + }, |
| 122 | + ]); |
| 123 | + expect(await driver.executeScript('plugin: getWaitTimeout', [])).to.deep.include({ |
168 | 124 | timeout: 1111, |
169 | 125 | intervalBetweenAttempts: 11, |
170 | 126 | }); |
|
0 commit comments