Ejemplo n.º 1
0
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,
    }
Ejemplo n.º 2
0
def test_render_resource_not_found(driver, fake_connector_class, spy):
    driver.get("http://applitools.github.io/demo/DomSnapshot/test-visual-grid.html")
    missing_blob_url = "http://applitools.github.io/blabla"
    missing_resource_url = "http://localhost:7374/get-cors.css"

    vg_runner = VisualGridRunner(1)
    eyes = Eyes(vg_runner)
    eyes.server_connector = fake_connector_class()
    eyes.open(
        driver,
        app_name="Visual Grid Render Test",
        test_name="TestRenderResourceNotFound",
    )

    running_test = vg_runner._get_all_running_tests()[0]
    rc_task_factory_spy = spy(VisualGridEyes, "_resource_collection_task")

    eyes.check_window("check")
    eyes.close(False)
    vg_runner.get_all_test_results(False)

    blobs = rc_task_factory_spy.call_args.args[4]["blobs"]
    error_blob = [b for b in blobs if b["url"] == missing_blob_url][-1]
    assert error_blob["errorStatusCode"] == 404
    assert error_blob["url"] == missing_blob_url

    render_request = eyes.server_connector.calls["render"][0]
    assert render_request.resources[missing_blob_url].error_status_code == "404"
    assert render_request.resources[missing_resource_url].error_status_code in [
        "404",
        "444",
        "503",
    ]
Ejemplo n.º 3
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,
        }
Ejemplo n.º 4
0
def test_get_all_vg_test_results(local_chrome_driver):
    local_chrome_driver.get(
        "https://applitools.github.io/demo/TestPages/SimpleTestPage")
    runner = VisualGridRunner()
    eyes1 = Eyes(runner)
    eyes1.open(
        local_chrome_driver,
        "USDK Test",
        "Test get all vg test results 1",
        {
            "width": 800,
            "height": 600
        },
    )
    eyes1.check_window()
    results = [eyes1.close()]
    eyes2 = Eyes(runner)
    eyes2.open(
        local_chrome_driver,
        "USDK Test",
        "Test get all vg test results 2",
        {
            "width": 800,
            "height": 600
        },
    )
    eyes2.check_window()
    results.append(eyes2.close())

    all_results = runner.get_all_test_results()

    assert len(all_results) == 2
    assert results[0] == all_results[0].test_results
    assert results[1] == all_results[1].test_results
def runner_setup():
    """
    One test runner for all tests. Print test results at the end of execution.
    """
    runner = VisualGridRunner(10)
    yield runner
    all_test_results = runner.get_all_test_results()
    print(all_test_results)
Ejemplo n.º 6
0
def runner_setup(request):
    if request.config.getoption("--eyes-mode")=='fast':
        runner= VisualGridRunner(1)
    else:
        runner = ClassicRunner()
    yield runner
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)
Ejemplo n.º 7
0
def test_visual_grid_runner_runner_started_logging(fake_connector_class):
    connector = fake_connector_class()
    runner = VisualGridRunner()

    runner._send_runner_started_log_message(connector)

    event = connector.input_calls["send_logs"][0][0]
    assert event.level.value == 2
    assert event.event == '{"defaultConcurrency": 5, "type": "runnerStarted"}'
Ejemplo n.º 8
0
def eyes(request):
    if request.param == "selenium":
        return Eyes(ClassicRunner())
    elif request.param == "visual_grid":
        return Eyes(VisualGridRunner())
    else:
        raise ValueError("invalid internal test config")
def test_special_rendering(url, test_name, batch_info, driver):
    runner = VisualGridRunner(30)
    eyes = Eyes(runner)
    sconf = Configuration(
        test_name=test_name, app_name="Visual Grid Render Test", batch=batch_info
    )
    sconf.add_device_emulation(DeviceName.Galaxy_S5)
    sconf.add_browser(1200, 800, BrowserType.CHROME)
    sconf.add_browser(1200, 800, BrowserType.FIREFOX)

    eyes.set_configuration(sconf)
    eyes.open(driver)
    driver.get(url)
    datetime_utils.sleep(500)
    eyes.check(test_name, Target.window().fully())
    eyes.close(False)
    all_results = runner.get_all_test_results(False)
