Last active
May 1, 2020 14:27
-
-
Save jimevans/91249828e7a8fcb79922b12a1a72874d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sample assumes driver is a valid IWebDriver, and that | |
| // elementThatPopsUpNewTab is a valid, already located IWebElement | |
| // that, when clicked, follows a link that will open a new tab. | |
| IList<string> existingHandles = driver.WindowHandles; | |
| elementThatPopsUpNewTab.Click(); | |
| WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); | |
| string newTabHandle = wait.Until<string>((d) => | |
| { | |
| string foundHandle = null; | |
| IList<string> differentHandles = d.WindowHandles.Except(existingHandles).ToList(); | |
| if (differentHandles.Count > 0) | |
| { | |
| foundHandle = differentHandles[0]; | |
| } | |
| return foundHandle; | |
| }); | |
| driver.SwitchTo().Window(newTabHandle); |
Author
@MESWEB Then you'll need to provide some code of your own that uses a real site that is failing for you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code give me error: "Timed out after 5 seconds"