Ejemplo n.º 1
0
    def __init__(self, element, driver):
        # type: (WebElement, EyesWebDriver) -> None
        """
        Ctor.

        :param element: The element in the frame.
        :param eyes: The eyes sdk instance.
        :param driver: EyesWebDriver instance.
        """
        if isinstance(element, EyesWebElement):
            element = element._element
        self._proxy_to_fields = all_fields(element.__class__)
        self._element = element  # type: WebElement
        self._driver = driver  # type: EyesWebDriver

        # setting from outside
        self.position_provider = None  # type: Optional[SeleniumPositionProvider]
        self._original_overflow = None  # type: Optional[Text]
Ejemplo n.º 2
0
    EyesBase,
    NullCutProvider,
    RegionProvider,
)
from applitools.images.fluent import ImagesCheckSettings, Target

from .__version__ import __version__
from .capture import EyesImagesScreenshot

if typing.TYPE_CHECKING:
    from typing import Text, Union, Optional, Dict
    from PIL import Image
    from applitools.common.utils.custom_types import ViewPort


@proxy_to("configuration", all_fields(Configuration))
class Eyes(EyesBase):
    _raw_title = None  # type: Optional[Text]
    _screenshot = None  # type: Optional[EyesImagesScreenshot]
    _inferred = None  # type: Optional[Text]

    @property
    def full_agent_id(self):
        # type: () -> Text
        if self.configure.agent_id is None:
            return self.base_agent_id
        return "%s [%s]" % (self.configure.agent_id, self.base_agent_id)

    @property
    def base_agent_id(self):
        # type: () -> Text
Ejemplo n.º 3
0
        AnyWebElement,
    )
    from applitools.core import (
        PositionProvider,
        FixedCutProvider,
        UnscaledFixedCutProvider,
        NullCutProvider,
    )
    from .frames import FrameChain
    from .fluent import SeleniumCheckSettings
    from .webelement import EyesWebElement


@proxy_to(
    "configure",
    all_fields(Configuration) + [
        "use_dom", "send_dom", "match_level", "ignore_displacements",
        "enable_patterns"
    ],
)
class Eyes(EyesConfigurationMixin):
    _is_visual_grid_eyes = False  # type: bool
    _visual_grid_eyes = None  # type: VisualGridEyes
    _selenium_eyes = None  # type: SeleniumEyes
    _runner = None  # type: Optional[VisualGridRunner]
    _driver = None  # type: Optional[EyesWebDriver]
    _is_opened = False  # type: bool
    _config_cls = Configuration

    def __init__(self, runner=None):
        # type: (Optional[VisualGridRunner, ClassicRunner]) -> None
Ejemplo n.º 4
0
    def _ref_if_locator(self, frame_ref):
        if isinstance(frame_ref, FrameLocator):
            frame_locator = frame_ref
            if frame_locator.frame_index:
                frame_ref = frame_locator.frame_index
            if frame_locator.frame_name_or_id:
                frame_ref = frame_locator.frame_name_or_id
            if frame_locator.frame_element:
                frame_ref = frame_locator.frame_element
            if frame_locator.frame_selector:
                by, value = frame_locator.frame_selector
                frame_ref = self._driver.find_elemen(by, value)
        return frame_ref


@proxy_to("_switch_to", all_fields(SwitchTo))
class _EyesSwitchTo(object):
    """
    Wraps :py:class:`selenium.webdriver.remote.switch_to.SwitchTo` object, so we can
    keep track of  switching between frames. It names EyesTargetLocator in other SDK's
    """

    PARENT_FRAME = 1
    _position_memento = None

    def __init__(self, driver, switch_to):
        # type: (EyesWebDriver, SwitchTo) -> None
        """
        Ctor.

        :param driver: EyesWebDriver instance.
Ejemplo n.º 5
0
        retVal.push(elem.currentStyle['border-right-width']);
        retVal.push(elem.currentStyle['border-bottom-width']);
        } else {
        retVal.push(0,0,0,0);
        }
"""
_JS_GET_BORDER_WIDTHS = _JS_GET_BORDER_WIDTHS_ARR + "return retVal;"
_JS_GET_SIZE_AND_BORDER_WIDTHS = """
        var elem = arguments[0];
        var retVal = [arguments[0].clientWidth, arguments[0].clientHeight];
        {}
        return retVal
""".format(_JS_GET_BORDER_WIDTHS_ARR)


@proxy_to("_element", all_fields(WebElement))
class EyesWebElement(object):
    """
    A wrapper for selenium web element. This enables eyes to be notified
     about actions/events for this element.
    """
    def __init__(self, element, driver):
        # type: (WebElement, EyesWebDriver) -> None
        """
        Ctor.

        :param element: The element in the frame.
        :param eyes: The eyes sdk instance.
        :param driver: EyesWebDriver instance.
        """
        if isinstance(element, EyesWebElement):