Пример #1
0
    def test_check_region_in_frame2_fluent(self):
        self.eyes.check(
            "Fluent - Inner frame div 1",
            Target.frame("frame1").region("#inner-frame-div").fully().timeout(
                5000).ignore(Region(50, 50, 100, 100)),
        )

        self.eyes.check(
            "Fluent - Inner frame div 2",
            Target.frame("frame1").region("#inner-frame-div").fully().ignore(
                Region(50, 50, 100, 100)).ignore(Region(70, 170, 90, 90)),
        )

        self.eyes.check(
            "Fluent - Inner frame div 3",
            Target.frame("frame1").region("#inner-frame-div").fully().timeout(
                5000),
        )

        self.eyes.check(
            "Fluent - Inner frame div 4",
            Target.frame("frame1").region("#inner-frame-div").fully(),
        )

        self.eyes.check(
            "Fluent - Full frame with floating region",
            Target.frame("frame1").fully().layout().floating(
                25, Region(200, 200, 150, 150)),
        )
def test_android_native_region__sauce_labs(mobile_eyes):
    eyes, mobile_driver = mobile_eyes
    eyes.open(mobile_driver, "AndroidNativeApp", "AndroidNativeApp checkRegionFloating")
    settings = Target.region(Region(0, 100, 1400, 2000)).floating(
        Region(10, 10, 20, 20), 3, 3, 20, 30
    )
    eyes.check("Contact list", settings)
def test_match_regions_with_regions_input(method_name):
    region, region1 = Region(0, 1, 2, 3), Region(0, 2, 4, 5)
    regions = get_regions_from_(method_name, region)
    assert regions[0]._region == region

    regions = get_regions_from_(method_name, region, region1)
    assert regions[0]._region == region
    assert regions[1]._region == region1
def test_iOS_native_region__sauce_labs(mobile_eyes):
    eyes, mobile_driver = mobile_eyes
    # eyes.configure.set_features(Feature.SCALE_MOBILE_APP)
    eyes.open(mobile_driver, "iOSNativeApp",
              "iOSNativeApp checkRegionFloating")
    settings = Target.region(Region(0, 100, 375,
                                    712)).floating(Region(10, 10, 20, 20), 3,
                                                   3, 20, 30)
    eyes.check("Contact list", settings)
def test_android_native_region__sauce_labs(mobile_eyes):
    eyes, mobile_driver = mobile_eyes
    # Click "Rebuild your app with new sdk" prompt
    mobile_driver.find_element(By.XPATH,
                               r"//android.widget.Button[@text='OK']").click()
    eyes.open(mobile_driver, "AndroidNativeApp",
              "AndroidNativeApp checkRegionFloating")
    settings = Target.region(Region(0, 100, 1400,
                                    2000)).floating(Region(10, 10, 20, 20), 3,
                                                    3, 20, 30)
    eyes.check("Contact list", settings)
Пример #6
0
def test_check_full_window_with_multiple_ignore_regions_by_selector__fluent(
        eyes_opened, check_test_result):
    eyes_opened.check("Fluent - Region by element",
                      Target.window().fully().ignore(".ignore"))
    check_test_result.send([{
        "actual_name":
        "ignore",
        "expected": [
            Region(10, 284, 800, 500),
            Region(122, 928, 456, 306),
            Region(8, 1270, 690, 206),
        ],
    }])
Пример #7
0
 def test_check_region_by_coordinate_in_frame_fluent(self):
     self.eyes.check(
         "Fluent - Inner frame coordinates",
         Target.frame("frame1").region(
             Region(30, 40, 400, 1200,
                    CoordinatesType.CONTEXT_RELATIVE)).fully(),
     )
Пример #8
0
    def ignore_region_by_coordinates(self,
                                     left,
                                     top,
                                     width,
                                     height,
                                     target=None):
        """
        Returns a Target object that ignores the region specified in the arguments.
        See `Defining Ignore and Floating Regions`.

            | =Arguments=     | =Description=                                                                                    |
            | Left (float)    | *Mandatory* - The left coordinate of the region to ignore e.g. 100                               |
            | Top (float)     | *Mandatory* - The top coordinate of the region to ignore e.g. 150                                |
            | Width (float)   | *Mandatory* - The width of the region to ignore e.g. 500                                         |
            | Height (float)  | *Mandatory* - The height of the region to ignore e.g. 120                                        |
            | Target (Target) | The previously existent Target, to be used if a ignore region or floating region was already set |
                
        *Example:*
            | ${target}=        | Ignore Region By Coordinates | 10               | 20 | 100 | 100 |
            | Check Eyes Window | Google Homepage              | target=${target} |

        """

        if target is None:
            target = Target()

        ignore_region = Region(float(left), float(top), float(width),
                               float(height))
        target.ignore(ignore_region)

        return target
