def test_acme_login(eyes_opened):
    username = eyes_opened.driver.find_element_by_id("username")
    username.click()
    username.send_keys("adamC")
    password = eyes_opened.driver.find_element_by_id("password")
    password.click()
    password.send_keys("MySecret123?")
    eyes_opened.check(Target.region(username), Target.region(password))
def _region_fully_test_flow(eyes):
    eyes.configure.stitch_mode = StitchMode.Scroll
    eyes.check(
        "region-scroll",
        Target.region([By.TAG_NAME, "footer"]),
    )
    eyes.configure.stitch_mode = StitchMode.CSS
    eyes.check(
        "region-css",
        Target.region([By.TAG_NAME, "footer"]).fully().timeout(0),
    )
Esempio n. 3
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"),
    )
def test_check_two_scrolled_regions__fluent(eyes_opened):
    top_element = eyes_opened.driver.find_element_by_xpath(
        "/html/body/div[4]/main/div[1]/div[2]")
    bottom_element = eyes_opened.driver.find_element_by_xpath(
        "/html/body/div[4]/main/div[1]/div[7]")

    eyes_opened.check(
        "Get started with",
        Target.region(top_element).fully(),
    )
    eyes_opened.check(
        "Customize your process with",
        Target.region(bottom_element).fully(),
    )
def test_region_selector_in_check_fluent_interface(eyes, driver):
    eyes_driver = eyes.open(
        driver,
        "Python Selenium",
        "TestRegionSelectorInCheckFluentInterface",
        {
            "width": 800,
            "height": 600
        },
    )
    eyes.check("By CSS Selector",
               Target.region([By.CSS_SELECTOR, "#overflowing-div"]))
    eyes.check("By XPATH",
               Target.region([By.XPATH, '//*[@id="overflowing-div"]']))
    eyes.close()
Esempio n. 6
0
def test_zachs_app(eyes, driver):
    driver.get("https://www.goodrx.com/xarelto/what-is")
    eyes.open(
        driver,
        app_name="Zachs Python app",
        test_name="I_29263 FF CSS transition FULLY",
        viewport_size={"width": 800, "height": 600},
    )
    proscons_ele = driver.find_element_by_xpath('//*[@id="pros-cons"]/..')
    eyes.check("pros-cons", Target.region(proscons_ele).fully())

    warnings_ele = driver.find_element_by_xpath('//*[@id="warnings"]/..')
    eyes.check("warnings", Target.region(warnings_ele).fully())

    eyes.close()
def test_screenshot_too_big(driver, eyes, fake_connector_class):
    eyes.server_connector = fake_connector_class()
    driver = eyes.open(
        driver,
        "Applitools Eyes SDK",
        "Test Screenshot Too Big",
        {
            "width": 800,
            "height": 800
        },
    )
    r_info = eyes.server_connector.render_info()
    eyes.save_debug_screenshots = True
    screenshots = []
    eyes._selenium_eyes._debug_screenshots_provider.save = (
        lambda image, suffix: screenshots.append(image))
    driver.get("https://applitools.github.io/demo/TestPages/FramesTestPage/")
    driver.find_element_by_id("stretched").click()
    frame = driver.find_element_by_css_selector("#modal2 iframe")
    driver.switch_to.frame(frame)
    element = driver.find_element_by_tag_name("html")
    eyes.check("Step 1", Target.region(element).fully())
    eyes.close(False)

    image = screenshots[-1]
    assert r_info.max_image_height == image.height
Esempio n. 8
0
 def test_check_region_in_a_very_big_frame_after_manual_switch_frame(self):
     with self.driver.switch_to.frame_and_back("frame1"):
         element = self.driver.find_element(By.CSS_SELECTOR, "img")
         # TODO #112: fix bug execute_script method calling with EyesWebElement
         self.driver.execute_script("arguments[0].scrollIntoView(true);",
                                    element.element)
         self.eyes.check("", Target.region((By.CSS_SELECTOR, "img")))
Esempio n. 9
0
def test_check_element_with_ignore_region_by_element__fluent(eyes_opened):
    element = eyes_opened.driver.find_element_by_id("overflowing-div-image")
    ignore_element = eyes_opened.driver.find_element_by_id("overflowing-div")
    eyes_opened.check(
        "Fluent - Region by element - fully",
        Target.region(element).ignore(ignore_element),
    )
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)
Esempio n. 11
0
 def test_check_element_with_ignore_region_by_element_fluent(self):
     element = self.driver.find_element_by_id("overflowing-div-image")
     ignore_element = self.driver.find_element_by_id("overflowing-div")
     self.eyes.check(
         "Fluent - Region by element - fully",
         Target.region(element).ignore(ignore_element),
     )
def test_verify_flight_status_widget(eyes, driver):
    eyes.open(driver, "FlyDubai IBE", "Verify Flight Status Widget")
    driver.find_element_by_css_selector(
        'div.widgetBoxWrapper > ul li:nth-of-type(4)').click()
    eyes.check("FZ Manage Booking Widget",
               Target.region('div.widgetBoxWrapper'))
    eyes.close(False)
    def visual_check(self, eyes: Eyes, test: str, step: str, region=None):
        """
        Perform a visual check of a page or region.

        :param eyes: Applitools Eyes pytest fixture
        :param test: A name for the test in the batch
        :param step: A name for the step within the test
        :param region: (Optional) A locator tuple (selenium.webdriver By, locator value)
          of a region within the page to capture
        """
        try:
            # Call Open on eyes to initialize a test session
            eyes.open(self.driver,
                      app_name="AppliFashion",
                      test_name=test,
                      viewport_size={
                          "width": 1200,
                          "height": 800
                      })

            # Check the store page with fluent api
            # https://applitools.com/docs/topics/sdk/the-eyes-sdk-check-fluent-api.html
            if region:
                eyes.check(step, Target.region(region=region))
            else:
                eyes.check(step,
                           Target.window().fully().with_name("Store page"))

            # Call Close on eyes to let the server know it should display the results
            eyes.close_async()

        except Exception as e:
            eyes.abort_async()
            print(e)
def test_check_region_in_a_very_big_frame_after_manual_switch_to_frame(
        eyes_opened):
    eyes_opened.driver.switch_to.frame("frame1")

    element = eyes_opened.driver.find_element_by_tag_name("img")
    eyes_opened.driver.execute_script("arguments[0].scrollIntoView(true);",
                                      element.element)
    eyes_opened.check("", Target.region([By.CSS_SELECTOR, "img"]))
def test_capture_element_on_pre_scrolled_down_page(eyes, driver):
    driver.get(
        "http://applitools.github.io/demo/TestPages/FramesTestPage/longframe.html"
    )
    eyes.open(
        driver=driver,
        app_name="Applitools Eyes SDK",
        test_name="Test capture element on pre scrolled down page",
        viewport_size={
            "width": 800,
            "height": 600
        },
    )
    driver.execute_script("window.scrollTo(0, 300)")
    eyes.check("Row 10", Target.region("body > table > tr:nth-child(10)"))
    eyes.check("Row 20", Target.region("body > table > tr:nth-child(20)"))
    eyes.close()
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)
Esempio n. 17
0
def test_check_scrollable_modal(eyes_opened):
    eyes_opened.driver.find_element_by_id("centered").click()
    scroll_root_sel = ("#modal-content" if eyes_opened.stitch_mode
                       == StitchMode.CSS else "#modal")
    eyes_opened.check(
        "Scrollable Modal",
        Target.region("#modal-content").fully().scroll_root_element(
            scroll_root_sel),
    )
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)
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()
Esempio n. 20
0
def test_check_element_by_id(local_chrome_driver):
    local_chrome_driver.get(
        "https://applitools.github.io/demo/TestPages/FramesTestPage/")
    with Eyes() as eyes:
        eyes.open(
            local_chrome_driver,
            "USDK Test",
            "Test check element by id",
            {
                "width": 800,
                "height": 600
            },
        )
        eyes.check(Target.region([By.ID, "overflowing-div"]))
def test_w3schools_iframe(eyes, driver):
    driver = eyes.open(
        driver,
        app_name="Python SDK",
        test_name="W3 Schools frame",
        viewport_size={
            "width": 800,
            "height": 600
        },
    )
    driver.get(
        "https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe")
    eyes.check("Entire Frame",
               Target.region((By.TAG_NAME, "body"), "iframeResult"))
    eyes.close()
Esempio n. 22
0
def test_check_element_in_shadow(local_chrome_driver):
    local_chrome_driver.get(
        "https://applitools.github.io/demo/TestPages/ShadowDOM/index.html")
    with Eyes() as eyes:
        eyes.open(
            local_chrome_driver,
            "USDK Test",
            "Test check element in shadow dom",
            {
                "width": 800,
                "height": 600
            },
        )
        eyes.check(
            Target.region(TargetPath.shadow("#has-shadow-root").region("h1")))
Esempio n. 23
0
def ultra_fast_test(web_driver, eyes):
    try:
        web_driver.get(test_url_v2)
        eyes.open(web_driver, "Demo App", "Task2")
        web_driver.maximize_window()
        black_shoes_checkobx = web_driver.find_element_by_id("colors__Black")
        if not black_shoes_checkobx.is_selected():
            black_shoes_checkobx.click()
        filter_btn = web_driver.find_element_by_id("filterBtn")
        filter_btn.click()
        product_grid = web_driver.find_element_by_id("product_grid")
        eyes.check("product_grid", Target.region(product_grid))
        eyes.close_async()
    except Exception as e:
        eyes.abort_async()
        print(e)
