* Creates a new WebDriver session. * * This function will always return a WebDriver instance. If there is an error * creating the session, such as the aforementioned SessionNotCreatedError, * the driver will have a rejected plain #getSession session promise. * This rejection wi
(executor, capabilities, onQuit = undefined)
| 717 | * @return {!WebDriver} The driver for the newly created session. |
| 718 | */ |
| 719 | static createSession(executor, capabilities, onQuit = undefined) { |
| 720 | let cmd = new command.Command(command.Name.NEW_SESSION) |
| 721 | |
| 722 | // For W3C remote ends. |
| 723 | cmd.setParameter('capabilities', { |
| 724 | firstMatch: [{}], |
| 725 | alwaysMatch: filterNonW3CCaps(capabilities), |
| 726 | }) |
| 727 | |
| 728 | let session = executeCommand(executor, cmd) |
| 729 | if (typeof onQuit === 'function') { |
| 730 | session = session.catch((err) => { |
| 731 | return Promise.resolve(onQuit.call(void 0)).then((_) => { |
| 732 | throw err |
| 733 | }) |
| 734 | }) |
| 735 | } |
| 736 | return new this(session, executor, onQuit) |
| 737 | } |
| 738 | |
| 739 | /** @override */ |
| 740 | async execute(command) { |
no test coverage detected