我如何设置 属性 strictFileInteractability
How can i set the Property strictFileInteractability
geckodriver 0.24.0 引入了 strictFileInteractability 功能,见下文,
但我还没有找到设置此功能的可能性。
代码试验:
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);
有人设法成功设置此功能吗?
变更日志:
github.com/mozilla/geckodriver/releases
w3c.github.io/webdriver/
GeckoDriver v0.24.0 向我们介绍了 strictFileInteractability
功能。
根据 WebDriver W3C Living Document 中的 Capabilities 部分:
Capability Key Value Type Description
---------- --- ---------- -----------
Strict file interactability "strictFileInteractability" boolean Defines the current session’s strict file interactability.
根据讨论 Add support for 'strictFileInteractability' W3C capability strictFileInteractability
capability was added from [java] Adding a type-safe option for strictFileInteractability capability 请求请求。
例子
使用 Java、Option
Class 和 Firefox:
代码块:
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();
控制台输出:
Google
使用 Java、DesiredCapabilities
Class 和 Firefox:
代码块:
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://whosebug.com");
System.out.println("Page Title is : "+driver.getTitle());
driver.quit();
控制台输出:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
geckodriver 0.24.0 引入了 strictFileInteractability 功能,见下文, 但我还没有找到设置此功能的可能性。
代码试验:
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);
有人设法成功设置此功能吗?
变更日志: github.com/mozilla/geckodriver/releases w3c.github.io/webdriver/
GeckoDriver v0.24.0 向我们介绍了 strictFileInteractability
功能。
根据 WebDriver W3C Living Document 中的 Capabilities 部分:
Capability Key Value Type Description
---------- --- ---------- -----------
Strict file interactability "strictFileInteractability" boolean Defines the current session’s strict file interactability.
根据讨论 Add support for 'strictFileInteractability' W3C capability strictFileInteractability
capability was added from [java] Adding a type-safe option for strictFileInteractability capability 请求请求。
例子
使用 Java、
Option
Class 和 Firefox:代码块:
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();
控制台输出:
Google
使用 Java、
DesiredCapabilities
Class 和 Firefox:代码块:
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://whosebug.com"); System.out.println("Page Title is : "+driver.getTitle()); driver.quit();
控制台输出:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers