def runner_setup(): """ One test runner for all tests. Print test results in the end of execution. """ runner = ClassicRunner() yield runner all_test_results = runner.get_all_test_results() print(all_test_results)
def test_classic_runner_raise_exception(driver): classic_runner = ClassicRunner() eyes = Eyes(classic_runner) eyes.open( driver, "Applitools Eyes Java SDK", "Classic Runner Test", dict(width=1200, height=800), ) eyes.check("Step 1", Target.window()) eyes.close(False) with pytest.raises(Exception): classic_runner.get_all_test_results()
def test_classic_runner_works_normally(driver): classic_runner = ClassicRunner() eyes = Eyes(classic_runner) driver.get("https://applitools.github.io/demo/TestPages/FramesTestPage/") eyes.open( driver, "Applitools Eyes Java SDK", "Classic Runner Test", dict(width=1200, height=800), ) eyes.check("Step 1", Target.window()) eyes.close(False) print(classic_runner.get_all_test_results())
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 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)
def __init__(self): self.base = BaseTestClass() self.logger = self.base.logger self.driver = self.base.driver runner = ClassicRunner() self.eyes = Eyes(runner) # Initialize the eyes SDK and set your private API key. self.eyes.api_key = "" self.view_port_size = {"width": 800, "height": 600} self.eyes.set_viewport_size(driver=self.driver, size=self.view_port_size)
def test_get_all_test_results(local_chrome_driver): local_chrome_driver.get( "https://applitools.github.io/demo/TestPages/SimpleTestPage") runner = ClassicRunner() eyes1 = Eyes(runner) eyes1.configure.set_hide_scrollbars(False) eyes1.open(local_chrome_driver, "USDK Test", "Test get all test results 1") eyes1.check_window() results = [eyes1.close()] eyes2 = Eyes(runner) eyes2.configure.set_hide_scrollbars(False) eyes2.open(local_chrome_driver, "USDK Test", "Test get all test results 2") 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
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)
def pytest_generate_tests(metafunc): metafunc.parametrize("eyes_runner", [ClassicRunner(), VisualGridRunner(1)])
classic_runner.get_all_test_results() def test_eyes_none_runner(driver): eyes = Eyes(None) eyes.configure.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(False) @pytest.mark.parametrize( "runner", [ClassicRunner()], ids=lambda o: "VG" if isinstance(o, VisualGridRunner) else "CR", ) 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",
def eyes_runner_class(): return lambda: ClassicRunner()
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
def configuration_keyword(eyes_library_with_selenium): eyes_library_with_selenium.eyes_runner = ClassicRunner() keyword = ConfigurationKeywords(eyes_library_with_selenium) return keyword
def session_keyword(eyes_library_with_selenium): eyes_library_with_selenium.eyes_runner = ClassicRunner() keyword = SessionKeywords(eyes_library_with_selenium) return keyword
def runner_setup(): """One test runner for all tests.""" runner = ClassicRunner() yield runner
eyes.abort_async() print(e) def tear_down(driver, runner): driver.quit() # Wait and collect all test results # 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 results print(all_test_results) # Use Chrome browser driver = Chrome(ChromeDriverManager().install()) # Initialize the Runner for your test. runner = ClassicRunner() # Initialize the eyes SDK eyes = Eyes(runner) set_up(eyes) try: test_demo_app(driver, eyes) finally: tear_down(driver, runner)