<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_attribute(self, locator, attribute, params=None, timeout=None, visible=False):
 """ Get attribute from element based on locator with optional parameters. Calls get_element() with expected condition: visibility of element located :param locator: locator tuple or WebElement instance :param attribute: attribute to return :param params: (optional) locator parameters :param timeout: (optional) time to wait for text (default: None) :param visible: should element be visible before getting text (default: False) :return: element attribute """

        element = locator
        if not isinstance(element, WebElement):
            element = self.get_present_element(locator, params, timeout, visible)

        try:
            return element.get_attribute(attribute)
        except AttributeError:
            msg = "Element with attribute <{}> was never located!".format(attribute)
            raise NoSuchElementException(msg)