Best Python code snippet using robotframework-appiumlibrary_python
test_accumulating_attribute_parser.py
Source:test_accumulating_attribute_parser.py
...126class TestElementMatches(TestCase):127 def test_element_matches_exactly(self):128 element_to_remove = "SOMETHING"129 element_to_check = "SOMETHING"130 self.assertTrue(_element_matches(element_to_remove, element_to_check))131 def test_element_no_match(self):132 element_to_remove = "SOMETHING"133 element_to_check = "SOMETHING_ELSE"134 self.assertFalse(_element_matches(element_to_remove, element_to_check))135 def test_element_matches_with_number_arg(self):136 element_to_remove = "SOMETHING"137 element_to_check = "SOMETHING=5"138 self.assertTrue(_element_matches(element_to_remove, element_to_check))139 def test_element_no_match_with_number_arg(self):140 element_to_remove = "SOMETHING"141 element_to_check = "SOMETHING_DIFFERENT=5"142 self.assertFalse(_element_matches(element_to_remove, element_to_check))143class TestRemoveAttributeElement(TestCase):144 def test_remove_element_without_numbers(self):145 current_attribute_state = {"attribute_1": ["ONE", "TWO=2", "THREE"]}146 elements_to_remove = ["ONE", "THREE"]147 expected_result = {"attribute_1": ["TWO=2"]}148 result = _remove_attribute_element(current_attribute_state, "attribute_1", elements_to_remove)149 self.assertEqual(result, expected_result)150 def test_remove_element_with_numbers(self):151 current_attribute_state = {"attribute_1": ["ONE", "TWO=2", "THREE"]}152 elements_to_remove = ["TWO"]153 expected_result = {"attribute_1": ["ONE", "THREE"]}154 result = _remove_attribute_element(current_attribute_state, "attribute_1", elements_to_remove)...
elementfinder.py
Source:elementfinder.py
...98 elif tag == 'file upload':99 tag = 'input'100 constraints['type'] = 'file'101 return tag, constraints102 def _element_matches(self, element, tag, constraints):103 if not element.tag_name.lower() == tag:104 return False105 for name in constraints:106 if not element.get_attribute(name) == constraints[name]:107 return False108 return True109 def _filter_elements(self, elements, tag, constraints):110 if tag is None: return elements111 return filter(112 lambda element: self._element_matches(element, tag, constraints),113 elements)114 def _get_attrs_with_url(self, key_attrs, criteria, browser):115 attrs = []116 url = None117 xpath_url = None118 for attr in ['@src', '@href']:119 if attr in key_attrs:120 if url is None or xpath_url is None:121 url = self._get_base_url(browser) + "/" + criteria122 xpath_url = utils.escape_xpath_value(url)123 attrs.append("%s=%s" % (attr, xpath_url))124 return attrs125 def _get_base_url(self, browser):126 url = browser.get_current_url()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!