Issue 5955 in selenium: WebElement.get_attribute broken for python

131 views
Skip to first unread message

sele...@googlecode.com

unread,
Jul 18, 2013, 5:53:00 PM7/18/13
to selenium-develope...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Status-Untriaged

New issue 5955 by eric.pla...@mutualmobile.com: WebElement.get_attribute
broken for python
http://code.google.com/p/selenium/issues/detail?id=5955


What steps will reproduce the problem?
1. Get a WebElement
2. Try to get a boolean attribute

What is the expected output? What do you see instead?
A boolean return value is expected, but get a traceback in stead

Selenium version: 2.33.0
OS: OSX 10.8.4 x86_64
Browser: appium
Browser version: appium

In [19]: driver
Out[19]: <selenium.webdriver.remote.webdriver.WebDriver at 0x10c30df90>

In [20]: el = driver.find_element_by_tag_name('listView')

In [21]: el
Out[21]: <selenium.webdriver.remote.webelement.WebElement at 0x10c30db90>
In [22]: el.get_attribute('enabled')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-22-6eef725c0355> in <module>()
----> 1 el.get_attribute('enabled')

/Users/plaster/rep/QA/mats/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.pyc
in
get_attribute(self, name)
71 attributeValue = resp['value']
72 if type(resp['value']) is bool:
---> 73 attributeValue = attributeValue.lower()
74
75 return attributeValue

AttributeError: 'bool' object has no attribute 'lower'

If we determined that the response type if a boolean value, why are we
trying to do a string lower on it?

--
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,
Jul 23, 2013, 2:10:45 AM7/23/13
to selenium-develope...@googlegroups.com
Updates:
Status: Fixed

Comment #1 on issue 5955 by luke.semerau: WebElement.get_attribute broken
for python
http://code.google.com/p/selenium/issues/detail?id=5955

thanks again for the patch

sele...@googlecode.com

unread,
Aug 7, 2013, 5:22:29 AM8/7/13
to selenium-develope...@googlegroups.com

Comment #2 on issue 5955 by dominik....@gmail.com: WebElement.get_attribute
With the additional string conversion get_attribute fails for values with
special characters.

Example for value 'München':
test_value =
driver.find_element_by_id("mapSearchField").get_attribute('value')

File "/home/db/.virtualenvs/django15/local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py",
line 71, in get_attribute
attributeValue = str(resp['value'])
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
position 1: ordinal not in range(128)

----------------------------------------------------------------------

Suggestion: only convert value to string when it is of type bool.
attributeValue = resp['value']
if type(resp['value']) is bool:
attributeValue = str(attributeValue).lower()

sele...@googlecode.com

unread,
Oct 10, 2013, 4:27:43 PM10/10/13
to selenium-develope...@googlegroups.com

Comment #3 on issue 5955 by evgenii...@gmail.com: WebElement.get_attribute
Installed selenium recently via pip install selenium,
bumped into same issue with appium:
get_attribute
"int" object has no attribute 'lower'
Reply all
Reply to author
Forward
0 new messages