Beispiel #1
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
Beispiel #2
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 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)
Beispiel #4
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())
Beispiel #5
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())
 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 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()
     )
Beispiel #9
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
Beispiel #12
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_default_rendering_of_multiple_targets(driver, vg_runner):
    driver.get("https://applitools.com/helloworld")
    eyes = Eyes(vg_runner)
    eyes.configuration.add_browser(800, 600, BrowserType.CHROME)
    eyes.configuration.add_browser(800, 600, BrowserType.FIREFOX)
    eyes.configuration.add_browser(1200, 800, BrowserType.CHROME)
    eyes.configuration.add_browser(1200, 800, BrowserType.FIREFOX)
    eyes.configuration.app_name = "TestDefaultRendering"
    eyes.configuration.test_name = "TestDefaultRenderingOfMultipleTargets"

    try:
        eyes.open(driver)
        eyes.check("", Target.window())
        eyes.close()
    finally:
        eyes.abort()

    all_test_results = vg_runner.get_all_test_results()
    batch_id = None
    batch_name = None
    for trc in all_test_results:
        if batch_id is None:
            batch_id = trc.test_results.batch_id
        if batch_name is None:
            batch_name = trc.test_results.batch_name

        assert batch_id == trc.test_results.batch_id
        assert batch_name == trc.test_results.batch_name
    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_ufg_options(driver, fake_connector_class):
    runner = VisualGridRunner(1)
    eyes = Eyes(runner)
    eyes.server_connector = fake_connector_class()

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

    driver.get("https://google.com")
    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()
    runner.get_all_test_results()

    request_options = eyes.server_connector.input_calls["render"][0][0].options
    assert request_options == {
        "option1": 5,
        "option2": False,
        "option3": "value3",
        "option4": 5,
    }
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)),
    )
def step_impl(context):
    title = context.browser.title
    assert "Person" in context.browser.find_element_by_css_selector(
        Locators.PERSONTYPE).text
    assert "Location" in context.browser.find_element_by_css_selector(
        Locators.LOCATIONTYPE).text
    assert "Resource" in context.browser.find_element_by_css_selector(
        Locators.RESOURCETYPE).text
    assert "Categories" in context.browser.find_element_by_css_selector(
        Locators.CATEGORYTYPE).text
    assert "Tags" in context.browser.find_element_by_css_selector(
        Locators.TAGSTYPE).text

    eyes.open(context.browser, "CFAHome",
              "Search Filters - No filters selected")
    # Take Screenshot
    eyes.match_level = MatchLevel.LAYOUT
    #eyes.force_full_page_screenshot = True
    eyes.check(context.browser.current_url, Target.window())
    # # End the test.
    eyes.close()

    print(
        u'STEP: Then I should see the "Person Type","Location Type", "Resource Type","Categories" and "Tags" filter'
    )
def test_coded_layout_regions_passed_to_match_window_request(
        driver, fake_connector_class, vg_runner, spy):
    eyes = Eyes(vg_runner)
    eyes.server_connector = fake_connector_class()
    driver.get(
        "https://applitools.github.io/demo/TestPages/SimpleTestPage/index.html"
    )
    eyes.open(driver, "Test Visual Grid",
              "Test regions are passed to render request")

    eyes.check(Target.window().fully().layout(Region(1, 2, 3, 4)).floating(
        5, Region(6, 7, 8,
                  9)).accessibility(Region(10, 11, 12, 13),
                                    AccessibilityRegionType.LargeText))

    eyes.close_async()
    server_connector = vg_runner._get_all_running_tests(
    )[0].eyes.server_connector
    vg_runner.get_all_test_results(False)
    _, match_data = server_connector.input_calls["match_window"][0]
    ims = match_data.options.image_match_settings

    assert len(server_connector.input_calls["match_window"]) == 1
    assert ims.layout_regions == [Region(1, 2, 3, 4)]
    assert ims.floating_match_settings == [
        FloatingMatchSettings(Region(6, 7, 8, 9), FloatingBounds(5, 5, 5, 5))
    ]
    assert ims.accessibility == [
        AccessibilityRegion(10, 11, 12, 13, AccessibilityRegionType.LargeText)
    ]
