本文整理汇总了Python中robot.libraries.BuiltIn.BuiltIn.should_match方法的典型用法代码示例。如果您正苦于以下问题:Python BuiltIn.should_match方法的具体用法?Python BuiltIn.should_match怎么用?Python BuiltIn.should_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robot.libraries.BuiltIn.BuiltIn
的用法示例。
在下文中一共展示了BuiltIn.should_match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _ElementKeywords
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import should_match [as 别名]
#.........这里部分代码省略.........
"""
if self._element_find(locator, True, True).is_enabled():
self.log_source(loglevel)
raise AssertionError("Element '%s' should be disabled "
"but did not" % locator)
self._info("Element '%s' is disabled ." % locator)
def element_should_be_enabled(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is enabled.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
"""
if not self._element_find(locator, True, True).is_enabled():
self.log_source(loglevel)
raise AssertionError("Element '%s' should be enabled "
"but did not" % locator)
self._info("Element '%s' is enabled ." % locator)
def element_name_should_be(self, locator, expected):
element = self._element_find(locator, True, True)
if expected != element.get_attribute('name'):
raise AssertionError("Element '%s' name should be '%s' "
"but it is '%s'." % (locator, expected, element.get_attribute('name')))
self._info("Element '%s' name is '%s' " % (locator, expected))
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))
def element_attribute_should_match(self, locator, attr_name, match_pattern, regexp=False):
"""Verify that an attribute of an element matches the expected criteria.
The element is identified by _locator_. See `introduction` for details
about locating elements. If more than one element matches, the first element is selected.
The _attr_name_ is the name of the attribute within the selected element.
The _match_pattern_ is used for the matching, if the match_pattern is
- boolean or 'True'/'true'/'False'/'false' String then a boolean match is applied
- any other string is cause a string match
The _regexp_ defines whether the string match is done using regular expressions (i.e. BuiltIn Library's
[http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Match%20Regexp|Should
Match Regexp] or string pattern match (i.e. BuiltIn Library's
[http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Match|Should
Match])
Examples:
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | text | *foobar |
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | text | f.*ar | regexp = True |
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | enabled | True |
| 1. is a string pattern match i.e. the 'text' attribute should end with the string 'foobar'
| 2. is a regular expression match i.e. the regexp 'f.*ar' should be within the 'text' attribute
| 3. is a boolead match i.e. the 'enabled' attribute should be True
_*NOTE: *_
On Android the supported attribute names are hard-coded in the
[https://github.com/appium/appium/blob/master/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/AndroidElement.java|AndroidElement]
示例2: _ElementKeywords
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import should_match [as 别名]
#.........这里部分代码省略.........
if not self._element_find(locator, True, True).is_enabled():
self.log_source(loglevel)
raise AssertionError("Element '%s' should be enabled "
"but did not" % locator)
self._info("Element '%s' is enabled ." % locator)
def element_should_be_visible(self, locator, loglevel='INFO'):
"""Verifies that element identified with locator is visible.
Key attributes for arbitrary elements are `id` and `name`. See
`introduction` for details about locating elements.
New in AppiumLibrary 1.4.5
"""
if not self._element_find(locator, True, True).is_displayed():
self.log_source(loglevel)
raise AssertionError("Element '%s' should be visible "
"but did not" % locator)
def element_name_should_be(self, locator, expected):
element = self._element_find(locator, True, True)
if str(expected) != str(element.get_attribute('name')):
raise AssertionError("Element '%s' name should be '%s' "
"but it is '%s'." % (locator, expected, element.get_attribute('name')))
self._info("Element '%s' name is '%s' " % (locator, expected))
def element_value_should_be(self, locator, expected):
element = self._element_find(locator, True, True)
if str(expected) != str(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))
def element_attribute_should_match(self, locator, attr_name, match_pattern, regexp=False):
"""Verify that an attribute of an element matches the expected criteria.
The element is identified by _locator_. See `introduction` for details
about locating elements. If more than one element matches, the first element is selected.
The _attr_name_ is the name of the attribute within the selected element.
The _match_pattern_ is used for the matching, if the match_pattern is
- boolean or 'True'/'true'/'False'/'false' String then a boolean match is applied
- any other string is cause a string match
The _regexp_ defines whether the string match is done using regular expressions (i.e. BuiltIn Library's
[http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Match%20Regexp|Should
Match Regexp] or string pattern match (i.e. BuiltIn Library's
[http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Match|Should
Match])
Examples:
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | text | *foobar |
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | text | f.*ar | regexp = True |
| Element Attribute Should Match | xpath = //*[contains(@text,'foo')] | enabled | True |
| 1. is a string pattern match i.e. the 'text' attribute should end with the string 'foobar'
| 2. is a regular expression match i.e. the regexp 'f.*ar' should be within the 'text' attribute
| 3. is a boolead match i.e. the 'enabled' attribute should be True
_*NOTE: *_
On Android the supported attribute names are hard-coded in the
[https://github.com/appium/appium/blob/master/lib/devices/android/bootstrap/src/io/appium/android/bootstrap/AndroidElement.java|AndroidElement]