Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 2 keywords: 1. get element attribute, 2. element value should be.… #61

Merged
merged 1 commit into from
Aug 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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