Esempio n. 24
0
    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)
def test_send_DOM_Selector(eyes, driver, batch_info):
    driver.get(
        "https://applitools.github.io/demo/TestPages/DomTest/dom_capture.html")
    config = Configuration().set_batch(batch_info)
    eyes.set_configuration(config)
    eyes.open(
        driver,
        "Test SendDom",
        "Test SendDom",
        viewport_size={
            "width": 1000,
            "height": 700
        },
    )
    eyes.check("region", Target.region("#scroll1"))
    results = eyes.close(False)
    assert get_has_DOM(eyes.api_key, results)
Esempio n. 26
0
    def check_eyes_region(self,
                          left,
                          top,
                          width,
                          height,
                          name,
                          enable_http_debug_log=None,
                          matchtimeout=None,
                          hidescrollbars=None,
                          wait_before_screenshots=None,
                          matchlevel=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_http_debug_log, hidescrollbars,
                                wait_before_screenshots, matchlevel, None)

        region = Region(float(left), float(top), float(width), float(height))
        variables.eyes.check(name, Target.region(region).timeout(matchtimeout))

        utils.update_properties(**original_properties)
Esempio n. 27
0
def test_wix_site(eyes, driver):
    eyes.match_timeout = 0
    eyes.force_full_page_screenshot = False
    driver = eyes.open(driver, app_name="Python SDK", test_name="Wix example")
    # Sign in to the page
    driver.get(
        "https://eventstest.wixsite.com/events-page-e2e/events/ba837913-7dad-41b9-b530-6c2cbfc4c265"
    )
    iframe_id = "TPAMultiSection_j5ocg4p8iframe"
    driver.switch_to.frame(iframe_id)
    # click register button
    driver.find_element_by_css_selector("[data-hook=get-tickets-button]").click()
    # add one ticket
    driver.find_element_by_css_selector("[data-hook=plus-button]").click()
    # just an example, where it make us some problems with scrolling to top of the frame.
    # eyes.check_region(By.CSS_SELECTOR, "[data-hook=plus-button]");
    eyes.check("", Target.region("[data-hook=plus-button]"))
    eyes.close()
Esempio n. 28
0
    def check_region_by_selector(
            self,
            selector,  # type: Locator
            tag=None,  # type: Optional[Text]
            *check_settings_keywords  # type: tuple[Any]
    ):
        # type: (...) -> MatchResult
        """
        Check specified region by selector

            | =Arguments=   | =Description=                         |
            |  Selector     | *Mandatory* - The selector to check.  |

        *Example:*
            |  Eyes Check Region By Element  |  css:#selector  |
        """
        check_settings_keywords, tag = try_resolve_tag_and_keyword(
            tag, check_settings_keywords, self.defined_keywords)
        check_settings = collect_check_settings(
            Target.region(self.from_locator_to_supported_form(selector)),
            self.defined_keywords, *check_settings_keywords)
        return self.current_eyes.check(check_settings, tag)
Esempio n. 29
0
def test_scrollable_modal_on_scrolled_down_page(driver):
    driver.get("https://applitools.github.io/demo/TestPages/ModalsPage")
    eyes = Eyes()
    driver = eyes.open(
        driver,
        "TestModal",
        "ScrollableModalOnScrolledDownPage",
        RectangleSize(width=1024, height=768),
    )
    # Scroll page to the bottom-most paragraph
    driver.execute_script(
        "arguments[0].scrollIntoView()",
        driver.find_element_by_css_selector("body > main > p:nth-child(17)"),
    )
    # Show popup without clicking a button on top to avoid scrolling up
    driver.execute_script("openModal('scrollable_content_modal')")

    content = driver.find_element_by_css_selector(
        ".modal-content.modal-content--scrollable")
    eyes.check(Target.region(content).scroll_root_element(content).fully())

    eyes.close()
Esempio n. 30
0
    def check_region_by_coordinates(
            self,
            region,  # type: Locator
            tag=None,  # type: Optional[Text]
            *check_settings_keywords  # type: tuple[Any]
    ):
        # type: (...) -> MatchResult
        """
        Check specified region

          |  =Arguments=  | =Description=                                                       |
          |  Region       | *Mandatory* - The region to check in format [left top width height] ,e.g. [100 200 300 300]  |

        *Example:*
            |  Eyes Check Region By Coordinates   |  [40 50 200 448]  |
        """
        check_settings_keywords, tag = try_resolve_tag_and_keyword(
            tag, check_settings_keywords, self.defined_keywords)
        check_settings = collect_check_settings(
            Target.region(parse_region(region)), self.defined_keywords,
            *check_settings_keywords)
        return self.current_eyes.check(check_settings, tag)