Issue 7524 in selenium: IEDriver: Error determining if element is displayed

47 views
Skip to first unread message

sele...@googlecode.com

unread,
Jun 19, 2014, 2:05:59 PM6/19/14
to selenium-develope...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Status-Untriaged

New issue 7524 by amur...@softrek.com: IEDriver: Error determining if
element is displayed
http://code.google.com/p/selenium/issues/detail?id=7524

I have webdriver code like this:

wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("ElementToDisappear")));

I sometimes (1 out of 10 times) get an "unknown" error from the call to
isDisplayed(..) inside the invisiblity check
(line 459 of ExpectedConditions.java)

Here's a sample stack trace:

org.openqa.selenium.WebDriverException: Error determining if element is
displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 285 milliseconds Build info:
version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32' System
info: host: 'IE9Win7', ip: '192.168.13.196', os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_55' Session ID:
99247e66-e0a1-4074-a09e-fc64324d0c5f Driver info:
org.openqa.selenium.ie.InternetExplorerDriver Capabilities
[{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0,
ignoreZoomSetting=false, enablePersistentHover=true,
ie.ensureCleanSession=false, browserName=internet explorer,
enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss,
version=9, ie.usePerProcessProxy=false, cssSelectorsEnabled=true,
ignoreProtectedModeSettings=false, requireWindowFocus=false,
handlesAlerts=true, initialBrowserUrl=http://localhost:7179/,
ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0,
ie.browserCommandLineSwitches=, takesScreenshot=true}] Command duration or
timeout: 482 milliseconds Build info: version: '2.41.0',
revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27
11:29:39' System info: host: 'softrek-ci01.softrekdom1.local',
ip: '192.168.1.24', os.name: 'Linux', os.arch: 'amd64',
os.version: '2.6.32-358.el6.x86_64', java.version: '1.7.0_25' Session ID:
f15a6a4a-6645-4d72-897b-1aa7354ae0e6 Driver info:
org.openqa.selenium.remote.RemoteWebDriver Capabilities [{platform=WINDOWS,
javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false,
enablePersistentHover=true, ie.ensureCleanSession=false,
browserName=internet explorer, enableElementCacheCleanup=true,
unexpectedAlertBehaviour=dismiss,
webdriver.remote.sessionid=f15a6a4a-6645-4d72-897b-1aa7354ae0e6, version=9,
ie.usePerProcessProxy=false, cssSelectorsEnabled=true,
ignoreProtectedModeSettings=false, requireWindowFocus=false,
handlesAlerts=true, initialBrowserUrl=http://localhost:7179/,
ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0,
ie.browserCommandLineSwitches=, takesScreenshot=true}]
org.openqa.selenium.WebDriverException: Error determining if element is
displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 285 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27
17:17:32'
System info: host: 'IE9Win7', ip: '192.168.13.196', os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_55'
Session ID: 99247e66-e0a1-4074-a09e-fc64324d0c5f
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true,
elementScrollBehavior=0, ignoreZoomSetting=false,
enablePersistentHover=true, ie.ensureCleanSession=false,
browserName=internet explorer, enableElementCacheCleanup=true,
unexpectedAlertBehaviour=dismiss, version=9, ie.usePerProcessProxy=false,
cssSelectorsEnabled=true, ignoreProtectedModeSettings=false,
requireWindowFocus=false, handlesAlerts=true,
initialBrowserUrl=http://localhost:7179/, ie.forceCreateProcessApi=false,
nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=,
takesScreenshot=true}]
Command duration or timeout: 482 milliseconds
Build info: version: '2.41.0',
revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27
11:29:39'
System info: host: 'softrek-ci01.softrekdom1.local', ip: '192.168.1.24',
os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64',
java.version: '1.7.0_25'
Session ID: f15a6a4a-6645-4d72-897b-1aa7354ae0e6
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true,
elementScrollBehavior=0, ignoreZoomSetting=false,
enablePersistentHover=true, ie.ensureCleanSession=false,
browserName=internet explorer, enableElementCacheCleanup=true,
unexpectedAlertBehaviour=dismiss,
webdriver.remote.sessionid=f15a6a4a-6645-4d72-897b-1aa7354ae0e6, version=9,
ie.usePerProcessProxy=false, cssSelectorsEnabled=true,
ignoreProtectedModeSettings=false, requireWindowFocus=false,
handlesAlerts=true, initialBrowserUrl=http://localhost:7179/,
ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0,
ie.browserCommandLineSwitches=, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at
org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at
org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:320)
at
org.openqa.selenium.support.ui.ExpectedConditions$15.apply(ExpectedConditions.java:459)
at
org.openqa.selenium.support.ui.ExpectedConditions$15.apply(ExpectedConditions.java:455)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at
com.softrek.test.functional.dashboard.panel.Panel.waitForLoad(Panel.java:30)