Пример #9
0
def test_check_window_with_ignore_region__fluent(eyes_opened):
    eyes_opened.driver.find_element_by_tag_name("input").send_keys("My Input")
    eyes_opened.check(
        "Fluent - Window with Ignore region",
        Target.window().fully().timeout(5000).ignore_caret().ignore(
            Region(left=50, top=50, width=100, height=100)),
    )
def test_iOS_native__sauce_labs(mobile_eyes):
    eyes, mobile_driver = mobile_eyes
    eyes.open(mobile_driver, "iOSNativeApp", "iOSNativeApp checkWindow")
    eyes.check(
        "Contact list",
        Target.window().ignore(Region(left=0, top=0, width=300, height=100)),
    )
Пример #11
0
    def check_eyes_window(
        self,
        name,
        force_full_page_screenshot=None,
        enable_eyes_log=None,
        enable_http_debug_log=None,
        matchtimeout=-1,
        target=None,
        hidescrollbars=None,
        wait_before_screenshots=None,
        send_dom=None,
        matchlevel=None,
        isdisabled=None
    ):
        """
        Takes a snapshot from the browser using the webdriver and matches
        it with the expected output.

            | =Arguments=                       | =Description=                                                                                                                                                   |
            | Name (str)                        | *Mandatory* - Name that will be given to region in Eyes                                                                                                         |
            | Force Full Page Screenshot (bool) | Will force the browser to take a screenshot of whole page. Define "Stitch Mode" argument on `Open Eyes Session` if necessary                                    |
            | Enable Eyes Log (bool)            | Determines if the trace logs of Applitools Eyes SDK are activated for this test. 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 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 checkpoint. Overrides the argument set on `Open Eyes Session` |
            | Send DOM (bool)                   | Sets if DOM information should be sent for this checkpoint                                                                                                      |    
            | 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 Window | Google Homepage | ${true} | ${true} | ${true} | 5000 |

        *Note (Safari on mobile):*
        When checking a window, 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(force_full_page_screenshot, enable_eyes_log, enable_http_debug_log, hidescrollbars, wait_before_screenshots, send_dom, matchlevel, None, isdisabled)
        
        # 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":
            size = variables.driver.get_window_size("current")

            variables.eyes.check_region(
                Region(0, 71, size.__getitem__("width"), size.__getitem__("height")),
                name,
                matchtimeout,
                target,
            )
        else:
            variables.eyes.check_window(name, int(matchtimeout), target)

        utils.update_properties(**original_properties)
def test_check_region_with_region(method_name="region"):
    region = Region(0, 1, 2, 3)
    cs = get_cs_from_method(method_name, region)
    assert cs.values.target_region == region

    selector_or_xpath = ".cssSelector_or_XPATH"
    cs = get_cs_from_method(method_name, selector_or_xpath)
    assert cs.values.target_selector == selector_or_xpath
Пример #13
0
def test_final_application_android(eyes_open):
    eyes, driver = eyes_open
    eyes.stitch_mode = StitchMode.CSS
    eyes.check_window(
        "Home",
        target=(Target().ignore(
            IgnoreRegionBySelector(By.CLASS_NAME, "hero-container")).floating(
                FloatingRegion(Region(10, 20, 30, 40),
                               FloatingBounds(10, 0, 20, 10)))),
    )

    hero = driver.find_element_by_class_name("hero-container")
    eyes.check_region_by_element(
        hero,
        "Page Hero",
        target=(Target().ignore(Region(20, 20, 50, 50), Region(40, 40, 10,
                                                               20))),
    )
def test_android_native_sauce_labs(mobile_eyes):
    eyes, mobile_driver = mobile_eyes
    # Click "Rebuild your app with new sdk" prompt
    mobile_driver.find_element(By.XPATH,
                               r"//android.widget.Button[@text='OK']").click()
    eyes.open(mobile_driver, "AndroidNativeApp",
              "AndroidNativeApp checkWindow")
    eyes.check(
        "Contact list",
        Target.window().ignore(Region(left=0, top=0, width=1440, height=100)),
    )
def test_check_window_with_match_region_paddings__fluent(
        eyes_opened, check_test_result):
    eyes_opened.check(
        "Fluent - Window with ignore region by selector stretched",
        Target.window().fully().ignore(".ignore", padding=dict(
            left=10)).content("#stretched", padding=dict(top=10)).layout(
                "#centered",
                padding=dict(top=10,
                             right=50)).strict("overflowing-div",
                                               padding=dict(bottom=100)),
    )
    check_test_result.send([{
        "actual_name":
        "ignore",
        "expected": [
            Region(10 + 10, 286, 800, 500),
            Region(122 + 10, 933, 456, 306),
            Region(8 + 10, 1277, 690, 206),
        ],
    }])
Пример #16
0
def test_check_many(eyes_opened):
    eyes_opened.check(
        Target.region("#overflowing-div-image").with_name(
            "overflowing div image"),
        Target.region("overflowing-div").with_name("overflowing div"),
        Target.region("overflowing-div-image").fully().with_name(
            "overflowing div image (fully)"),
        Target.frame("frame1").frame("frame1-1").fully().with_name(
            "Full Frame in Frame"),
        Target.frame("frame1").with_name("frame1"),
        Target.region(Region(30, 50, 300, 620)).with_name("rectangle"),
    )
Пример #17
0
def test_check_window_with_match_region_paddings__fluent(
        eyes_opened, check_test_result):
    eyes_opened.check(
        "Fluent - Window with ignore region by selector stretched",
        Target.window().fully().ignore(".ignore", padding=dict(
            left=10)).content("#stretched", padding=dict(top=10)).layout(
                "#centered",
                padding=dict(top=10,
                             right=50)).strict("overflowing-div",
                                               padding=dict(bottom=100)),
    )
    # regions are different for latest UFG chrome vs classic chrome
    if isinstance(eyes_opened._runner, ClassicRunner):
        expected_regions = [
            Region(10, 286, 800, 500),
            Region(122, 933, 456, 306),
            Region(8, 1277, 690, 206),
        ]
    else:
        expected_regions = [
            Region(10, 285, 800, 501),
            Region(122, 932, 456, 307),
            Region(8, 1276, 690, 207),
        ]

    check_test_result.send([{
        "actual_name": "ignore",
        "expected": expected_regions,
    }])
def test_sample_script(eyes, driver):
    driver = eyes.open(driver, "Python app", "TestSampleScript", {
        "width": 800,
        "height": 600
    })
    driver.get("http://applitools.com")
    eyes.check_window(
        "Home",
        target=(Target().ignore(
            IgnoreRegionBySelector(By.CLASS_NAME, "hero-container")).floating(
                FloatingRegion(Region(10, 20, 30, 40),
                               FloatingBounds(10, 0, 20, 10)))),
    )

    hero = driver.find_element_by_class_name("hero-container")
    eyes.check_region_by_element(
        hero,
        "Page Hero",
        target=(Target().ignore(Region(20, 20, 50, 50), Region(40, 40, 10,
                                                               20))),
    )
    eyes.close()
Пример #19
0
    def check_eyes_region(self,
                          left,
                          top,
                          width,
                          height,
                          name,
                          enable_eyes_log=None,
                          enable_http_debug_log=None,
                          matchtimeout=-1,
                          target=None,
                          hidescrollbars=None,
                          wait_before_screenshots=None,
                          send_dom=None,
                          matchlevel=None,
                          isdisabled=None):
        """
        Takes a snapshot of the given region from the browser using a Region
        object (identified by left, top, width, height) and matches it with the
        expected output.

        The width and the height cannot be greater than the width and the height specified on `Open Eyes Session`.

            | =Arguments=                   | =Description=                                                                                                                                                   |
            | Left (float)                  | *Mandatory* - The left coordinate of the region that is tested e.g. 100                                                                                         |
            | Top (float)                   | *Mandatory* - The top coordinate of the region that is tested e.g. 150                                                                                          |
            | Width (float)                 | *Mandatory* - The width of the region that is tested e.g. 500                                                                                                   |
            | Height (float)                | *Mandatory* - The height of the region that is tested e.g. 120                                                                                                  |
            | Name (str)                    | *Mandatory* - Name that will be given to region in Eyes                                                                                                         |
            | 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 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 checkpoint. Overrides the argument set on `Open Eyes Session` |
            | Send DOM (bool)               | Sets if DOM information should be sent for this checkpoint                                                                                                      |    
            | 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 | 100 | 150 | 500 | 120 | Google Logo | ${true} | ${true} | 5000 |
        """
        original_properties = utils.save_current_properties()
        utils.update_properties(None, enable_eyes_log, enable_http_debug_log,
                                hidescrollbars, wait_before_screenshots,
                                send_dom, matchlevel, None, isdisabled)

        region = Region(float(left), float(top), float(width), float(height))
        variables.eyes.check_region(region, name, matchtimeout, target)

        utils.update_properties(**original_properties)
Пример #20
0
    def floating_region_by_coordinates(
        self,
        left,
        top,
        width,
        height,
        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 specified in the arguments.
        See `Defining Ignore and Floating Regions`

            | =Arguments=            | =Description=                                                                                    |
            | Left (float)           | *Mandatory* - The left coordinate of the floating region e.g. 100                                |
            | Top (float)            | *Mandatory* - The top coordinate of the floating region e.g. 150                                 |
            | Width (float)          | *Mandatory* - The width of the floating region e.g. 500                                          |
            | Height (float)         | *Mandatory* - The height of the floating region e.g. 120                                         |
            | 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 Coordinates |  10              | 10               | 200 | 150 | 10 | 0 | 50 | 50 | 
            | Check Eyes Window                            |  Google Homepage | target=${target} |
        """

        if target is None:
            target = Target()

        region = Region(float(left), float(top), float(width), float(height))
        floating_bounds = FloatingBounds(
            int(max_left_offset),
            int(max_top_offset),
            int(max_right_offset),
            int(max_down_offset),
        )
        floating_region = FloatingRegion(region, floating_bounds)
        target.floating(floating_region)

        return target
