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)
Exemple #2
0
 def test_check_frame_in_frame_fully_fluent2(self):
     self.eyes.check("Fluent - Window with Ignore region 2",
                     Target.window().fully())
     self.eyes.check(
         "Fluent - Full Frame in Frame 2",
         Target.frame("frame1").frame("frame1-1").fully(),
     )
Exemple #3
0
def test_double_open_check_close_async_with_different_instances(
        driver, eyes_runner, name_suffix):
    eyes1 = Eyes(eyes_runner)
    driver.get(
        "https://applitools.github.io/demo/TestPages/VisualGridTestPage/")
    eyes1.open(
        driver,
        "Applitools Eyes SDK",
        "TestDoubleOpenCheckCloseAsyncWithDifferentInstances" + name_suffix,
        dict(width=1200, height=800),
    )
    eyes1.check("Step 1", Target.window().fully().ignore_displacements(False))
    eyes1.close_async()

    eyes2 = Eyes(eyes_runner)
    eyes2.open(
        driver,
        "Applitools Eyes SDK",
        "TestDoubleOpenCheckCloseAsyncWithDifferentInstances" + name_suffix,
        dict(width=1200, height=800),
    )
    eyes2.check("Step 2", Target.window().fully().ignore_displacements(False))
    eyes2.close_async()

    all_test_results = eyes_runner.get_all_test_results(False)
    assert len(all_test_results.all_results) == 2
Exemple #4
0
 def test_scrollbars_hidden_and_returned_fluent(self):
     self.eyes.check("Fluent - Window (Before)", Target.window().fully())
     self.eyes.check(
         "Fluent - Inner frame div",
         Target.frame("frame1").region("#inner-frame-div").fully(),
     )
     self.eyes.check("Fluent - Window (After)", Target.window().fully())
Exemple #5
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)),
        )
Exemple #6
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
def ultra_fast_test(web_driver, eyes, url):
    try:
        # Navigate to the url we want to test
        web_driver.get(url)

        # Call Open on eyes to initialize a test session
        eyes.open(web_driver, "Demo App", "Ultrafast grid demo", {
            "width": 800,
            "height": 600
        })

        # check the login page with fluent api, see more info here
        # https://applitools.com/docs/topics/sdk/the-eyes-sdk-check-fluent-api.html
        eyes.check("", Target.window().fully().with_name("Login page"))

        web_driver.find_element_by_id("log-in").click()

        # Check the app page
        eyes.check("", Target.window().fully().with_name("App 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)
Exemple #8
0
def test_scrollbars_hidden_and_returned__fluent(eyes_opened):
    eyes_opened.check("Fluent - Window (Before)", Target.window().fully())
    eyes_opened.check(
        "Fluent - Inner frame div",
        Target.frame("frame1").region("#inner-frame-div").fully(),
    )
    eyes_opened.check("Fluent - Window (After)", Target.window().fully())
Exemple #9
0
def test_demo_app(driver, eyes):
    try:
        # Set AUT's name, test name and viewport size (width X height)
        # We have set it to 800 x 600 to accommodate various screens. Feel free to change it.
        eyes.open(driver, "Demo App", "Smoke Test", {
            "width": 800,
            "height": 600
        })

        # Navigate the browser to the "ACME" demo app.
        driver.get("https://demo.applitools.com")

        # To see visual bugs after the first run, use the commented line below instead.
        # driver.get("https://demo.applitools.com/index_v2.html");

        # Visual checkpoint #1 - Check the login page. using the fluent API
        # https://applitools.com/docs/topics/sdk/the-eyes-sdk-check-fluent-api.html?Highlight=fluent%20api
        eyes.check("", Target.window().fully().with_name("Login Window"))

        #This will create a test with two test steps
        driver.find_element_by_id("log-in").click()

        # Visual checkpoint #2 - Check the app page.
        eyes.check("", Target.window().fully().with_name("App Window"))

        # End the test.
        eyes.close_async()
    except Exception as e:
        #If the test was aborted before eyes.close was called, ends the test as aborted.
        eyes.abort_async()
        print(e)
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 test_data_driver_c(self):
     self.eyes.check(
         self._testMethodName + " before clicking login", Target.window()
     )
     self.login_page.login("", "password")
     element = self.login_page.get_element_log_in_error()
     self.eyes.check(self._testMethodName + " after clicking login", Target.window())
     self.assertTrue(element, "The error does not exist on the page")
     self.assertTrue(element.is_displayed, "The error does not exist on the page")
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),
    )
    def test_data_driven_a(self):
        """Test to ensure error is visible when you do not enter a username or password"""
        self.eyes.check(
            self._testMethodName + " before clicking login", Target.window()
        )
        self.login_page.login("", "")

        element = self.login_page.get_element_log_in_error()
        self.eyes.check(self._testMethodName + " after clicking login", Target.window())
        self.assertTrue(element, "The error does not exist on the page")
        self.assertTrue(element.is_displayed, "The error is not visible on the page")
 def test_canvas_chart(self):
     self.login_page.login("username", "password")
     main_page = MainPage(self.login_page.driver)
     main_page.get_element_compare_expenses().click()
     self.eyes.check(
         self._testMethodName + " before adding next year ", Target.window()
     )
     main_page.get_element_show_data_for_next_year().click()
     self.eyes.check(
         self._testMethodName + " after adding next year ", Target.window()
     )