def run_test():
    # Create a runner with concurrency of 10
    runner = VisualGridRunner(10)

    # Initialize Eyes with Visual Grid Runner
    eyes = initialize_eyes(runner)

    # Create a new Webdriver, ChromeDriverManager is uses for detect or download the chromedriver
    driver = Chrome(ChromeDriverManager().install())

    # Navigate to the URL we want to test
    driver.get("https://demo.applitools.com")

    # To see visual bugs, change the above URL to:
    # driver.get("https://demo.applitools.com/index_v2.html")
    # https://demo.applitools.com/index_v2.html and run the test again

    # Call Open on eyes to initialize a test session
    eyes.open(driver)

    # Check the Login page
    eyes.check("Step 1 - Login page", Target.window().fully())

    # Click on the Login button to go to the App's main page
    driver.find_element_by_id("log-in").click()

    # Check the App page
    eyes.check("Step 2 - App Page", Target.window().fully())

    driver.quit()
    print(
        "Please wait... we are now: \n1. Uploading resources, \n2. Rendering in Visual Grid, "
        "and \n3. Using Applitools A.I. to validate the checkpoints. \nIt'll take about 30 "
        "secs to a minute...")

    # Close eyes and collect results
    # This could be used instead of close_async and get_all_test_results
    # eyes.close()

    # Send close task
    eyes.close_async()

    # Return test results from all eyes instances
    all_test_results = runner.get_all_test_results()
    print(all_test_results)
Ejemplo n.º 11
0
def test_get_all_vg_test_results_all_desktop_browsers(local_chrome_driver):
    local_chrome_driver.get(
        "https://applitools.github.io/demo/TestPages/SimpleTestPage")
    runner = VisualGridRunner(5)
    eyes = Eyes(runner)
    for browser_type in BrowserType:
        eyes.configure.add_browser(DesktopBrowserInfo(800, 600, browser_type))

    eyes.open(
        local_chrome_driver,
        "USDK Test",
        "Test get all vg test results all browsers",
    )
    eyes.check_window()
    eyes.close_async()
    all_results = runner.get_all_test_results()

    assert len(all_results) == 16
Ejemplo n.º 12
0
def test_ufg_skip_list(driver, fake_connector_class, spy):
    vg_runner = VisualGridRunner(1)
    eyes = Eyes(vg_runner)
    eyes.server_connector = fake_connector_class()
    driver.get("https://applitools.github.io/demo/TestPages/"
               "VisualGridTestPageWithRelativeBGImage/index.html")
    eyes.open(driver, app_name="TestUFGEyes", test_name="TestUFGSkipList")
    running_test = vg_runner._get_all_running_tests()[0]
    create_dom_snapshot_spy = spy(dom_snapshot_script, "create_dom_snapshot")
    check_spy = spy(running_test, "check")

    eyes.check_window("check 1")
    eyes.check_window("check 2")
    eyes.check_window("check 3")
    eyes.close(False)

    skip_list = create_dom_snapshot_spy.call_args.args[2]
    script_result = _retrieve_urls(check_spy.call_args.kwargs["script_result"])
    assert set(skip_list) - set(script_result["resource_urls"])
Ejemplo n.º 13
0
def test_mobile_only(driver, batch_info):
    runner = VisualGridRunner(30)
    eyes = Eyes(runner)

    sconf = Configuration()
    sconf.test_name = "Mobile Render Test"
    sconf.app_name = "Visual Grid Render Test"
    sconf.batch = batch_info

    sconf.add_device_emulation(DeviceName.Galaxy_S5)

    eyes.set_configuration(sconf)
    eyes.open(driver)
    driver.get(
        "https://applitools.github.io/demo/TestPages/DynamicResolution/mobile.html"
    )
    eyes.check("Test Mobile Only", Target.window().fully())
    eyes.close()
    all_results = runner.get_all_test_results()
Ejemplo n.º 14
0
def test_create_open_check_close_vg_eyes(local_chrome_driver):
    local_chrome_driver.get(
        "https://applitools.github.io/demo/TestPages/SimpleTestPage")
    runner = VisualGridRunner()
    eyes = Eyes(runner)
    eyes.open(
        local_chrome_driver,
        "USDK Test",
        "Test create open VG eyes",
        {
            "width": 800,
            "height": 600
        },
    )
    check_result = eyes.check_window()
    eyes.close_async()
    all_results = runner.get_all_test_results().all_results

    assert check_result is None
    assert len(all_results) == 1
    assert all_results[0].test_results.is_passed
