Selenium WebDriver for C # - Popup Dialogs

Is there any support for working with pop-up dialogs (in particular, with downloading files) in C #?

+1
source share
3 answers

In the popup dialog box, you can use a warning for catch:

IAlert alert = driver.SwitchTo().Alert();
alert.Accept();
+3
source

From the WebDriver FAQ: WebDriver offers the ability to handle multiple windows. This is done using the "WebDriver.switchTo (). Window ()" method to switch to a window with a known name. If the name is unknown, you can use "WebDriver.getWindowHandles ()" to get a list of known windows. You can pass the handle "switchTo (). Window ()".

Full FAQ here.

Thoughtworks

 String parentWindowHandle = browser.getWindowHandle(); // save the current window handle.
      WebDriver popup = null;
      Iterator<String> windowIterator = browser.getWindowHandles();
      while(windowIterator.hasNext()) { 
        String windowHandle = windowIterator.next(); 
        popup = browser.switchTo().window(windowHandle);
        if (popup.getTitle().equals("Google") {
          break;
        }
      }

, Java # ( )

        String parentWindowHandle = _browser.CurrentWindowHandle; // save the current window handle.
        IWebDriver popup = null;
        var  windowIterator = _browser.WindowHandles;

        foreach (var windowHandle in windowIterator)
        {
            popup = _browser.SwitchTo().Window(windowHandle);

            if (popup.Title == "Google")
            {
                break;
            }
        }
+2

, - , .

WebDriver only interacts with a web page. The popup dialog after creating the instance becomes the domain of the operating system, not a web page.

You can bypass the file upload / download dialog by sending a POST or GET with the content you receive or send to the server.

You can use tools such as AutoIt or the Windows Automation API to interact with other dialog boxes.

+2
source

All Articles