def get_step_DOM(eyes, results): session_results = get_session_results(eyes.api_key, results) actualAppOutputs = session_results["actualAppOutput"] dom_id = actualAppOutputs[0]["image"]["domId"] url = urlunsplit( urlsplit(eyes.server_url)._replace(path="/api/images/dom/" + dom_id, query=urlencode( {"apiKey": eyes.api_key}))) res = requests.get(url) return res.json()
def check_image_match_settings(eyes, test_result, comparision): session_results = get_session_results(eyes.api_key, test_result) img = session_results["actualAppOutput"][0]["imageMatchSettings"] for param in comparision: actual = img[param["actual_name"]] expected = param["expected"] if attr.has(expected.__class__): actual = attr_from_dict(actual, expected.__class__) elif isinstance(expected, list): expected_cls = expected[0].__class__ actual = [attr_from_dict(a, expected_cls) for a in actual] assert actual == expected
def test_check_element_and_window_in_sequence(driver, eyes, batch_info, vg_runner): driver.get("https://demo.applitools.com") eyes = Eyes(vg_runner) eyes.set_configuration( Configuration( test_name="TestCheckElementAndWindow", app_name="Visual Grid Additional Test", batch=batch_info, ).add_browser(1024, 768, BrowserType.CHROME)) eyes.open(driver) eyes.check_window("Step 1") eyes.check( "Step 2", Target.region("body > div > div").layout( "body > div > div > form > div:nth-child(1)"), ) eyes.check( "Step 3", Target.window().ignore("body > div > div > form > div:nth-child(1)"), ) eyes.close_async() trc = vg_runner.get_all_test_results().all_results[0] session_results = get_session_results(eyes.api_key, trc.test_results) actual_output = session_results["actualAppOutput"] assert len(actual_output[1]["imageMatchSettings"]["layout"]) == 1 assert actual_output[1]["imageMatchSettings"]["layout"][0] == { "left": 80, "top": 322, "width": 290, "height": 62, } assert len(actual_output[2]["imageMatchSettings"]["ignore"]) == 1 assert actual_output[2]["imageMatchSettings"]["ignore"][0] == { "left": 367, "top": 322, "width": 290, "height": 62, }
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
def get_has_DOM(api_key, results): session_results = get_session_results(api_key, results) actualAppOutputs = session_results["actualAppOutput"] assert len(actualAppOutputs) == 1 return actualAppOutputs[0]["image"]["hasDom"]