Skip to content

Commit b448f83

Browse files
Correct encoding of getAttribute.js. Fixes #2785
The atom is also only loaded once to prevent continuous reading from disk.
1 parent fdf8975 commit b448f83

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

py/selenium/webdriver/remote/webelement.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
except ImportError: # 3+
3838
from io import BytesIO as IOStream
3939

40+
getAttribute_js = pkgutil.get_data(__package__, 'getAttribute.js').decode('utf8')
41+
4042

4143
class WebElement(object):
4244
"""Represents a DOM element.
@@ -131,9 +133,8 @@ def get_attribute(self, name):
131133

132134
attributeValue = ''
133135
if self._w3c:
134-
raw = pkgutil.get_data(__package__, 'getAttribute.js')
135136
attributeValue = self.parent.execute_script(
136-
"return (%s).apply(null, arguments);" % raw,
137+
"return (%s).apply(null, arguments);" % getAttribute_js,
137138
self, name)
138139
else:
139140
resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name})

0 commit comments

Comments
 (0)