Skip to content

Commit

Permalink
WebElement __eq__ compares against more types
Browse files Browse the repository at this point in the history
Prior to the definition of __ne__, many users
were using != with items without 'id' attr.
These users are broken by the new definition
of __ne__ as __eq__ raises an AttributeError.
Ensure __eq__ returns false when no 'id' attr
is defined.

Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
  • Loading branch information
joshbruning authored and lukeis committed Aug 1, 2015
1 parent b94b265 commit 7fb6b1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def id(self):
return self._id

def __eq__(self, element):
return self._id == element.id
return hasattr(element, 'id') and self._id == element.id

def __ne__(self, element):
return not self.__eq__(element)
Expand Down

0 comments on commit 7fb6b1b

Please sign in to comment.