예제 #1
0
파일: check.py 프로젝트: isonic1/robot
    def check_eyes_region_by_selector(self,
                                      value,
                                      name,
                                      selector=None,
                                      enable_http_debug_log=None,
                                      matchtimeout=None,
                                      hidescrollbars=None,
                                      wait_before_screenshots=None,
                                      matchlevel=None):
        """
        Takes a snapshot of the region of the element found by calling
        find_element(by, value) from the browser using the web driver and
        matches it with the expected output. With a choice from eight
        selectors, to check by on `Using Selectors` section.

        Not available to mobile native apps.

            | =Arguments=                   | =Description=                                                                                                                                             |
            | Value (str)                   | *Mandatory* - The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown                                                      |
            | Name (str)                    | *Mandatory* - Name that will be given to region in Eyes                                                                                                   |
            | Selector (str)                | *Mandatory* - The strategy to locate the element. The supported selectors are specified in `Using Selectors`                                              |
            | Match Timeout (int)           | Determines how much time in milliseconds Eyes continue to retry the matching before declaring a mismatch on this checkpoint                               |
            | Target (Target)               | The intended Target. See `Defining Ignore and Floating Regions`                                                                                           |
            | Hide Scrollbars (bool)        | Sets if the scrollbars are hidden in the checkpoint, by passing 'True' or 'False' in the variable                                                         |
            | Wait Before Screenshots (int) | Determines the number of milliseconds that Eyes will wait before capturing the screenshot of this test. Overrides the argument set on `Open Eyes Session` |
            | Match Level (str)             | The match level for the comparison of this checkpoint - can be STRICT, LAYOUT, CONTENT or EXACT                                                           |

        *Example:*
            | Check Eyes Region By Selector | .first.expanded.dropdown | Css Element | css selector | ${true} | ${true} | 5000 |

        *Note (Safari on mobile):*
        When checking an element, provide osname=iOS and browsername=Safari on `Open Eyes Session`.
        Due to an issue regarding the height of the address bar not being taken into account when the screenshot is taken, a temporary workaround is in place.
        In order to screenshot the correct element, it is added the value of 71 to the y coordinate of the element.
        """
        original_properties = utils.save_current_properties()
        utils.update_properties(None, enable_http_debug_log, hidescrollbars,
                                wait_before_screenshots, matchlevel)

        selector_strategy = utils.get_selector_strategy(selector)

        variables.eyes.check(
            name,
            Target.region([selector_strategy, value
                           ]).timeout(matchtimeout).match_level(matchlevel))

        utils.update_properties(**original_properties)
예제 #2
0
    def floating_region_by_selector(
        self,
        value,
        selector="id",
        max_left_offset=0,
        max_top_offset=0,
        max_right_offset=0,
        max_down_offset=0,
        target=None,
    ):
        """
        Returns a Target object that includes the floating region containing the element specified in the arguments by selector and value.
        See `Defining Ignore and Floating Regions` and `Using Selectors`.

            | =Arguments=            | =Description=                                                                                                |
            | Value (str)            | *Mandatory* - The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown         |
            | Selector (str)         | *Mandatory* - The strategy to locate the element. The supported selectors are specified in `Using Selectors` |
            | Max Left Offset (int)  | The amount the floating region may move to the left. e.g. 10                                                 |
            | Max Top Offset (int)   | The amount the floating region may moveupwards. e.g. 20                                                      |
            | Max Right Offset (int) | The amount the floating region may move to the right. e.g. 10                                                |
            | Max Down Offset (int)  | The amount the floating region may move downwards. e.g. 50                                                   |
            | Target (Target)        | The previously existent Target, to be used if a ignore region or floating region was already set             |
                
        *Example:*
            | ${target}=        | Floating Region By Selector | .first.expanded.dropdown | css selector | 20 | 10 | 20 | 10 |
            | Check Eyes Window | Google Homepage             | target=${target}         |
        """

        if target is None:
            target = Target()

        selector_strategy = utils.get_selector_strategy(selector)
        floating_bounds = FloatingBounds(
            int(max_left_offset),
            int(max_top_offset),
            int(max_right_offset),
            int(max_down_offset),
        )
        floating_region = FloatingRegionBySelector(
            selector_strategy, value, floating_bounds
        )
        target.floating(floating_region)

        return target
예제 #3
0
파일: target.py 프로젝트: isonic1/robot
    def ignore_region_by_selector(self, value, selector="id", target=None):
        """
        Returns a Target object that ignores the region of the element specified in the arguments by selector and value.
        See `Defining Ignore and Floating Regions` and `Using Selectors`

            | =Arguments=     | =Description=                                                                                                |
            | Value (str)     | *Mandatory* - The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown         |
            | Selector (str)  | *Mandatory* - The strategy to locate the element. The supported selectors are specified in `Using Selectors` |
            | Target (Target) | The previously existent Target, to be used if a ignore region or floating region was already set             |
                
        *Example:*
            | ${target}=        | Ignore Region By Selector | .first.expanded.dropdown | css selector |
            | Check Eyes Window | Google Homepage           | target=${target}         |
        """

        if target is None:
            target = Target()

        selector_strategy = utils.get_selector_strategy(selector)
        ignore_region = IgnoreRegionBySelector(selector_strategy, value)
        target.ignore(ignore_region)

        return target
