Skip to content

Commit 7fb6b1b

Browse files
joshbruninglukeis
authored andcommitted
WebElement __eq__ compares against more types
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 <[email protected]>
1 parent b94b265 commit 7fb6b1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/selenium/webdriver/remote/webelement.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def id(self):
426426
return self._id
427427

428428
def __eq__(self, element):
429-
return self._id == element.id
429+
return hasattr(element, 'id') and self._id == element.id
430430

431431
def __ne__(self, element):
432432
return not self.__eq__(element)

0 commit comments

Comments
 (0)