-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address tab-related flakiness in integration tests (#2754)
* Redo webdriver tab stuff * whitespace * Cleanup * Wait on activation and controlling * Skip a test in Safari
- Loading branch information
1 parent
6581108
commit 9c15dc7
Showing
8 changed files
with
161 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2021 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
/** | ||
* Wraps methods in the underlying webdriver API to create, switch between, | ||
* and close tabs in a browser. | ||
*/ | ||
class TabManager { | ||
/** | ||
* @param {WebDriver} driver | ||
* | ||
* @private | ||
*/ | ||
constructor(driver) { | ||
this._driver = driver; | ||
this._openedHandles = new Set(); | ||
this._initialHandle = null; | ||
} | ||
|
||
async openTab(url) { | ||
if (this._initialHandle === null) { | ||
this._initialHandle = await this._driver.getWindowHandle(); | ||
} | ||
|
||
await this._driver.switchTo().newWindow('tab'); | ||
this._openedHandles.add(await this._driver.getWindowHandle()); | ||
|
||
await this._driver.get(url); | ||
} | ||
|
||
async closeOpenedTabs() { | ||
for (const handle of this._openedHandles) { | ||
await this._driver.switchTo().window(handle); | ||
await this._driver.close(); | ||
} | ||
this._openedHandles = new Set(); | ||
|
||
if (this._initialHandle) { | ||
await this._driver.switchTo().window(this._initialHandle); | ||
} | ||
} | ||
} | ||
|
||
module.exports = {TabManager}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.