예제 #4
0
    def check_eyes_region_in_frame_by_selector(self,
                                               framereference,
                                               value,
                                               name,
                                               selector="id",
                                               enable_eyes_log=None,
                                               enable_http_debug_log=None,
                                               matchtimeout=-1,
                                               target=None,
                                               hidescrollbars=None,
                                               wait_before_screenshots=None,
                                               send_dom=None,
                                               stitchcontent=None,
                                               matchlevel=None,
                                               isdisabled=None):
        """
        Takes a snapshot of the region of the element found by calling
        find_element(by, value) inside a specific frame, 
        and matches it with the expected output. With a choice from eight
        selectors, to check by on `Using Selectors` section.

            | =Arguments=                              | =Description=                                                                                                                                                   |
            | Frame Reference (str, int or WebElement) | *Mandatory* - Defines the frame to be checked. See below what arguments must be used as frame reference                                                         |
            | Value (str)                              | *Mandatory* - The specific value of the selector. e.g. a CSS SELECTOR value .first.expanded.dropdown                                                            |
            | Name (str)                               | *Mandatory* - Name that will be given to region in Eyes                                                                                                         |
            | Selector (str)                           | *Mandatory* - The strategy to locate the element. The supported selectors are specified in `Using Selectors`                                                    |
            | Enable Eyes Log (bool)                   | Determines if the trace logs of Applitools Eyes SDK are activated for this checkpoint. Overrides the argument set on `Open Eyes Session`                        |
            | Enable HTTP Debug Log (bool)             | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable                                                                   |
            | Match Timeout (int)                      | Determines how much time in milliseconds Eyes continue to retry the matching before declaring a mismatch on this test                                           |
            | Target (Target)                          | The intended Target. See `Defining Ignore and Floating Regions`                                                                                                 |
            | Hide Scrollbars (bool)                   | Sets if the scrollbars are hidden in the checkpoint, by passing 'True' or 'False' in the variable                                                               |
            | Wait Before Screenshots (int)            | Determines the number of milliseconds that Eyes will wait before capturing the screenshot of this checkpoint. Overrides the argument set on `Open Eyes Session` |
            | Send DOM (bool)                          | Sets if DOM information should be sent for this checkpoint                                                                                                      |    
            | Stitch Content (bool)                    | Determines if Eyes will scroll this element to take a full element screenshot, when the element is scrollable                                                   |    
            | Match Level (str)                        | The match level for the comparison of this checkpoint - can be STRICT, LAYOUT, CONTENT or EXACT                                                                 |
            | Is Disabled (bool)                       | Determines whether or not interactions with Eyes will be silently ignored for this checkpoint                                                                   |    

        *Example:*
            | Check Eyes Region In Frame By Selector | FrameName | .first.expanded.dropdown | Css Element | css selector | ${true} | ${true} | 5000 |

        *Frame Reference*

        In order to locate the correct frame, you must use one of the following references:
         - Str: Name of the frame
         - Int: Index of frame, relative to the list of frames on the page
         - EyesWebElement or WebElement: The frame element

        *Note (Safari on mobile):*
        When checking an element, provide osname=iOS and browsername=Safari on `Open Eyes Session`.
        Due to an issue regarding the height of the address bar not being taken into account when the screenshot is taken, a temporary workaround is in place.
        In order to screenshot the correct element, it is added the value of 71 to the y coordinate of the element.

        """

        original_properties = utils.save_current_properties()
        utils.update_properties(None, enable_eyes_log, enable_http_debug_log,
                                hidescrollbars, wait_before_screenshots,
                                send_dom, matchlevel, stitchcontent,
                                isdisabled)

        if type(framereference) is six.text_type:
            try:
                framereference = int(framereference)
            except:
                framereference = str(framereference)

        selector_strategy = utils.get_selector_strategy(selector)

        # Temporary workaround in order to capture the correct element on Safari
        # Element coordinate y doesn't take the address bar height into consideration, so it has to be added
        # Current address bar height: 71
        if variables.eyes.host_app == "Safari" and variables.eyes.host_os == "iOS":

            with variables.driver.switch_to.frame_and_back(framereference):

                element = variables.driver.find_element(
                    selector_strategy, value)
                location = element.location
                size = element.size

                variables.eyes.check_region(
                    Region(
                        location.__getitem__("x"),
                        location.__getitem__("y") + 71,
                        size.__getitem__("width"),
                        size.__getitem__("height"),
                    ),
                    name,
                    matchtimeout,
                    target,
                    variables.stitchcontent,
                )
        else:
            variables.eyes.check_region_in_frame_by_selector(
                framereference,
                selector_strategy,
                value,
                name,
                matchtimeout,
                target,
                variables.stitchcontent,
            )

        utils.update_properties(**original_properties)