def test_modern_approach_demo_task3(py, py_eyes):
    try:
        # Navigate to the url we want to test
        py.visit(py.config.custom['environment']['url'])

        # Filter Black Shoes
        filterBlack = py.get('#colors__Black')
        filterBlack.click()
        filterBlack.is_checked()
        py.get('#filterBtn').click()

        # Open the first result
        py.find('#product_grid').first().click()

        # Call Open on eyes to initialize a test session
        py_eyes.open(py.webdriver, "Cross Browser Testing Demo App", "Task 3", {"width": 800, "height": 600})

        # Check the app page
        py_eyes.check("Task 3",
                      Target.window().fully().with_name("Product Details test"))

        # Call Close on eyes to let the server know it should display the results
        py_eyes.close_async()
    except Exception as e:
        py_eyes.abort_async()
        print(e)
Beispiel #20
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_dynamic_content(self):
     self.driver.get(self.URL + "?showAd=true")
     self.login_page.login("username", "password")
     main_page = MainPage(self.driver)
     self.eyes.check(self._testMethodName, Target.window())
     self.assertTrue(main_page.get_element_flash_sale().is_displayed())
     self.assertTrue(main_page.get_element_flash_sale_2().is_displayed())
Beispiel #22
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_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)
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"] == []
Beispiel #25
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(),
     )
Beispiel #26
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,
        }
Beispiel #27
0
    def test_login_applitools_tc1(self):
        testcase_result = "Failed"

        try:
            logger = self.logger
            logger.info('Starting Testcase: test_login')
            driver = self.driver
            username = self.base.get_data("tc1", "username")
            password = self.base.get_data("tc1", "password")
            if driver is not None:
                #login
                print("before login")
                login = LoginPageTestSteps(driver, logger)
                navigate = login.navigate_to_login_page()
                print("after navigate to login")
                try:
                    self.eyes.open(driver=driver,
                                   app_name="SauceDemo",
                                   test_name="LoginScreen")
                    self.eyes.check("Logintest", Target.window())  #eyes
                    self.eyes.close(False)  #eyes close
                except Exception as e:
                    self.logger.error(e)
                    print(e)
                user = login.set_username(username)
                passd = login.set_password(password)
                login_btn = login.click_login_button()
                try:
                    self.eyes.open(driver=driver,
                                   app_name="SauceDemo",
                                   test_name="WelcomeScreen")
                    self.eyes.check("WelcomeTest", Target.window())  #eyes
                    self.eyes.close(False)  #eyes close
                except Exception as e:
                    print(e)
                self.terminate_driver(driver)

                if (navigate or user or passd or login_btn) is not False:
                    testcase_result = 'Passed'
            else:
                logger.info('problem initiating WebDriver')
        except Exception as e:
            self.logger.error(e)
            testcase_result = False
        self.base.set_result("tc1", "test_result", testcase_result)
        time.sleep(1)
        return testcase_result
    def test_table_sort(self):
        self.login_page.login("username", "password")
        main_page = MainPage(self.login_page.driver)
        amounts_before_sort = main_page.get_amounts_float()
        data_before_sort = main_page.get_row_data()
        # let's test to make sure it isn't already sorted!
        self.assertNotEqual(amounts_before_sort, sorted(amounts_before_sort))
        self.eyes.check(self._testMethodName + " before sort", Target.window())

        main_page.get_element_amount_header().click()
        amounts_after_sort = main_page.get_amounts_float()
        data_after_sort = main_page.get_row_data()
        self.eyes.check(self._testMethodName + " after sort", Target.window())

        self.assertNotEqual(amounts_before_sort, amounts_after_sort)
        self.assertEqual(amounts_after_sort, sorted(amounts_after_sort))
        [self.assertTrue(row in data_after_sort) for row in data_before_sort]
def test_abort_eyes(eyes, driver):
    eyes.open(driver, "Test Abort", "Test Abort", {
        "width": 1200,
        "height": 800
    })
    eyes.check("SEL", Target.window())
    time.sleep(15)
    eyes.abort()
def step_impl(context):
    eyes.open(context.browser, "CFAHome", "Search Buckets - No filters selected")
    eyes.match_level = MatchLevel.LAYOUT
    #eyes.force_full_page_screenshot = True
    eyes.check(context.browser.current_url + " Verify Search Page", Target.window())

    # # End the test.
    eyes.close()