: - あなたがポップアップで動作することができます。このように
string currentHandle = driver.CurrentWindowHandle;
//Save the currently-focused window handle into a variable so that you can switch back to it later.
ReadOnlyCollection<string> originalHandles = driver.WindowHandles;
//Get the list of currently opened window handles.
// Now work here to open popups
// WebDriverWait.Until<T> waits until the delegate return the popup window handle.
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
string popupWindowHandle = wait.Until<string>((d) =>
{
string foundHandle = null;
// Subtract out the list of known handles. In the case of a single
// popup, the newHandles list will only have one value.
List<string> newHandles = driver.CurrentWindowHandles.Except(originalHandles).ToList();
if (newHandles.Count > 0)
{
foundHandle = newHandles[0];
}
return foundHandle;
});
driver.SwitchTo().Window(popupWindowHandle);
// Do whatever you need to on the popup browser, then...
driver.Close();
driver.SwitchToWindow(currentHandle);
...それはあなたを助けることを願っています。.. :)