def test_charts_with_scroll_root_fluent(eyes_opened):
    eyes_opened.configure.add_property("Fluent", True)
    eyes_opened.check(
        Target.frame("mainFrame").frame("angularContainerIframe").region(
            "mv-temperature-sensor-graph").scroll_root_element(
                "mat-sidenav-content"))

    eyes_opened.check(
        Target.frame("mainFrame").frame("angularContainerIframe").region(
            "mv-humidity-sensor-graph").scroll_root_element(
                "mat-sidenav-content"))
Exemple #16
0
def test_double_check_dont_get_all_results(driver, eyes_runner, name_suffix):
    eyes = Eyes(eyes_runner)
    driver.get("https://applitools.com/helloworld")
    eyes.open(
        driver,
        "Applitools Eyes SDK",
        "TestDoubleCheckDontGetAllResults" + name_suffix,
        dict(width=1200, height=800),
    )
    eyes.check("Step 1", Target.window().with_name("Step 1"))
    eyes.check("Step 2", Target.window().with_name("Step 2"))
    eyes.close(False)
 def test_data_driven_d(self):
     self.eyes.check(
         self._testMethodName + " before clicking login", Target.window()
     )
     self.login_page.login("username", "password")
     main_page = MainPage(self.login_page.driver)
     self.eyes.check(self._testMethodName + " after clicking login", Target.window())
     success, elements_not_found, elements_not_visible = main_page.Validate()
     self.assertTrue(
         success,
         f"elements not found: {elements_not_found}\nelements not "
         f"visible: {elements_not_visible}",
     )
def test_eyes_runner(driver, runner):
    eyes = Eyes(runner)
    eyes2 = Eyes(runner)
    batch_info = BatchInfo("Runner Testing")
    config = (
        Configuration()
        .set_send_dom(True)
        .set_hide_scrollbars(True)
        .set_stitch_mode(StitchMode.CSS)
        .set_batch(batch_info)
    )
    eyes.set_configuration(config)
    eyes2.set_configuration(config)
    driver.get(
        "http://applitools.github.io/demo/TestPages/VisualGridTestPage/index.html"
    )
    eyes.add_property(
        "Runner", "VisualGrid" if isinstance(runner, VisualGridRunner) else "Selenium"
    )
    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes2.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner 2 Test",
        dict(width=1200, height=800),
    )

    eyes.check("Step 1", Target.window().fully().ignore_displacements(False))
    eyes2.check("Step 1", Target.window().fully().ignore_displacements(False))

    eyes.close_async()

    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes.check("Step 2", Target.window().fully().ignore_displacements(False))
    eyes.close_async()
    eyes2.close(True)

    driver.quit()
    all_tests_results = runner.get_all_test_results()
    if len(all_tests_results.all_results) != 3:
        raise Exception
