How can i set the Property strictFileInteractability

Viewed 855

geckodriver 0.24.0 introduces the capability strictFileInteractability see below, but I haven't found a possibility to set this capability.

Code trials:

FirefoxProfile profile=new FirefoxProfile();

// Has no effect
profile.setPreference("strictFileInteractability", true);

...

FirefoxOptions options = new FirefoxOptions();

// Has no effect
options.setCapability("strictFileInteractability", true);

...

DesiredCapabilities capabilities = DesiredCapabilities.firefox();

// Has no effect
capabilities.setCapability("strictFileInteractability", true);

Did someone manage to successfully set this capability?

Changelog: github.com/mozilla/geckodriver/releases w3c.github.io/webdriver/

1 Answers

GeckoDriver v0.24.0 introduced us to strictFileInteractability capability.

As per the Capabilities section within WebDriver W3C Living Document:

Capability                  Key                         Value Type  Description
----------                  ---                         ----------  -----------
Strict file interactability "strictFileInteractability" boolean     Defines the current session’s strict file interactability.

As per the discussion Add support for 'strictFileInteractability' W3C capability strictFileInteractability capability was added from [java] Adding a type-safe option for strictFileInteractability capability pull request.


Example

  • Using Java, Option Class and Firefox:

    • Code Block:

      System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");
      FirefoxOptions opt = new FirefoxOptions();
      opt.setCapability("strictFileInteractability", true);
      FirefoxDriver driver = new FirefoxDriver(opt);
      driver.get("https://www.google.com/");
      System.out.println(driver.getTitle());
      driver.quit();
      
    • Console Output:

      Google
      
  • Using Java, DesiredCapabilities Class and Firefox:

    • Code Block:

      System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");
      DesiredCapabilities dc = new DesiredCapabilities();
      dc.setCapability("strictFileInteractability", true);
      FirefoxOptions opt = new FirefoxOptions();
      opt.merge(dc);
      FirefoxDriver driver = new FirefoxDriver(opt);
      driver.get("https://stackoverflow.com");
      System.out.println("Page Title is : "+driver.getTitle());
      driver.quit();
      
    • Console Output:

      Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
      
Related