def test_check_window_with_ignore_region_fluent(eyes, driver):
    eyes.open(
        driver,
        "Eyes Selenium SDK - Fluent API",
        "TestCheckWindowWithIgnoreRegion_Fluent",
        {
            "width": 800,
            "height": 600
        },
    )
    driver.get("http://applitools.github.io/demo/TestPages/FramesTestPage/")
    driver.find_element_by_tag_name("input").send_keys("My Input")
    eyes.check_window(
        "Fluent - Window with Ignore region",
        target=Target().ignore(Region(left=50, top=50, width=100, height=100)),
    )
    eyes.close()
def test_coordinates_resolving(eyes, driver):
    driver = eyes.open(
        driver,
        "Python Selenium",
        "TestCoordinatesResolving",
        {
            "width": 800,
            "height": 600
        },
    )
    element = driver.find_element_by_css_selector("button")
    left = element.location["x"]
    top = element.location["y"]
    width = element.size["width"]
    height = element.size["height"]

    eyes.check("web element", Target.region(element))
    eyes.check("coordinates", Target.region(Region(left, top, width, height)))

    eyes.close()
def test_quickstart_example(eyes, driver):
    required_viewport = {"width": 1200, "height": 800}
    eyes.set_viewport_size(driver, required_viewport)
    eyes.open(
        driver=driver,
        app_name="TestQuickstartExample",
        test_name="My first Selenium Python test!",
        viewport_size={
            "width": 800,
            "height": 600
        },
    )

    eyes.check_window("Hello!")

    driver.find_element_by_css_selector("button").click()
    eyes.check_window("Click!")

    eyes.check_region(Region(20, 20, 50, 50), "step")

    eyes.close()
