Skip to content

Commit

Permalink
Merge pull request #61 from FileStringAutomation/master
Browse files Browse the repository at this point in the history
add 2 keywords: 1. get element attribute, 2. element value should be.…
  • Loading branch information
jollychang committed Aug 10, 2015
2 parents 1d38ef2 + 4a84e6d commit 48c90b6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/AppiumLibrary/keywords/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,33 @@ def element_name_should_be(self, locator, expected):
self._info("Element '%s' name is '%s' " % (locator, expected))


def get_element_attribute(self, locator, attribute):
"""Get element attribute using given attribute: name, value,...
Example:
|Get Element Attribute| locator | name |
or
|Get Element Attribute| locator | value |
"""
element = self._element_find(locator, True, True)
try:
return element.get_attribute(attribute)
except:
raise AssertionError("Element '%s' could not be found or "
"attribute '%s' is not valid." % (locator, attribute))
self._info("Element '%s' attribute is '%s' " % (locator, attribute))


def element_value_should_be(self, locator, expected):
element = self._element_find(locator, True, True)
if expected != element.get_attribute('value'):
raise AssertionError("Element '%s' value should be '%s' "
"but it is '%s'." % (locator, expected, element.get_attribute('value')))
self._info("Element '%s' value is '%s' " % (locator, expected))



# Private

def _is_index(self, index_or_name):
Expand Down

0 comments on commit 48c90b6

Please sign in to comment.