I poked around in the IEDriver code and found that this error is coming
from line 58 in
cpp/iedriver/CommandHandlers/IsElementDisplayedCommandHandler.h
I think it's caused by the element in question being removed from the dom
exactly at the moment between GetElement and IsDisplayed; I would expect a
stale element error to be thrown instead of an unknown error.

I forked and made what I think would be a suitable improvement to better
identify a stale or not found element when situations like this happen.

See
https://github.com/amuraco/selenium/commit/7a8c291b0b24f473be6c9290a0225e6c1c4b1eba
I do not have the necessary toolchain to be able to recompile and test
this, but hopefully that commit is illustrative for the explaining what
could be improved.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

sele...@googlecode.com

unread,
Jun 23, 2014, 4:06:02 PM6/23/14
to selenium-develope...@googlegroups.com
Updates:
Cc: james.h....@gmail.com
Labels: Browser-IE

Comment #1 on issue 7524 by barancev: IEDriver: Error determining if
(No comment was entered for this change.)

sele...@googlecode.com

unread,
Jun 23, 2014, 7:28:07 PM6/23/14
to selenium-develope...@googlegroups.com

Comment #2 on issue 7524 by amur...@softrek.com: IEDriver: Error
determining if element is displayed
http://code.google.com/p/selenium/issues/detail?id=7524

Here's a test case that usually triggers the error, again it's not entirely
deterministic which is what the patch should make much better.

sele...@googlecode.com

unread,
Jun 23, 2014, 7:29:07 PM6/23/14
to selenium-develope...@googlegroups.com

Comment #3 on issue 7524 by amur...@softrek.com: IEDriver: Error
determining if element is displayed
http://code.google.com/p/selenium/issues/detail?id=7524

