# -*- coding: utf-8 -*-

__author__ = 'm_beloborodko@wargaming.net'

from abc import ABCMeta, abstractmethod


class AbstractElement(metaclass=ABCMeta):
    """
    Abstract element. All elements should be derived from this class.

    :param wgc.client.client.WGCClient client: WGC client.
    :param str element_name: element name.
    :param str selector: element selector.
    """

    def __init__(self, client, element_name, selector, index=0, window_handle=None, provider=None):
        self.client = client
        self.element_name = element_name
        self.selector = selector
        self.index = index
        self.window_handle = window_handle
        self.provider = provider

    @abstractmethod
    def click(self, wait_response=True, timeout=10, index=0, ignore_exc=False):
        """
        Method to click on element.

        :param bool ignore_exc: ignore errors.
        :param int timeout: time wait response.
        :param bool wait_response: flag that indicates should we wait for
        response or not.
        :param int index: index of web element in list.
        """

    @abstractmethod
    def double_click(self):
        """
        Double click on element.
        """

    @abstractmethod
    def get_bounding_client_rect(self, index):
        """
        .getBoundingClientRect();
        """

    @property
    @abstractmethod
    def is_element_displayed(self):
        """
        Property to indicate is element displayed.
        """

    @property
    @abstractmethod
    def is_checkbox_checked(self):
        """
        Property to indicate is checkbox checked.
        """

    @property
    @abstractmethod
    def is_element_present(self):
        """
        Indicates is element present or not.
        """

    @abstractmethod
    def get_text(self):
        """
        Get text of element.

        :rtype: str | list[str]
        :return: text of element.
        """

    @abstractmethod
    def get_html_text(self):
        """
        Get text of element.

        :rtype: str | list[str]
        :return: text of element.
        """

    @abstractmethod
    def get_value(self):
        """
        Get value of element.

        :rtype: str | list[str]
        :return: value of element.
        """

    @abstractmethod
    def set_text(self, text, index=0):
        """
        Set text on element.

        :param str text: text that should be set on element.
        """

    @abstractmethod
    def get_attribute(self, attribute_name, index=0):
        """
        Get attribute name.

        :param int index: index of element
        :param str attribute_name: name of attribute.
        :rtype: str
        :return: attribute.
        """
        
    @abstractmethod
    def get_style_value(self, attribute_name, index=0):
        """
        Get style attribute value.
        """

    @abstractmethod
    def get_property_value(self, attribute_name, index=0):
        """
        Get style attribute name.

        :param int index: index of element
        :param str attribute_name: name of attribute.
        :rtype: str
        :return: attribute.
        """

    @abstractmethod
    def trigger_event(self, event, params=None, index=0):
        """
        Triggers event.

        :param str event: event that should be triggered.
        :param str params: params that should be passed with event.
        :param int index: index of web element in list.
        """

    @abstractmethod
    def get_elements_count(self):
        """
        Gets element count.

        :rtype: int
        :return: elements count.
        """

    @abstractmethod
    def hover_on_element(self):
        """
        Hover on element.
        """

    @abstractmethod
    def mouseenter_on_element(self):
        """
        Mouse enter on element.
        """

    @abstractmethod
    def mouseover_on_element(self):
        """
        Mouse over on element.
        """

    @abstractmethod
    def mouseleave_on_element(self):
        """
        Mouse leave on element.
        """

    @abstractmethod
    def get_element_color(self):
        """
        Get element color.

        :rtype: str
        :return: element color string.
        """

    @abstractmethod
    def get_element_background_color(self):
        """
        Get element background color.

        :rtype: str
        :return: element background color string.
        """

    @abstractmethod
    def set_checkbox_state(self, state):
        """
        Set checkbox state for element.

        :param bool state: state.
        """

    @abstractmethod
    def set_focus(self):
        """
        Set focus to element
        """
