Skip to content

Commit 5c4d78b

Browse files
committed
Allow IE driver to work with transparent file upload elements.
Many modern JavaScript widget frameworks hide <input type="file"> elements so as to make their UIs "prettier." The IE driver would see these elements as not visible, and thus not interactible. This commit allows users to use sendKeys to upload files when this type of file upload element exists, bringing the driver in line with what is allowed by the Firefox driver.
1 parent 04e6815 commit 5c4d78b

File tree

7 files changed

+1631
-1617
lines changed

7 files changed

+1631
-1617
lines changed

cpp/iedriver/CommandHandlers/SendKeysCommandHandler.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,6 @@ class SendKeysCommandHandler : public IECommandHandler {
8080
status_code = this->GetElement(executor, element_id, &element_wrapper);
8181

8282
if (status_code == WD_SUCCESS) {
83-
bool displayed;
84-
status_code = element_wrapper->IsDisplayed(true, &displayed);
85-
if (status_code != WD_SUCCESS || !displayed) {
86-
response->SetErrorResponse(EELEMENTNOTDISPLAYED,
87-
"Element is not displayed");
88-
return;
89-
}
90-
91-
if (!element_wrapper->IsEnabled()) {
92-
response->SetErrorResponse(EELEMENTNOTENABLED,
93-
"Element is not enabled");
94-
return;
95-
}
96-
9783
CComPtr<IHTMLElement> element(element_wrapper->element());
9884

9985
LocationInfo location = {};
@@ -147,6 +133,20 @@ class SendKeysCommandHandler : public IECommandHandler {
147133
return;
148134
}
149135

136+
bool displayed;
137+
status_code = element_wrapper->IsDisplayed(true, &displayed);
138+
if (status_code != WD_SUCCESS || !displayed) {
139+
response->SetErrorResponse(EELEMENTNOTDISPLAYED,
140+
"Element is not displayed");
141+
return;
142+
}
143+
144+
if (!element_wrapper->IsEnabled()) {
145+
response->SetErrorResponse(EELEMENTNOTENABLED,
146+
"Element is not enabled");
147+
return;
148+
}
149+
150150
if (!this->VerifyPageHasFocus(top_level_window_handle, window_handle)) {
151151
LOG(WARN) << "HTML rendering pane does not have the focus. Keystrokes may go to an unexpected UI element.";
152152
}

cpp/iedriver/Generated/atoms.h

Lines changed: 1606 additions & 1602 deletions
Large diffs are not rendered by default.

cpp/iedriverserver/CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ available via the project downloads page. Changes in "revision" field indicate
99
private releases checked into the prebuilts directory of the source tree, but
1010
not made generally available on the downloads page.
1111

12+
v2.45.0.6
13+
=========
14+
* Updates to JavaScript automation atoms.
15+
* Allow IE driver to work with transparent file upload elements. Many modern
16+
JavaScript widget frameworks hide <input type="file"> elements so as to
17+
make their UIs "prettier." The IE driver would see these elements as not
18+
visible, and thus not interactible. This commit allows users to use sendKeys
19+
to upload files when this type of file upload element exists, bringing the
20+
driver in line with what is allowed by the Firefox driver.
21+
1222
v2.45.0.5
1323
=========
1424
* Changed to allow interaction with elements where opacity = 0. The
0 Bytes
Binary file not shown.
1 KB
Binary file not shown.
1 KB
Binary file not shown.

dotnet/test/common/UploadTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void ShouldAllowFileUploading()
4646
[Test]
4747
[Category("Javascript")]
4848
[IgnoreBrowser(Browser.WindowsPhone, "Does not yet support file uploads")]
49-
[IgnoreBrowser(Browser.IE, "Transparent file upload element not yet handled")]
49+
//[IgnoreBrowser(Browser.IE, "Transparent file upload element not yet handled")]
5050
public void ShouldAllowFileUploadingUsingTransparentUploadElement()
5151
{
5252
driver.Url = transparentUploadPage;

0 commit comments

Comments
 (0)