Skip to content

Commit

Permalink
update IE options class in each language to match the currently suppo…
Browse files Browse the repository at this point in the history
…rted capabilities in the IE Driver
  • Loading branch information
titusfortner committed Aug 20, 2021
1 parent 182aa41 commit fcbfb3a
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 16 deletions.
51 changes: 51 additions & 0 deletions dotnet/src/webdriver/IE/InternetExplorerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public class InternetExplorerOptions : DriverOptions
private const string ForceShellWindowsApiCapability = "ie.forceShellWindowsApi";
private const string FileUploadDialogTimeoutCapability = "ie.fileUploadDialogTimeout";
private const string EnableFullPageScreenshotCapability = "ie.enableFullPageScreenshot";
private const string EdgeExecutablePathCapability = "ie.edgepath";
private const string LegacyFileUploadDialogHandlingCapability = "ie.useLegacyFileUploadDialogHandling";
private const string AttachToEdgeChromeCapability = "ie.edgechromium";

private bool ignoreProtectedModeSettings;
private bool ignoreZoomLevel;
Expand All @@ -100,10 +103,13 @@ public class InternetExplorerOptions : DriverOptions
private bool usePerProcessProxy;
private bool ensureCleanSession;
private bool enableFullPageScreenshot = true;
private bool legacyFileUploadDialogHandling;
private bool attachToEdgeChrome;
private TimeSpan browserAttachTimeout = TimeSpan.MinValue;
private TimeSpan fileUploadDialogTimeout = TimeSpan.MinValue;
private string initialBrowserUrl = string.Empty;
private string browserCommandLineArguments = string.Empty;
private string edgeExecutablePathCapability = string.Empty;
private InternetExplorerElementScrollBehavior elementScrollBehavior = InternetExplorerElementScrollBehavior.Default;
private Dictionary<string, object> additionalInternetExplorerOptions = new Dictionary<string, object>();

Expand Down Expand Up @@ -131,6 +137,9 @@ public InternetExplorerOptions() : base()
this.AddKnownCapabilityName(EnsureCleanSessionCapability, "EnsureCleanSession property");
this.AddKnownCapabilityName(FileUploadDialogTimeoutCapability, "FileUploadDialogTimeout property");
this.AddKnownCapabilityName(EnableFullPageScreenshotCapability, "EnableFullPageScreenshot property");
this.AddKnownCapabilityName(LegacyFileUploadDialogHanldingCapability, "LegacyFileUploadDialogHanlding property");
this.AddKnownCapabilityName(AttachToEdgeChromeCapability, "AttachToEdgeChrome property");
this.AddKnownCapabilityName(EdgeExecutablePathCapability, "EdgeExecutablePath property");
}

/// <summary>
Expand Down Expand Up @@ -282,6 +291,33 @@ public bool EnsureCleanSession
set { this.ensureCleanSession = value; }
}

/// <summary>
/// Gets or sets a value indicating whether to use the legacy handling for file upload dialogs.
/// </summary>
public bool LegacyFileUploadDialogHanlding
{
get { return this.legacyFileUploadDialogHandling; }
set { this.legacyFileUploadDialogHandling = value; }
}

/// <summary>
/// Gets or sets a value indicating whether to attach to Edge Chrome browser.
/// </summary>
public bool AttachToEdgeChrome
{
get { return this.attachToEdgeChrome; }
set { this.attachToEdgeChrome = value; }
}

/// <summary>
/// Gets or sets the path to the Edge Browser Executable.
/// </summary>
public string EdgeExecutablePath
{
get { return this.edgeExecutablePath; }
set { this.edgeExecutablePath = value; }
}

/// <summary>
/// Provides a means to add additional capabilities not yet added as type safe options
/// for the Internet Explorer driver.
Expand Down Expand Up @@ -447,6 +483,21 @@ private Dictionary<string, object> BuildInternetExplorerOptionsDictionary()
internetExplorerOptionsDictionary[EnableFullPageScreenshotCapability] = false;
}

if (this.legacyFileUploadDialogHandling)
{
internetExplorerOptionsDictionary[LegacyFileUploadDialogHandling] = true;
}

