Skip to content

Commit 7c73ba5

Browse files
authored
fix(appium): expose switchToContext (#4015)
1 parent c5f3d3d commit 7c73ba5

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

docs/helpers/Appium.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ let settings = await I.grabSettings();
440440

441441
Returns **[Promise][6]<[string][5]>** Appium: support Android and iOS
442442

443-
### \_switchToContext
443+
### switchToContext
444444

445445
Switch to the specified context.
446446

lib/helper/Appium.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Appium extends Webdriver {
368368
if (context.web) return this.switchToWeb(context.web);
369369
if (context.webview) return this.switchToWeb(context.webview);
370370
}
371-
return this._switchToContext(context);
371+
return this.switchToContext(context);
372372
}
373373

374374
_withinEnd() {
@@ -834,7 +834,7 @@ class Appium extends Webdriver {
834834
*
835835
* @param {*} context the context to switch to
836836
*/
837-
async _switchToContext(context) {
837+
async switchToContext(context) {
838838
return this.browser.switchContext(context);
839839
}
840840

@@ -858,11 +858,11 @@ class Appium extends Webdriver {
858858
this.isWeb = true;
859859
this.defaultContext = 'body';
860860

861-
if (context) return this._switchToContext(context);
861+
if (context) return this.switchToContext(context);
862862
const contexts = await this.grabAllContexts();
863863
this.debugSection('Contexts', contexts.toString());
864864
for (const idx in contexts) {
865-
if (contexts[idx].match(/^WEBVIEW/)) return this._switchToContext(contexts[idx]);
865+
if (contexts[idx].match(/^WEBVIEW/)) return this.switchToContext(contexts[idx]);
866866
}
867867

868868
throw new Error('No WEBVIEW could be guessed, please specify one in params');
@@ -885,8 +885,8 @@ class Appium extends Webdriver {
885885
this.isWeb = false;
886886
this.defaultContext = '//*';
887887

888-
if (context) return this._switchToContext(context);
889-
return this._switchToContext('NATIVE_APP');
888+
if (context) return this.switchToContext(context);
889+
return this.switchToContext('NATIVE_APP');
890890
}
891891

892892
/**

test/helper/AppiumV2_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ describe('Appium', function () {
171171
});
172172
});
173173

174-
describe('app context and activity: #_switchToContext, #switchToWeb, #switchToNative', () => {
174+
describe('app context and activity: #switchToContext, #switchToWeb, #switchToNative', () => {
175175
it('should switch context', async () => {
176176
await app.resetApp();
177177
await app.waitForElement('~buttonStartWebviewCD', smallWait);
178178
await app.click('~buttonStartWebviewCD');
179-
await app._switchToContext('WEBVIEW_io.selendroid.testapp');
179+
await app.switchToContext('WEBVIEW_io.selendroid.testapp');
180180
const val = await app.grabContext();
181181
return assert.equal(val, 'WEBVIEW_io.selendroid.testapp');
182182
});

test/helper/Appium_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ describe('Appium', function () {
168168
});
169169
});
170170

171-
describe('app context and activity: #_switchToContext, #switchToWeb, #switchToNative', () => {
171+
describe('app context and activity: #switchToContext, #switchToWeb, #switchToNative', () => {
172172
it('should switch context', async () => {
173173
await app.resetApp();
174174
await app.waitForElement('~buttonStartWebviewCD', smallWait);
175175
await app.click('~buttonStartWebviewCD');
176-
await app._switchToContext('WEBVIEW_io.selendroid.testapp');
176+
await app.switchToContext('WEBVIEW_io.selendroid.testapp');
177177
const val = await app.grabContext();
178178
return assert.equal(val, 'WEBVIEW_io.selendroid.testapp');
179179
});

typings/tests/helpers/Appium.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ appium.grabCurrentActivity(); // $ExpectType Promise<string>
3939
appium.grabNetworkConnection(); // $ExpectType Promise<{}>
4040
appium.grabOrientation(); // $ExpectType Promise<string>
4141
appium.grabSettings(); // $ExpectType Promise<string>
42-
appium._switchToContext(str); // $ExpectType void
42+
appium.switchToContext(str); // $ExpectType void
4343
appium.switchToWeb(); // $ExpectType Promise<void>
4444
appium.switchToNative(); // $ExpectType Promise<void>
4545
appium.switchToNative(str); // $ExpectType Promise<void>

typings/tests/helpers/AppiumTs.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ appium.grabCurrentActivity(); // $ExpectType Promise<string>
3939
appium.grabNetworkConnection(); // $ExpectType Promise<{}>
4040
appium.grabOrientation(); // $ExpectType Promise<string>
4141
appium.grabSettings(); // $ExpectType Promise<string>
42-
appium._switchToContext(str); // $ExpectType Promise<any>
42+
appium.switchToContext(str); // $ExpectType Promise<any>
4343
appium.switchToWeb(); // $ExpectType Promise<void>
4444
appium.switchToNative(); // $ExpectType Promise<void>
4545
appium.switchToNative(str); // $ExpectType Promise<void>

0 commit comments

Comments
 (0)