def py_eyes():
    runner = VisualGridRunner(10)
    py_eyes = Eyes(runner)
    # You can get your api key from the Applitools dashboard
    api_key = os.environ["APPLITOOLS_API_KEY"]
    py_eyes.configure.set_api_key(api_key)

    # create a new batch info instance and set it to the configuration
    py_eyes.configure.set_batch(BatchInfo("UFG Hackaton"))

    # Add browsers with different viewports
    # Add mobile emulation devices in Portrait mode
    (py_eyes.configure.add_browser(1200, 700, BrowserType.CHROME).add_browser(
        1200, 700, BrowserType.FIREFOX).add_browser(
            1200, 700, BrowserType.EDGE_CHROMIUM).add_browser(
                768, 700, BrowserType.CHROME).add_browser(
                    1200, 700, BrowserType.FIREFOX).add_browser(
                        1200, 700,
                        BrowserType.EDGE_CHROMIUM).add_device_emulation(
                            DeviceName.iPhone_X)  # Portrait mode
     )
    yield py_eyes
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)
def tear_down(web_driver, runner):
    # Close the browser
    print("Closing the browser.")
    web_driver.close()

    print("Running UFG and creating Batch in Dashboard")
    # we pass false to this method to suppress the exception that is thrown if we
    # find visual differences
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)


# Create a new chrome web driver
web_driver = Chrome(ChromeDriverManager().install())

# Create a runner with concurrency of 1
runner = VisualGridRunner(concurrency)

# Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
eyes = Eyes(runner)

set_up(eyes)

try:
    # ⭐️ Note to see visual bugs, run the test using the above URL for the 1st run.
    # but then change the above URL to https://demo.applitools.com/index_v2.html
    # (for the 2nd run)
    ultra_fast_test(web_driver, eyes)
finally:
    tear_down(web_driver, runner)
Ejemplo n.º 17
0
import pytest

from applitools.common import Region
from applitools.core import VisualLocator
from applitools.selenium import ClassicRunner, Eyes, VisualGridRunner


@pytest.mark.parametrize("eyes_runner", [ClassicRunner(), VisualGridRunner(1)])
def test_visual_locator(driver, eyes_runner):
    driver.get("https://applitools.github.io/demo/TestPages/FramesTestPage/")
    eyes = Eyes(eyes_runner)
    test_name = "testVisualLocators"
    if isinstance(eyes_runner, VisualGridRunner):
        test_name += "_VG"
    eyes.open(driver, "Applitools Eyes SDK", test_name)

    result = eyes.locate(VisualLocator.name("applitools_title"))
    eyes.close_async()

    assert len(result) == 1
    assert result["applitools_title"][0] == Region(3, 19, 158, 38)
Ejemplo n.º 18
0
def runner_setup():
    """One test runner for all tests."""
    concurrent_sessions = 5
    runner = VisualGridRunner(concurrent_sessions)
    yield runner
Ejemplo n.º 19
0

def test_eyes_none_runner(driver):
    eyes = Eyes(None)
    eyes.configuration.hide_scrollbars = True
    driver.get("https://applitools.github.io/demo/TestPages/FramesTestPage/")
    eyes.open(
        driver, "Eyes Selenium SDK - Null Runner", "TestSeleniumEyesWithNullRunner"
    )
    eyes.check_window()
    eyes.close()


