diff --git a/lib/browser/commands/set-orientation/index.js b/lib/browser/commands/set-orientation/index.js index 4fb173ae..b44c2726 100644 --- a/lib/browser/commands/set-orientation/index.js +++ b/lib/browser/commands/set-orientation/index.js @@ -9,17 +9,17 @@ module.exports = (browser) => { } session.overwriteCommand('setOrientation', async (origSetOrientation, orientation) => { - const result = await origSetOrientation(orientation); - if (!config.waitOrientationChange) { - return result; + return origSetOrientation(orientation); } + const initialBodyWidth = await getBodyWidth(); + const result = await origSetOrientation(orientation); + if (typeof result === 'string' && result.match(/Already in/)) { return result; } - const initialBodyWidth = await getBodyWidth(); await waitForOrientationChange(initialBodyWidth, orientation); return result; diff --git a/test/lib/browser/commands/set-orientation/index.js b/test/lib/browser/commands/set-orientation/index.js index af2d5448..ba027526 100644 --- a/test/lib/browser/commands/set-orientation/index.js +++ b/test/lib/browser/commands/set-orientation/index.js @@ -60,14 +60,6 @@ describe('"setOrientation" command', () => { assert.notCalled(session.waitUntil); }); - - it('should not get initial body width', async () => { - await mkBrowser_().init(); - - await session.setOrientation('portrait'); - - assert.notCalled(session.execute); - }); }); it('should return changed orientation if it differs from the current one', async () => {