def add_element_extension_method(Klass):
def add_element_method(Klass, using):<EOL><INDENT>locator = using.name.lower()<EOL>find_element_name = "<STR_LIT>" + locator<EOL>find_element_if_exists_name = "<STR_LIT>" + locator + "<STR_LIT>"<EOL>find_element_or_none_name = "<STR_LIT>" + locator + "<STR_LIT>"<EOL>wait_for_element_name = "<STR_LIT>" + locator<EOL>find_elements_name = "<STR_LIT>" + locator<EOL>wait_for_elements_name = "<STR_LIT>" + locator<EOL>def find_element(self, value):<EOL><INDENT>return self.element(using.value, value)<EOL><DEDENT>find_element.__name__ = find_element_name<EOL>find_element.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>def find_element_if_exists(self, value):<EOL><INDENT>return self.element_if_exists(using.value, value)<EOL><DEDENT>find_element_if_exists.__name__ = find_element_if_exists_name<EOL>find_element_if_exists.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>def find_element_or_none(self, value):<EOL><INDENT>return self.element_or_none(using.value, value)<EOL><DEDENT>find_element_or_none.__name__ = find_element_or_none_name<EOL>find_element_or_none.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>def wait_for_element_by(self, *args, **kwargs):<EOL><INDENT>return self.wait_for_element(using.value, *args, **kwargs)<EOL><DEDENT>wait_for_element_by.__name__ = wait_for_element_name<EOL>wait_for_element_by.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>def find_elements(self, value):<EOL><INDENT>return self.elements(using.value, value)<EOL><DEDENT>find_elements.__name__ = find_elements_name<EOL>find_elements.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>def wait_for_elements_available(self, *args, **kwargs):<EOL><INDENT>return self.wait_for_elements(using.value, *args, **kwargs)<EOL><DEDENT>wait_for_elements_available.__name__ = wait_for_elements_name<EOL>wait_for_elements_available.__doc__ = (<EOL>"<STR_LIT>".format(using.value) +<EOL>"<STR_LIT>"<EOL>)<EOL>setattr(Klass, find_element_name, find_element)<EOL>setattr(Klass, find_element_if_exists_name, find_element_if_exists)<EOL>setattr(Klass, find_element_or_none_name, find_element_or_none)<EOL>setattr(Klass, wait_for_element_name, wait_for_element_by)<EOL>setattr(Klass, find_elements_name, find_elements)<EOL>setattr(Klass, wait_for_elements_name, wait_for_elements_available)<EOL><DEDENT>for locator in iter(Locator):<EOL><INDENT>add_element_method(Klass, locator)<EOL><DEDENT>
Add element_by alias and extension' methods(if_exists/or_none).