Пример #24
0
def test_check_window_with_floating_by_region__fluent(eyes_opened):
    eyes_opened.check(
        "Fluent - Window with floating region by region",
        Target.window().floating(Region(10, 10, 10, 10), 3, 3, 20, 30),
    )
Пример #25
0
def test_check_region_with_ignore_region__fluent(eyes_opened):
    eyes_opened.check(
        "Fluent - Region with Ignore region",
        Target.region("#overflowing-div").ignore(
            Region(left=50, top=50, width=100, height=100)),
    )
Пример #26
0
def test_simple_region(eyes_opened):
    eyes_opened.check("Simple Region",
                      Target.window().region(Region(50, 50, 100, 100)))
Пример #27
0
def test_check_region_by_coordinates__fluent(eyes_opened):
    eyes_opened.check("Fluent - Region by coordinates",
                      Target.region(Region(50, 70, 90, 110)))
Пример #28
0
 def test_check_window_with_floating_by_region_fluent(self):
     self.eyes.check(
         "Fluent - Window with floating region by selector",
         Target.window().floating(Region(10, 10, 10, 10), 3, 3, 20, 30),
     )
Пример #29
0
def test_check_overflowing_region_by_coordinates__fluent(eyes_opened):
    eyes_opened.check(
        "Fluent - Region by overflowing coordinates",
        Target.region(Region(50, 110, 90, 550)),
    )
def test_check_region_with_region(method_name="region"):
    region = Region(0, 1, 2, 3)
    cs = get_cs_from_method(method_name, region)
    assert cs.values.target_region == region