Skip to content
DialogCapabilities for have ability to work with OpenFileDialog and SaveFileDialog using SeleniumWebDriver
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


DialogCapabilities is a library for work with OpenFileDialog and SaveFileDialog.

Main idea is simple: to give an ability to work with system dialogs like OpenFileDialog and SaveFileDialog for SeleniumWebDriver users. SeleniumWebDriver by default have no abbility to perform any actions with them as this dialogs is related to OS, but not browser-related.

IMPORTANT 1: limits of lib

At the moment library works only with foreground dialogs. Background dialog windows supported only unofficially.

Also there can be mistakes in case of using few dialogs in the same time in one instance of OS.

Maybe later I will add support of search dialogs related to exact window. Maybe not.

IMPORTANT 2 : How to do not use this library

Even of this library is exist, prefer to use another ways if this is possible. This library was created for situations when you have no ability to use another way for some reason or if you don't want to.

Way 1: for visible file fields


<input type="file" id="uploadhere" />

Selenium Code

IWebElement element = driver.FindElement(By.Id("uploadhere"));

Way 2: for invisible fields

If input field is invisible, need to make it visible:

public void AttachFile(WebDriver driver, By locator, String file) {
  WebElement input = driver.findElement(locator);
  Unhide(driver, input);

private void Unhide(WebDriver driver, WebElement element) {
  String script = "arguments[0].style.opacity=1;"
	+ "arguments[0].style['transform']='translate(0px, 0px) scale(1)';"
	+ "arguments[0].style['MozTransform']='translate(0px, 0px) scale(1)';"
	+ "arguments[0].style['WebkitTransform']='translate(0px, 0px) scale(1)';"
	+ "arguments[0].style['msTransform']='translate(0px, 0px) scale(1)';"
	+ "arguments[0].style['OTransform']='translate(0px, 0px) scale(1)';"
	+ "return true;";
  ((JavascriptExecutor) driver).executeScript(script, element);

Way 3: for any fields

Send Post request with files to the site.

Samples of using the Lib

Add to using block:

using DialogCapabilities.Dialogs;


// for English Windows

//For windows with russian GUI
Dialogs.OpenFileDialog("Открыть", @"d:\test.txt");

MultiFile selection in OpenFileDialog:

var filePaths = new string[] {@"d:\test1.txt", @"d:\test2.txt", @"d:\test3.txt"};

//Or for Eng windows:

//for russian language OS
Dialogs.OpenFileDialog("Открыть", filePaths);


//for eng language OS

//for russian language OS
Dialogs.SaveFileDialog("Сохранить как", @"d:\test.txt");

Building of custom Dialogs:

public void CustomSaveFileDialog(string title, string file)
    var dialog = FormController.Catch(title);



Path you can find using Spy++ utility built in into Visual Studio

You can’t perform that action at this time.