@pytest.mark.parametrize(
    "runner",
    [VisualGridRunner(10), ClassicRunner()],
    ids=lambda o: "VG" if isinstance(o, VisualGridRunner) else "CR",
)
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
Ejemplo n.º 20
0
def test_viewports_test(driver, batch_info):
    runner = VisualGridRunner(30)
    eyes = Eyes(runner)

    sconf = Configuration()
    sconf.batch = batch_info
    sconf.test_name = "Viewport Size Test"
    sconf.app_name = "Visual Grid Viewports Test"
    sconf.hide_scrollbars = True
    sconf.stitch_mode = StitchMode.CSS
    sconf.force_full_page_screenshot = True
    sconf.match_level = MatchLevel.STRICT

    sconf.add_browser(800, 600, BrowserType.CHROME)
    sconf.add_browser(700, 500, BrowserType.CHROME)
    sconf.add_browser(1200, 800, BrowserType.CHROME)
    sconf.add_browser(1600, 1200, BrowserType.CHROME)
    sconf.add_browser(800, 600, BrowserType.FIREFOX)
    sconf.add_browser(700, 500, BrowserType.FIREFOX)
    sconf.add_browser(1200, 800, BrowserType.FIREFOX)
    sconf.add_browser(1600, 1200, BrowserType.FIREFOX)
    sconf.add_browser(800, 600, BrowserType.EDGE)
    sconf.add_browser(700, 500, BrowserType.EDGE)
    sconf.add_browser(1200, 800, BrowserType.EDGE)
    # sconf.add_browser(1600, 1200, BrowserType.EDGE)
    sconf.add_browser(800, 600, BrowserType.IE_11)
    sconf.add_browser(700, 500, BrowserType.IE_11)
    sconf.add_browser(1200, 800, BrowserType.IE_11)
    # sconf.add_browser(1600, 1200, BrowserType.IE_11)
    sconf.add_browser(800, 600, BrowserType.IE_10)
    sconf.add_browser(700, 500, BrowserType.IE_10)
    sconf.add_browser(1200, 800, BrowserType.IE_10)
    # sconf.add_browser(1600, 1200, BrowserType.IE_10)
    eyes.set_configuration(sconf)

    eyes.open(driver)
    driver.get("https://www.applitools.com")
    eyes.check("Test Viewport", Target.window().fully())
    eyes.close_async()

    all_results = runner.get_all_test_results(False)
    assert len(sconf.browsers_info) > len(BrowserType)
    assert len(all_results) == len(sconf.browsers_info)

    results = defaultdict(set)
    for trc in all_results:
        assert trc
        session_results = None
        try:
            session_results = get_session_results(eyes.api_key, trc.test_results)
        except Exception as e:
            logger.exception(e)

        if session_results is None:
            logger.debug("Error: session_results is null for item {}".format(trc))
            continue

        env = session_results["env"]
        browser = env["hostingAppInfo"]
        if browser is None:
            logger.debug("Error: HostingAppInfo (browser) is null. {}".format(trc))
            continue

        sizes_list = results[browser]
        display_size = RectangleSize.from_(env["displaySize"])
        if display_size in sizes_list:
            assert (
                False
            ), "Browser {} viewport size {} already exists in results.".format(
                browser, display_size
            )
        sizes_list.add(display_size)
    assert len(results) == 5
Ejemplo n.º 21
0
        filter_btn.click()
        first_shoe_detail = web_driver.find_element_by_id("A____217")
        if first_shoe_detail.is_displayed():
            first_shoe_detail.click()

        else:
            print("Shoe details link is not displayed in order to click")
        eyes.check("", Target.window().fully())
        eyes.close_async()
    except Exception as e:
        eyes.abort_async()
        print(e)


def tear_down(web_driver, runner):
    web_driver.quit()
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)


web_driver = Chrome(ChromeDriverManager().install())
consecutive_runs = 10
runner = VisualGridRunner(consecutive_runs)
eyes = Eyes(runner)
set_up(eyes)

try:
    ultra_fast_test(web_driver, eyes)
finally:
    tear_down(web_driver, runner)
Ejemplo n.º 22
0
 def eyes_runner_class():
     return lambda: VisualGridRunner(1)
Ejemplo n.º 23
0
def pytest_generate_tests(metafunc):
    metafunc.parametrize("eyes_runner", [ClassicRunner(), VisualGridRunner(1)])
Ejemplo n.º 24
0

def tear_down(web_driver, runner):
    # Close the browser
    web_driver.quit()

    # we pass false to this method to suppress the exception that is thrown if we
    # find visual differences
    all_test_results = runner.get_all_test_results(False)
    print(all_test_results)


# Create a new chrome web driver
web_driver = Chrome(ChromeDriverManager().install())

# Create a runner with concurrency of 1
runner = VisualGridRunner(1)

# Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
eyes = Eyes(runner)

set_up(eyes)

try:
    # ⭐️ Note to see visual bugs, run the test using the above URL for the 1st run.
    # but then change the above URL to https://demo.applitools.com/index_v2.html
    # (for the 2nd run)
    ultra_fast_test(web_driver, eyes)
finally:
    tear_down(web_driver, runner)
Ejemplo n.º 25
0
def vg_runner():
    vg = VisualGridRunner(10)
    return vg
