Skip to content

Commit 478b5f7

Browse files
committed
Fixing IE stale element detection for parent elements.
When calling element.findElement(s), if the parent element is stale, the IE driver was returning an "invalid argument" error. The W3C specification mandates that "stale element reference" is the correct error. Fixes issue #5700.
1 parent b337a82 commit 478b5f7

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

cpp/iedriver/CommandHandlers/FindChildElementCommandHandler.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ void FindChildElementCommandHandler::ExecuteInternal(
101101
return;
102102
}
103103
if (status_code == ENOSUCHWINDOW) {
104-
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to find element on closed window");
104+
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW,
105+
"Unable to find element on closed window");
105106
return;
106107
}
107108
if (status_code != ENOSUCHELEMENT) {
@@ -117,8 +118,13 @@ void FindChildElementCommandHandler::ExecuteInternal(
117118
response->SetErrorResponse(ERROR_NO_SUCH_ELEMENT,
118119
"Unable to find element with " + mechanism + " == " + value);
119120
} else {
120-
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Element is no longer valid");
121-
return;
121+
if (status_code == EOBSOLETEELEMENT) {
122+
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE,
123+
"Specified parent element is no longer attached to the DOM");
124+
} else {
125+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
126+
"Element is no longer valid");
127+
}
122128
}
123129
}
124130

cpp/iedriver/CommandHandlers/FindChildElementsCommandHandler.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ void FindChildElementsCommandHandler::ExecuteInternal(
101101
return;
102102
}
103103
} else if (status_code == ENOSUCHWINDOW) {
104-
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to find elements on closed window");
104+
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW,
105+
"Unable to find elements on closed window");
105106
return;
106107
} else {
107108
response->SetErrorResponse(status_code, found_elements.asString());
@@ -121,7 +122,13 @@ void FindChildElementsCommandHandler::ExecuteInternal(
121122
"returned an unexpected error");
122123
}
123124
} else {
124-
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Element is no longer valid");
125+
if (status_code == EOBSOLETEELEMENT) {
126+
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE,
127+
"Specified parent element is no longer attached to the DOM");
128+
} else {
129+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
130+
"Element is no longer valid");
131+
}
125132
}
126133
}
127134

cpp/iedriverserver/CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ 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+
v3.11.1.4
13+
=========
14+
* Fixed finding child elements to return proper error if parent element is
15+
stale. Fixes issue #5700.
16+
1217
v3.11.1.3
1318
=========
1419
* Fixed detection of obscured elements when top element is not displayed.

cpp/iedriverserver/IEDriverServer.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ END
5050
//
5151

5252
VS_VERSION_INFO VERSIONINFO
53-
FILEVERSION 3,11,1,3
54-
PRODUCTVERSION 3,11,1,3
53+
FILEVERSION 3,11,1,4
54+
PRODUCTVERSION 3,11,1,4
5555
FILEFLAGSMASK 0x3fL
5656
#ifdef _DEBUG
5757
FILEFLAGS 0x1L
@@ -68,12 +68,12 @@ BEGIN
6868
BEGIN
6969
VALUE "CompanyName", "Software Freedom Conservancy"
7070
VALUE "FileDescription", "Command line server for the IE driver"
71-
VALUE "FileVersion", "3.11.1.3"
71+
VALUE "FileVersion", "3.11.1.4"
7272
VALUE "InternalName", "IEDriverServer.exe"
7373
VALUE "LegalCopyright", "Copyright (C) 2017"
7474
VALUE "OriginalFilename", "IEDriverServer.exe"
7575
VALUE "ProductName", "Selenium WebDriver"
76-
VALUE "ProductVersion", "3.11.1.3"
76+
VALUE "ProductVersion", "3.11.1.4"
7777
END
7878
END
7979
BLOCK "VarFileInfo"
Binary file not shown.
2 KB
Binary file not shown.

0 commit comments

Comments
 (0)