Skip to content

Commit ab1abaa

Browse files
Encode the isDisplayed atom and only load it once
The atom is only used in Safari so the conditional has been updated accordingly.
1 parent b448f83 commit ab1abaa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

py/selenium/webdriver/remote/webelement.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from io import BytesIO as IOStream
3939

4040
getAttribute_js = pkgutil.get_data(__package__, 'getAttribute.js').decode('utf8')
41+
isDisplayed_js = pkgutil.get_data(__package__, 'isDisplayed.js').decode('utf8')
4142

4243

4344
class WebElement(object):
@@ -348,10 +349,10 @@ def send_keys(self, *value):
348349
# RenderedWebElement Items
349350
def is_displayed(self):
350351
"""Whether the element is visible to a user."""
351-
if self._w3c :
352-
raw = pkgutil.get_data(__package__, 'isDisplayed.js')
352+
# Only go into this conditional for browsers that don't use the atom themselves
353+
if self._w3c and self.parent.capabilities['browserName'] == 'safari':
353354
return self.parent.execute_script(
354-
"return (%s).apply(null, arguments);" % raw,
355+
"return (%s).apply(null, arguments);" % isDisplayed_js,
355356
self)
356357
else:
357358
return self._execute(Command.IS_ELEMENT_DISPLAYED)['value']

0 commit comments

Comments
 (0)