if (this.attachToEdgeChrome)
{
internetExplorerOptionsDictionary[AttachToEdgeChrome] = true;
}

if (!string.IsNullOrEmpty(this.edgeExecutablePathCapability))
{
internetExplorerOptionsDictionary[EdgeExecutablePathCapability] = this.edgeExecutablePathCapability;
}

foreach (KeyValuePair<string, object> pair in this.additionalInternetExplorerOptions)
{
internetExplorerOptionsDictionary[pair.Key] = pair.Value;
Expand Down
23 changes: 20 additions & 3 deletions java/src/org/openqa/selenium/ie/InternetExplorerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public class InternetExplorerOptions extends AbstractDriverOptions<InternetExplo
private static final String FULL_PAGE_SCREENSHOT = "ie.enableFullPageScreenshot";
private static final String UPLOAD_DIALOG_TIMEOUT = "ie.fileUploadDialogTimeout";
private static final String FORCE_WINDOW_SHELL_API = "ie.forceShellWindowsApi";
private static final String VALIDATE_COOKIE_DOCUMENT_TYPE = "ie.validateCookieDocumentType";
private static final String LEGACY_FILE_UPLOAD_DIALOG_HANDLING = "ie.useLegacyFileUploadDialogHandling";
private static final String ATTACH_TO_EDGE_CHROME = "ie.edgechromium";
private static final String EDGE_EXECUTABLE_PATH = "ie.edgepath";

private static final List<String> CAPABILITY_NAMES = Arrays.asList(
BROWSER_ATTACH_TIMEOUT,
Expand All @@ -80,8 +82,11 @@ public class InternetExplorerOptions extends AbstractDriverOptions<InternetExplo
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
REQUIRE_WINDOW_FOCUS,
UPLOAD_DIALOG_TIMEOUT,
VALIDATE_COOKIE_DOCUMENT_TYPE,
NATIVE_EVENTS);
NATIVE_EVENTS,
LEGACY_FILE_UPLOAD_DIALOG_HANDLING,
ATTACH_TO_EDGE_CHROME,
EDGE_EXECUTABLE_PATH);


private final Map<String, Object> ieOptions = new HashMap<>();

Expand Down Expand Up @@ -213,6 +218,18 @@ public InternetExplorerOptions takeFullPageScreenshot() {
return amend(FULL_PAGE_SCREENSHOT, true);
}

public InternetExplorerOptions useLegacyUploadDialog() {
return amend(LEGACY_FILE_UPLOAD_DIALOG_HANDLING, true);
}

public InternetExplorerOptions attachToEdgeChrome() {
return amend(ATTACH_TO_EDGE_CHROME, true);
}

public InternetExplorerOptions withEdgeExecutablePath(String path) {
return amend(EDGE_EXECUTABLE_PATH, path);
}

