fix NewCommandTimeout handling for freshly created sessions

This commit is contained in:
Jonah Stiennon 2016-01-20 11:50:09 -08:00
Родитель 17d512a21e
Коммит 72aeb807ad
2 изменённых файлов: 21 добавлений и 3 удалений

Просмотреть файл

@ -16,6 +16,10 @@ import util from 'util';
class AppiumDriver extends BaseDriver {
constructor (args) {
super();
// the main Appium Driver has no new command timeout
this.newCommandTimeoutMs = 0;
this.args = args;
this.sessions = {};
@ -110,12 +114,17 @@ class AppiumDriver extends BaseDriver {
.catch(B.CancellationError, () => {})
.catch((err) => {
log.warn(`Closing session, cause was '${err.message}'`);
log.info(`Removing session ${innerSessionId} from our master session list`);
delete this.sessions[innerSessionId];
})
.done();
log.info(`New ${InnerDriver.name} session created successfully, session ` +
`${innerSessionId} added to master session list`);
// set the New Command Timeout for the inner driver
d.startNewCommandTimeout();
return [innerSessionId, dCaps];
}
@ -155,9 +164,6 @@ class AppiumDriver extends BaseDriver {
return super.executeCommand(cmd, ...args);
}
// since we don't call super.executeCommand, we need
// to clear the appium driver timeout manually
this.clearNewCommandTimeout();
let sessionId = args[args.length - 1];
return this.sessions[sessionId].executeCommand(cmd, ...args);
}

Просмотреть файл

@ -66,5 +66,17 @@ describe('FakeDriver - via HTTP', () => {
await driver2.init(caps).should.eventually.be.rejected;
await driver1.quit();
});
it('should use the newCommandTimeout of the inner Driver on session creation', async () => {
let driver = wd.promiseChainRemote(TEST_HOST, TEST_PORT);
caps.newCommandTimeout = 0.25;
let [sessionId] = await driver.init(caps);
should.exist(sessionId);
await B.delay(250);
await driver.source().should.eventually.be.rejectedWith(/terminated/);
});
});
});