Here's a short test case (refer to the jsfiddle for a short javascript
script that redraws 100 nodes every 100ms.
@Test
public void testIsDisplayed() {
driver.get("http://jsfiddle.net/ARG6X/show/light/");
for (int i = 0; i < 100; i++) {
try {
driver.findElement(By.className("item" + i)).isDisplayed();
} catch (StaleElementReferenceException | NotFoundException e) {
//I expect these

sele...@googlecode.com

unread,
Jul 16, 2014, 12:21:04 PM7/16/14
to selenium-develope...@googlegroups.com

Comment #4 on issue 7524 by charles....@gmail.com: IEDriver: Error
determining if element is displayed
http://code.google.com/p/selenium/issues/detail?id=7524

We're seeing this issue as well. We have some abstraction around a
WebDriver in our framework, and we're adding a temporary workaround to
catch a WebDriverException for InternetExplorer only, then try again.

Retries are generally a horrible idea, but we need consistent tests (and
can't wait for the fix), hence the workaround.

sele...@googlecode.com

unread,
Jul 28, 2014, 8:31:11 AM7/28/14
to selenium-develope...@googlegroups.com

Comment #5 on issue 7524 by amur...@softrek.com: IEDriver: Error
determining if element is displayed
http://code.google.com/p/selenium/issues/detail?id=7524

any update from the selenium team about including this minor
improvement/fix?

sele...@googlecode.com

unread,
Sep 2, 2014, 9:44:38 AM9/2/14
to selenium-develope...@googlegroups.com

Comment #6 on issue 7524 by tim.romb...@gmail.com: IEDriver: Error
determining if element is displayed
https://code.google.com/p/selenium/issues/detail?id=7524

I've just noticed that in many cases, when this exception occurs, a warning
message popup appears in the browser. Title 'message from webpage', message
<Current URL>:Permission denied. Since after clicking OK, the browser
immediately closes, I was not able to get a JS stacktrace on this message
yet.

sele...@googlecode.com

unread,
Dec 4, 2014, 11:33:21 AM12/4/14
to selenium-develope...@googlegroups.com

Comment #7 on issue 7524 by amur...@softrek.com: IEDriver: Error
Any update on this issue?

sele...@googlecode.com

unread,
Jul 2, 2015, 12:31:15 PM7/2/15
to selenium-develope...@googlegroups.com

Comment #8 on issue 7524 by lorenjoh...@gmail.com: IEDriver: Error
I'm seeing a similar problem with the Python bindings while using explicit
waiting for an element to be visible after loading a page. I only see this
issue with IEdriver and only intermittently.

WebDriverWait(mg.driver, timeout).until(condition)
/Library/Python/2.7/site-packages/selenium/webdriver/support/wait.py:66: in
until
value = method(self._driver)
/Library/Python/2.7/site-packages/selenium/webdriver/support/expected_conditions.py:72:
in
__call__
return _element_if_visible(_find_element(driver, self.locator))
/Library/Python/2.7/site-packages/selenium/webdriver/support/expected_conditions.py:90:
in
_element_if_visible
return element if element.is_displayed() else False
/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py:323:
in
is_displayed
return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']
/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py:402:
in
_execute
return self._parent.execute(command, params)
/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py:175:
in
execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at
0x103eacc10>
response = {'class': 'org.openqa.selenium.remote.Response', 'hCode':
9221641, 'sessionId': 'c91e1ef0-5fb8-41e5-97b7-543c80053a67', 'state': 'unhandled
error', ...}

def check_response(self, response):
"""
Checks that a JSON response from the WebDriver does not have an
error.

:Args:
- response - The JSON response from the WebDriver server as a
dictionary
object.

:Raises: If the response contains an error message.
"""
status = response['status']
if status == ErrorCode.SUCCESS:
return
exception_class = ErrorInResponseException
if status in ErrorCode.NO_SUCH_ELEMENT:
exception_class = NoSuchElementException
elif status in ErrorCode.NO_SUCH_FRAME:
exception_class = NoSuchFrameException
elif status in ErrorCode.NO_SUCH_WINDOW:
exception_class = NoSuchWindowException
elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
exception_class = StaleElementReferenceException
elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
exception_class = ElementNotVisibleException
elif status in ErrorCode.INVALID_ELEMENT_STATE:
exception_class = InvalidElementStateException
elif status in ErrorCode.INVALID_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
exception_class = InvalidSelectorException
elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
exception_class = ElementNotSelectableException
elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
exception_class = WebDriverException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = WebDriverException
elif status in ErrorCode.TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.SCRIPT_TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.UNKNOWN_ERROR:
exception_class = WebDriverException
elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
exception_class = UnexpectedAlertPresentException
elif status in ErrorCode.NO_ALERT_OPEN:
exception_class = NoAlertPresentException
elif status in ErrorCode.IME_NOT_AVAILABLE:
exception_class = ImeNotAvailableException
elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
exception_class = ImeActivationFailedException
elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
exception_class = MoveTargetOutOfBoundsException
else:
exception_class = WebDriverException
value = response['value']
if isinstance(value, basestring):
if exception_class == ErrorInResponseException:
raise exception_class(response, value)
raise exception_class(value)
message = ''
if 'message' in value:
message = value['message']

screen = None
if 'screen' in value:
screen = value['screen']

stacktrace = None
if 'stackTrace' in value and value['stackTrace']:
stacktrace = []
try:
for frame in value['stackTrace']:
line = self._value_or_default(frame, 'lineNumber', '')
file =
self._value_or_default(frame, 'fileName', '<anonymous>')
if line:
file = "%s:%s" % (file, line)
meth =
self._value_or_default(frame, 'methodName', '<anonymous>')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException and 'alert'
in value:
raise exception_class(message, screen, stacktrace,
value['alert'].get('text'))
> raise exception_class(message, screen, stacktrace)
E WebDriverException: Message: Error determining if element is
displayed (WARNING: The server did not provide any stacktrace information)
E Command duration or timeout: 97 milliseconds
E Build info: version: '2.46.0', revision: '87c69e2',
time: '2015-06-04 16:16:47'
E System info: host: 'IE11Win7', ip: '10.1.15.193', os.name: 'Windows
7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_45'
E Driver info: org.openqa.selenium.ie.InternetExplorerDriver
E Capabilities [{browserAttachTimeout=0, enablePersistentHover=false,
ie.forceCreateProcessApi=false, pageLoadStrategy=normal,
ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true,
version=11, platform=WINDOWS, nativeEvents=true,
ie.ensureCleanSession=false, elementScrollBehavior=0,
ie.browserCommandLineSwitches=, requireWindowFocus=false,
browserName=internet explorer, initialBrowserUrl=http://localhost:19898/,
takesScreenshot=true, javascriptEnabled=true,
ignoreProtectedModeSettings=false, enableElementCacheCleanup=true,
cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
E Session ID: 39e86eb8-a23e-4fce-84ef-ef24bd024268
E Screenshot: available via screen
E Stacktrace:
E at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(None:-2)
E at sun.reflect.NativeConstructorAccessorImpl.newInstance
(None:-1)
E at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(None:-1)
E at java.lang.reflect.Constructor.newInstance (None:-1)
E at org.openqa.selenium.remote.ErrorHandler.createThrowable
(ErrorHandler.java:204)
E at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed
(ErrorHandler.java:156)
E at org.openqa.selenium.remote.RemoteWebDriver.execute
(RemoteWebDriver.java:605)
E at org.openqa.selenium.remote.RemoteWebElement.execute
(RemoteWebElement.java:269)
E at org.openqa.selenium.remote.RemoteWebElement.isDisplayed
(RemoteWebElement.java:310)
E at sun.reflect.GeneratedMethodAccessor9.invoke (None:-1)
E at sun.reflect.DelegatingMethodAccessorImpl.invoke (None:-1)
E at java.lang.reflect.Method.invoke (None:-1)
E at
org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke
(EventFiringWebDriver.java:332)
E at com.sun.proxy.$Proxy2.isDisplayed (None:-1)
E at
org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.isDisplayed
(EventFiringWebDriver.java:386)
E at sun.reflect.GeneratedMethodAccessor9.invoke (None:-1)
E at sun.reflect.DelegatingMethodAccessorImpl.invoke (None:-1)
E at java.lang.reflect.Method.invoke (None:-1)
E at org.openqa.selenium.remote.server.KnownElements$1.invoke
(KnownElements.java:64)
E at com.sun.proxy.$Proxy3.isDisplayed (None:-1)
E at
org.openqa.selenium.remote.server.handler.GetElementDisplayed.call
(GetElementDisplayed.java:32)
E at
org.openqa.selenium.remote.server.handler.GetElementDisplayed.call
(GetElementDisplayed.java:1)
E at java.util.concurrent.FutureTask.run (None:-1)
E at org.openqa.selenium.remote.server.DefaultSession$1.run
(DefaultSession.java:176)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
E at java.lang.Thread.run (None:-1)

/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py:166:
WebDriverException
Reply all
Reply to author
Forward
0 new messages