Ejemplo n.º 26
0
    def open_eyes_grid_session(
        self,
        apikey=None,
        appname=None,
        testname=None,
        library=None,
        width=None,
        height=None,
        osname=None,
        browsername=None,
        matchlevel=None,
        enable_eyes_log=None,
        enable_http_debug_log=None,
        baselinename=None,
        batch=None,
        branchname=None,
        parentbranch=None,
        serverurl=None,
        force_full_page_screenshot=None,
        stitchmode=None,
        matchtimeout=None,
        hidescrollbars=None,
        save_new_tests=None,
        wait_before_screenshots=None,
        send_dom=None,
        stitchcontent=False,
        isdisabled=None,
    ):
        """
        Starts a grid session (=test) with Applitools.

        Some of the following arguments may also be defined on library import.
        See `Before running tests` or `Importing`.

            | =Arguments=                       | =Description=                                                                                                                               |
            | API Key (str)                     | *Mandatory* - User's Applitools Eyes key                                                                                                    |
            | Application Name (str)            | *Mandatory* - The name of the application under test                                                                                        |
            | Test Name (str)                   | *Mandatory* - The test name                                                                                                                 |
            | Library (str)                     | Library to test (Either SeleniumLibrary or AppiumLibrary)                                                                                   |
            | Width (int)                       | The width of the browser window e.g. 1280                                                                                                   |
            | Height (int)                      | The height of the browser window e.g. 1000                                                                                                  |
            | Operating System (str)            | The operating system of the test, can be used to override the OS name to allow cross OS verification                                        |
            | Browser Name (str)                | The browser name for the test, can be used to override the browser name to allow cross browser verification                                 |
            | Match Level (str)                 | The match level for the comparison of this test's checkpoints - can be STRICT, LAYOUT, CONTENT or EXACT                                     |
            | Enable Eyes Log (bool)            | Determines if the trace logs of Applitools Eyes SDK are activated for this session                                                          |
            | Enable HTTP Debug Log (bool)      | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable                                               |
            | Baseline Name (str)               | Name of the branch where the baseline reference will be taken from and where new and accepted steps will be saved to                        |
            | Batch (str or BatchInfo)          | The desired batch. See `Group tests into batches`                                                                                           |
            | Branch Name (str)                 | The branch to use to check test                                                                                                             |
            | Parent Branch (str)               | Parent Branch to base the new Branch on                                                                                                     |
            | Server URL (str)                  | The URL of the Eyes server. If not provided then your test will run on the public cloud                                                     |
            | Force Full Page Screenshot (bool) | Will force the browser to take a screenshot of whole page                                                                                   |
            | Stitch Mode (str)                 | Type of stitching used for full page screenshots - can be CSS or SCROLL                                                                     |
            | Match Timeout (int)               | Determines how much time in milliseconds Eyes continues to retry the matching before declaring a mismatch on this test checkpoints          |
            | Hide Scrollbars (bool)            | Sets if the scrollbars are hidden this session's tests, by passing 'True' or 'False' in the variable                                        |
            | Save New Tests (bool)             | Sets if the new checkpoints on this session are automatically accepted, by passing 'True' or 'False' in the variable                        |
            | Wait Before Screenshots (int)     | Determines the number of milliseconds that Eyes will wait before capturing a screenshot on this test checkpoints                            |
            | Send DOM (bool)                   | Sets if DOM information should be sent for this session's checkpoints                                                                       |
            | Stitch Content (bool)             | If this test checkpoint's elements/region are scrollable, determines if Eyes will scroll this them to take a full region/element screenshot |
            | Is Disabled (bool)                | Determines whether or not interactions with Eyes will be silently ignored for this test                                                     |

        *Mandatory Arguments:* They may be defined through this keyword, or when importing the library.
        In order to run a test, provide at least the API Key, Application Name and Test Name.

        When opening the session on a mobile browser or hybrid app, the context must be set to WEBVIEW in order to retrieve the correct viewport size. Geolocation of the device may have to be set after switching context.

        *Example:*
            | Open Eyes Grid Session  | YourApplitoolsKey | AppName | TestName | SeleniumLibrary | 1024 | 768 | OSOverrideName | BrowserOverrideName | layout | ${true} | batchname=BatchName | serverurl=https://myserver.com |
        """

        if appname is None:
            appname = self.library_arguments["appname"]
        if testname is None:
            testname = self.library_arguments["testname"]
        if apikey is None:
            apikey = self.library_arguments["apikey"]
        if library is None:
            library = self.library_arguments["library"]
        if osname is None:
            osname = self.library_arguments["osname"]
        if browsername is None:
            browsername = self.library_arguments["browsername"]
        if matchlevel is None:
            matchlevel = self.library_arguments["matchlevel"]
        if enable_eyes_log is None:
            enable_eyes_log = self.library_arguments["enable_eyes_log"]
        if serverurl is None:
            serverurl = self.library_arguments["serverurl"]
        if save_new_tests is None:
            save_new_tests = self.library_arguments["save_new_tests"]
        if matchtimeout is None:
            matchtimeout = self.library_arguments["matchtimeout"]

        # Create a runner with concurrency of 1
        runner = VisualGridRunner(1)
        # Create Eyes object with the runner, meaning it'll be a Visual Grid eyes.
        variables.eyes = Eyes(runner)

        variables.eyes.api_key = apikey

        # Add browsers with different viewports
        # Add mobile emulation devices in Portrait mode
        (variables.eyes.configure.add_browser(
            800, 600, BrowserType.CHROME).add_browser(
                700, 500, BrowserType.FIREFOX).add_browser(
                    1600, 1200, BrowserType.IE_11).add_browser(
                        1024, 768, BrowserType.EDGE_CHROMIUM).add_browser(
                            800, 600, BrowserType.SAFARI).add_device_emulation(
                                DeviceName.iPhone_X).add_device_emulation(
                                    DeviceName.Pixel_2))

        try:
            libraryInstance = BuiltIn().get_library_instance(library)

            if library == "AppiumLibrary":
                driver = libraryInstance._current_application()
            else:
                driver = libraryInstance.driver
        except RuntimeError:
            raise Exception("%s instance not found" % library)

        utils.manage_logging(enable_eyes_log, enable_http_debug_log)

        if osname is not None:
            variables.eyes.host_os = osname
        if browsername is not None:
            variables.eyes.host_app = browsername
        if baselinename is not None:
            variables.eyes.baseline_branch_name = baselinename
        if batch is not None:
            if type(batch) is six.text_type:
                batch = str(batch)
            batches_list = variables.batches

            # If batch argument is string
            if isinstance(batch, str):
                # Check for batch with same name
                for batch_element in batches_list:
                    if batch_element.name == batch:
                        variables.eyes.batch = batch_element
                        break
                # If a batch with this name is not yet on the list
                if variables.eyes.batch is None:
                    new_batch = BatchInfo(batch)
                    variables.eyes.batch = new_batch
                    variables.batches.append(new_batch)
            # If batch argument is BatchInfo
            else:
                # Check for batch with same name and date
                for batch_element in batches_list:
                    if (batch_element.name == batch.name
                            and batch_element.started_at == batch.started_at):
                        variables.eyes.batch = batch_element
                        break
                # If the list doesn't contain a batch with the same name and date
                if variables.eyes.batch is None:
                    variables.eyes.batch = batch
                    variables.batches.append(batch)

        if matchlevel is not None:
            variables.eyes.match_level = utils.get_match_level(matchlevel)
        if parentbranch is not None:
            variables.eyes.parent_branch_name = parentbranch
        if branchname is not None:
            variables.eyes.branch_name = branchname
        if osname is not None:
            variables.eyes.host_os = osname
        if stitchmode is not None:
            variables.eyes.stitch_mode = utils.get_stitch_mode(stitchmode)
        if matchtimeout is not None:
            variables.eyes.match_timeout = int(matchtimeout)
        if force_full_page_screenshot is not None:
            variables.eyes.force_full_page_screenshot = force_full_page_screenshot
        if save_new_tests is not None:
            variables.eyes.save_new_tests = save_new_tests
        if wait_before_screenshots is not None:
            variables.eyes.wait_before_screenshots = int(
                wait_before_screenshots)
        if send_dom is not None:
            variables.eyes.send_dom = send_dom
        if stitchcontent is not False:
            variables.stitchcontent = stitchcontent

        if width is None and height is None:
            variables.driver = variables.eyes.open(driver, appname, testname)
        else:
            variables.driver = variables.eyes.open(driver, appname, testname, {
                "width": int(width),
                "height": int(height)
            })

        # Workaround - This property has to be called after opening session
        # Otherwise, the checks will throw exceptions
        if isdisabled is not None:
            variables.eyes.is_disabled = isdisabled
Ejemplo n.º 27
0
def vg_eyes():
    vgr = VisualGridRunner(1)
    eyes = Eyes(vgr)
    eyes.configuration.add_browser(700, 460, BrowserType.CHROME)
    return eyes