當前位置: 首頁>>代碼示例>>Python>>正文


Python visual_test.VisualTest類代碼示例

本文整理匯總了Python中toolium.visual_test.VisualTest的典型用法代碼示例。如果您正苦於以下問題:Python VisualTest類的具體用法?Python VisualTest怎麽用?Python VisualTest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了VisualTest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_scrolls_size_firefox

def test_get_scrolls_size_firefox(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.config.set('Driver', 'type', 'firefox')
    visual = VisualTest(driver_wrapper)

    # Check chrome scrolls
    assert visual.get_scrolls_size() == {'x': 0, 'y': 0}
開發者ID:jframos,項目名稱:toolium,代碼行數:7,代碼來源:test_visual_test.py

示例2: test_no_enabled

def test_no_enabled(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.config.set('VisualTests', 'enabled', 'false')
    visual = VisualTest(driver_wrapper)

    visual.assert_screenshot(None, filename='screenshot_full', file_suffix='screenshot_suffix')
    driver_wrapper.driver.save_screenshot.assert_not_called()
開發者ID:jframos,項目名稱:toolium,代碼行數:7,代碼來源:test_visual_test.py

示例3: test_assert_screenshot_mobile_resize_and_exclude

def test_assert_screenshot_mobile_resize_and_exclude(driver_wrapper):
    # Create elements mock
    exclude_elements = [get_mock_element(x=0, y=0, height=24, width=375)]

    # Configure driver mock
    with open(file_ios, "rb") as f:
        image_data = f.read()
    driver_wrapper.driver.get_screenshot_as_png.return_value = image_data
    driver_wrapper.driver.get_window_size.return_value = {'width': 375, 'height': 667}

    # Update conf and create a new VisualTest instance
    driver_wrapper.config.set('Driver', 'type', 'ios')
    visual = VisualTest(driver_wrapper)

    # Assert screenshot
    visual.assert_screenshot(None, filename='screenshot_ios', file_suffix='screenshot_suffix',
                             exclude_elements=exclude_elements)
    driver_wrapper.driver.get_screenshot_as_png.assert_called_once_with()

    # Check cropped image
    expected_image = os.path.join(root_path, 'resources', 'ios_excluded.png')
    output_file = os.path.join(visual.output_directory, '01_screenshot_ios__screenshot_suffix.png')
    PilEngine().assertSameFiles(output_file, expected_image, 0.1)

    # Output image and new baseline image must be equals
    baseline_file = os.path.join(root_path, 'output', 'visualtests', 'baseline', 'firefox',
                                 'screenshot_ios.png')
    PilEngine().assertSameFiles(output_file, baseline_file, 0.1)
開發者ID:Telefonica,項目名稱:toolium,代碼行數:28,代碼來源:test_visual_test.py

示例4: test_assert_screenshot_mobile_web_resize_and_exclude

def test_assert_screenshot_mobile_web_resize_and_exclude(driver_wrapper):
    # Create elements mock
    driver_wrapper.driver.execute_script.return_value = 0  # scrollX=0 and scrollY=0
    form_element = get_mock_element(x=0, y=0, height=559, width=375)
    exclude_elements = [get_mock_element(x=15, y=296.515625, height=32, width=345)]

    # Configure driver mock
    file_ios_web = os.path.join(root_path, 'resources', 'ios_web.png')
    with open(file_ios_web, "rb") as f:
        image_data = f.read()
    driver_wrapper.driver.get_screenshot_as_png.return_value = image_data
    driver_wrapper.driver.get_window_size.return_value = {'width': 375, 'height': 667}

    # Update conf and create a new VisualTest instance
    driver_wrapper.config.set('Driver', 'type', 'ios')
    driver_wrapper.config.set('AppiumCapabilities', 'browserName', 'safari')
    visual = VisualTest(driver_wrapper)

    # Assert screenshot
    visual.assert_screenshot(form_element, filename='screenshot_ios_web', file_suffix='screenshot_suffix',
                             exclude_elements=exclude_elements)
    driver_wrapper.driver.get_screenshot_as_png.assert_called_once_with()

    # Check cropped image
    expected_image = os.path.join(root_path, 'resources', 'ios_web_exclude.png')
    output_file = os.path.join(visual.output_directory, '01_screenshot_ios_web__screenshot_suffix.png')
    MagickEngine().assertSameFiles(output_file, expected_image, 0.1)

    # Output image and new baseline image must be equal
    baseline_file = os.path.join(root_path, 'output', 'visualtests', 'baseline', 'firefox', 'screenshot_ios_web.png')
    MagickEngine().assertSameFiles(output_file, baseline_file, 0.1)
開發者ID:jframos,項目名稱:toolium,代碼行數:31,代碼來源:test_visual_test.py

示例5: test_get_html_row

def test_get_html_row(driver_wrapper):
    expected_row = '<tr class=diff><td>report_name</td><td><img style="width: 100%" onclick=' \
                   '"launchModal\(this.src\)" src=".*register_v2.png"/></td></td><td><img style="width: 100%" ' \
                   'onclick="launchModal\(this.src\)" src=".*register.png"/></td></td><td></td></tr>'
    visual = VisualTest(driver_wrapper)
    row = visual._get_html_row('diff', 'report_name', file_v1, file_v2)
    assert re.compile(expected_row).match(row) is not None
開發者ID:Telefonica,項目名稱:toolium,代碼行數:7,代碼來源:test_visual_test.py

示例6: test_compare_files_size_fail

def test_compare_files_size_fail(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.config.set('VisualTests', 'fail', 'true')
    visual = VisualTest(driver_wrapper)

    with pytest.raises(AssertionError):
        visual.compare_files('report_name', file_v1, file_small, 0)
開發者ID:jframos,項目名稱:toolium,代碼行數:7,代碼來源:test_visual_test.py

示例7: test_exclude_no_elements

def test_exclude_no_elements(driver_wrapper):
    # Exclude no elements
    visual = VisualTest(driver_wrapper)
    img = Image.open(file_v1)
    img = visual.exclude_elements(img, [])

    # Assert output image
    assert_image(visual, img, 'report_name', 'register')
開發者ID:jframos,項目名稱:toolium,代碼行數:8,代碼來源:test_visual_test.py

示例8: test_get_scrolls_size_iexplore

def test_get_scrolls_size_iexplore(driver_wrapper):
    # Update conf and create a new VisualTest instance
    # Mock scrollHeight, scrollWidth, innerHeight, innerWidth
    driver_wrapper.driver.execute_script.side_effect = [600, 1200, 400, 900]
    driver_wrapper.config.set('Driver', 'type', 'iexplore')
    visual = VisualTest(driver_wrapper)

    # Check chrome scrolls
    assert visual.get_scrolls_size() == {'x': 21, 'y': 21}
開發者ID:jframos,項目名稱:toolium,代碼行數:9,代碼來源:test_visual_test.py

示例9: test_exclude_elements

def test_exclude_elements(driver_wrapper):
    # Create elements mock
    visual = VisualTest(driver_wrapper)
    web_elements = [get_mock_element(x=250, y=40, height=40, width=300),
                    get_mock_element(x=250, y=90, height=20, width=100)]
    img = Image.open(file_v1)  # Exclude elements
    img = visual.exclude_elements(img, web_elements)

    # Assert output image
    assert_image(visual, img, 'report_name', 'register_exclude')
開發者ID:Telefonica,項目名稱:toolium,代碼行數:10,代碼來源:test_visual_test.py

示例10: test_exclude_elements

def test_exclude_elements(driver_wrapper):
    # Create elements mock
    driver_wrapper.driver.execute_script.return_value = 0  # scrollX=0 and scrollY=0
    visual = VisualTest(driver_wrapper)
    web_elements = [get_mock_element(x=250, y=40, height=40, width=300),
                    get_mock_element(x=250, y=90, height=20, width=100)]
    img = Image.open(file_v1)  # Exclude elements
    img = visual.exclude_elements(img, web_elements)

    # Assert output image
    assert_image(visual, img, 'report_name', 'register_exclude')
開發者ID:jframos,項目名稱:toolium,代碼行數:11,代碼來源:test_visual_test.py

示例11: test_crop_element

def test_crop_element(driver_wrapper):
    # Create element mock
    web_element = get_mock_element(x=250, y=40, height=40, width=300)
    visual = VisualTest(driver_wrapper)

    # Resize image
    img = Image.open(file_v1)
    img = visual.crop_element(img, web_element)

    # Assert output image
    assert_image(visual, img, 'report_name', 'register_cropped_element')
開發者ID:Telefonica,項目名稱:toolium,代碼行數:11,代碼來源:test_visual_test.py

示例12: test_remove_scrolls_without_scroll

def test_remove_scrolls_without_scroll(driver_wrapper):
    # Create a new VisualTest instance
    visual = VisualTest(driver_wrapper)
    visual.get_scrolls_size = lambda: {'x': 0, 'y': 0}

    # Remove scroll
    img = Image.open(file_scroll)
    img = visual.remove_scrolls(img)

    # Assert output image
    assert_image(visual, img, 'report_name', 'register_chrome_scroll')
開發者ID:jframos,項目名稱:toolium,代碼行數:11,代碼來源:test_visual_test.py

示例13: test_mobile_resize

def test_mobile_resize(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.driver.get_window_size.return_value = {'width': 375, 'height': 667}
    driver_wrapper.config.set('Driver', 'type', 'ios')
    visual = VisualTest(driver_wrapper)

    # Resize image
    img = Image.open(file_ios)
    img = visual.mobile_resize(img)

    # Assert output image
    assert_image(visual, img, 'report_name', 'ios_resized')
開發者ID:jframos,項目名稱:toolium,代碼行數:12,代碼來源:test_visual_test.py

示例14: test_mobile_no_resize

def test_mobile_no_resize(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.driver.get_window_size.return_value = {'width': 750, 'height': 1334}
    driver_wrapper.config.set('Driver', 'type', 'ios')
    visual = VisualTest(driver_wrapper)

    # Resize image
    orig_img = Image.open(file_ios)
    img = visual.mobile_resize(orig_img)

    # Assert that image object has not been modified
    assert orig_img == img
開發者ID:jframos,項目名稱:toolium,代碼行數:12,代碼來源:test_visual_test.py

示例15: test_crop_element

def test_crop_element(driver_wrapper):
    # Create element mock
    driver_wrapper.driver.execute_script.return_value = 0  # scrollX=0 and scrollY=0
    web_element = get_mock_element(x=250, y=40, height=40, width=300)
    visual = VisualTest(driver_wrapper)

    # Resize image
    img = Image.open(file_v1)
    img = visual.crop_element(img, web_element)

    # Assert output image
    assert_image(visual, img, 'report_name', 'register_cropped_element')
開發者ID:jframos,項目名稱:toolium,代碼行數:12,代碼來源:test_visual_test.py


注:本文中的toolium.visual_test.VisualTest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。