Exemple #19
0
def test_eyes_runner(driver, runner):
    eyes = Eyes(runner)
    eyes2 = Eyes(runner)
    eyes.server_url = "https://eyes.applitools.com/"

    eyes.send_dom = True
    eyes2.send_dom = False
    eyes.stitch_mode = StitchMode.CSS
    eyes2.stitch_mode = StitchMode.CSS

    batch_info = BatchInfo("Runner Testing")
    batch_info.id = "RCA_Batch_ID"
    eyes.batch_info = batch_info
    eyes2.batch_info = batch_info

    driver.get(
        "http://applitools.github.io/demo/TestPages/VisualGridTestPage/index.html"
    )

    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes2.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner 2 Test",
        dict(width=1200, height=800),
    )

    eyes.check("Step 1", Target.window().fully().ignore_displacements(False))
    eyes2.check("Step 1", Target.window().fully().ignore_displacements(False))

    eyes.close_async()

    eyes.open(
        driver,
        "Applitools Eyes Java SDK",
        "Classic Runner Test",
        dict(width=1200, height=800),
    )
    eyes.check("Step 2", Target.window().fully().ignore_displacements(False))
    eyes.close_async()
    eyes2.close(True)

    driver.quit()
    all_tests_results = runner.get_all_test_results()
    if len(all_tests_results.all_results) != 3:
        raise Exception
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()
Exemple #22
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_fluent_info_api_serialization(use_dom, enable_patterns,
                                       ignore_displacements, match_level, eyes,
                                       screenshot):
    settings = (Target.window().fully().use_dom(use_dom).enable_patterns(
        enable_patterns).ignore_displacements(
            ignore_displacements).match_level(match_level))
    image_match_settings = MatchWindowTask.create_image_match_settings(
        settings, eyes)
    assert image_match_settings.match_level == match_level
    assert image_match_settings.use_dom == use_dom
    assert image_match_settings.enable_patterns == enable_patterns
    assert image_match_settings.ignore_displacements == ignore_displacements
    assert image_match_settings.ignore_regions == []
    assert image_match_settings.strict_regions == []
    # assert image_match_settings.accessibility == []
    assert image_match_settings.layout_regions == []
    assert image_match_settings.content_regions == []
    assert image_match_settings.floating_match_settings == []

    serialized_img = json.loads(json_utils.to_json(image_match_settings))
    assert serialized_img["matchLevel"] == match_level.value
    assert serialized_img["useDom"] == use_dom
    assert serialized_img["enablePatterns"] == enable_patterns
    assert serialized_img["ignoreDisplacements"] == ignore_displacements
    assert serialized_img["Ignore"] == []
    assert serialized_img["Layout"] == []
    assert serialized_img["Strict"] == []
    assert serialized_img["Content"] == []
    assert serialized_img["Floating"] == []
Exemple #24
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),
    )
Exemple #25
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)),
    )
Exemple #26
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")))
Exemple #27
0
def test_ufg_options(driver):
    runner = VisualGridRunner(1)
    eyes = Eyes(runner)

    (eyes.configure.add_browser(800, 600,
                                BrowserType.CHROME).set_visual_grid_options(
                                    VisualGridOption("option1", "value1"),
                                    VisualGridOption("option2", False)))

    driver.get("https://google.com")
    with patch("applitools.core.server_connector.ServerConnector.render"
               ) as patched:
        eyes.open(driver, "Mock app", "Mock Test")
        eyes.check(
            "",
            Target.window().visual_grid_options(
                VisualGridOption("option3", "value3"),
                VisualGridOption("option4", 5),
                VisualGridOption("option1", 5),
            ),
        )
        eyes.close_async()
        res = runner.get_all_test_results()

        request_options = patched.call_args.args[0].options
        assert request_options == {
            "option1": 5,
            "option2": False,
            "option3": "value3",
            "option4": 5,
        }
Exemple #28
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(),
     )
def test_image_match_settings_serialization(use_dom, enable_patterns,
                                            ignore_displacements, match_level,
                                            eyes, screenshot):
    settings = (Target.window().fully().use_dom(use_dom).enable_patterns(
        enable_patterns).ignore_displacements(
            ignore_displacements).match_level(match_level))
    exact_match_settings = ExactMatchSettings()
    exact_match_settings.match_threshold = 0.5
    eyes.configure.default_match_settings = ImageMatchSettings(
        match_level=MatchLevel.EXACT,
        exact=exact_match_settings,
        use_dom=use_dom)
    image_match_settings = MatchWindowTask.create_image_match_settings(
        settings, eyes)
    assert image_match_settings.match_level == match_level
    assert image_match_settings.use_dom == use_dom
    assert image_match_settings.enable_patterns == enable_patterns
    assert image_match_settings.ignore_displacements == ignore_displacements
    assert (image_match_settings.exact.match_threshold ==
            exact_match_settings.match_threshold)

    serialized_img = json.loads(json_utils.to_json(image_match_settings))
    assert serialized_img["matchLevel"] == match_level.value
    assert serialized_img["useDom"] == use_dom
    assert serialized_img["enablePatterns"] == enable_patterns
    assert serialized_img["ignoreDisplacements"] == ignore_displacements
    assert (serialized_img["exact"]["minDiffIntensity"] ==
            exact_match_settings.min_diff_intensity)
    assert (serialized_img["exact"]["minDiffWidth"] ==
            exact_match_settings.min_diff_width)
    assert (serialized_img["exact"]["minDiffHeight"] ==
            exact_match_settings.min_diff_height)
    assert (serialized_img["exact"]["matchThreshold"] ==
            exact_match_settings.match_threshold)
Exemple #30
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),
     )