private InternetExplorerOptions amend(String optionName, Object value) {
setCapability(optionName, value);
return this;
Expand Down
50 changes: 42 additions & 8 deletions py/selenium/webdriver/ie/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class Options(ArgOptions):
PERSISTENT_HOVER = 'enablePersistentHover'
REQUIRE_WINDOW_FOCUS = 'requireWindowFocus'
USE_PER_PROCESS_PROXY = 'ie.usePerProcessProxy'
VALIDATE_COOKIE_DOCUMENT_TYPE = 'ie.validateCookieDocumentType'
USE_LEGACY_FILE_UPLOAD_DIALOG_HANDLING = 'ie.useLegacyFileUploadDialogHandling'
ATTACH_TO_EDGE_CHROME = 'ie.edgechromium'
EDGE_EXECUTABLE_PATH = 'ie.edgepath'

def __init__(self):
super(Options, self).__init__()
Expand Down Expand Up @@ -289,20 +291,52 @@ def use_per_process_proxy(self, value: bool):
self._options[self.USE_PER_PROCESS_PROXY] = value

@property
def validate_cookie_document_type(self) -> bool:
""":Returns: The options Validate Cookie Document Type value """
return self._options.get(self.VALIDATE_COOKIE_DOCUMENT_TYPE)
def use_legacy_file_upload_dialog_handling(self) -> bool:
""":Returns: The options Use Legacy File Upload Dialog Handling value """
return self._options.get(self.USE_LEGACY_FILE_UPLOAD_DIALOG_HANDLING)

@validate_cookie_document_type.setter
def validate_cookie_document_type(self, value: bool):
@use_legacy_file_upload_dialog_handling.setter
def use_legacy_file_upload_dialog_handling(self, value: bool):
"""
Sets the options Validate Cookie Document Type value
Sets the options Use Legacy File Upload Dialog Handling value
:Args:
- value: boolean value
"""
self._options[self.VALIDATE_COOKIE_DOCUMENT_TYPE] = value
self._options[self.USE_LEGACY_FILE_UPLOAD_DIALOG_HANDLING] = value

@property
def attach_to_edge_chrome(self) -> bool:
""":Returns: The options Attach to Edge Chrome value """
return self._options.get(self.ATTACH_TO_EDGE_CHROME)

@attach_to_edge_chrome.setter
def attach_to_edge_chrome(self, value: bool):
"""
Sets the options Attach to Edge Chrome value
:Args:
- value: boolean value
"""
self._options[self.ATTACH_TO_EDGE_CHROME] = value

@property
def edge_executable_path(self) -> str:
""":Returns: The options Edge Executable Path value """
return self._options.get(self.EDGE_EXECUTABLE_PATH)

@edge_executable_path.setter
def edge_executable_path(self, value: str):
"""
Sets the options Initial Browser Url value
:Args:
- value: Path string
"""
self._options[self.EDGE_EXECUTABLE_PATH] = value

@property
def additional_options(self) -> dict:
Expand Down
4 changes: 3 additions & 1 deletion rb/lib/selenium/webdriver/ie/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class Options < WebDriver::Options
persistent_hover: 'enablePersistentHover',
require_window_focus: 'requireWindowFocus',
use_per_process_proxy: 'ie.usePerProcessProxy',
validate_cookie_document_type: 'ie.validateCookieDocumentType'
use_legacy_file_upload_dialog_handling: 'ie.useLegacyFileUploadDialogHandling',
attach_to_edge_chrome: 'ie.edgechromium',
edge_executable_path: 'ie.edgepath'
}.freeze
BROWSER = 'internet explorer'

Expand Down
16 changes: 12 additions & 4 deletions rb/spec/unit/selenium/webdriver/ie/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ module IE
persistent_hover: true,
require_window_focus: true,
use_per_process_proxy: true,
validate_cookie_document_type: true,
use_legacy_file_upload_dialog_handling: true,
attach_to_edge_chrome: true,
edge_executable_path: '/path/to/edge',
'custom:options': {foo: 'bar'})

expect(opts.args.to_a).to eq(%w[foo bar])
Expand All @@ -72,7 +74,9 @@ module IE
expect(opts.persistent_hover).to eq(true)
expect(opts.require_window_focus).to eq(true)
expect(opts.use_per_process_proxy).to eq(true)
expect(opts.validate_cookie_document_type).to eq(true)
expect(opts.use_legacy_file_upload_dialog_handling).to eq(true)
expect(opts.attach_to_edge_chrome).to eq(true)
expect(opts.edge_executable_path).to eq('/path/to/edge')
expect(opts.browser_name).to eq('internet explorer')
expect(opts.browser_version).to eq('11')
expect(opts.platform_name).to eq('win10')
Expand Down Expand Up @@ -142,7 +146,9 @@ module IE
persistent_hover: true,
require_window_focus: true,
use_per_process_proxy: true,
validate_cookie_document_type: true)
use_legacy_file_upload_dialog_handling: true,
attach_to_edge_chrome: true,
edge_executable_path: '/path/to/edge')

key = 'se:ieOptions'
expect(opts.as_json).to eq('browserName' => 'internet explorer',
Expand Down Expand Up @@ -171,7 +177,9 @@ module IE
'enablePersistentHover' => true,
'requireWindowFocus' => true,
'ie.usePerProcessProxy' => true,
'ie.validateCookieDocumentType' => true})
'ie.useLegacyFileUploadDialogHandling' => true,
'ie.edgechromium' => true,
'ie.edgepath' => '/path/to/edge'})
end
end
end # Options
Expand Down

0 comments on commit fcbfb3a

Please sign in to comment.