def test_happyflow_1_chrome_click_accept_and_continue(json_metadata): json_metadata['TEST_ID'] = 'TID_003' selenium_url = 'http://{}:4444/wd/hub'.format(SELENIUM_HUB_HOST) chrome_options = webdriver.ChromeOptions() mobile_emulation = {"deviceName": "Nexus 5"} chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) browser = webdriver.Remote( command_executor=selenium_url, desired_capabilities=chrome_options.to_capabilities()) # URL = 'http://192.168.88.105:8002/' # browser.get(URL) browser.get(FOOD_PAGE) sleep(1) fl_page = first_time_landing.MainPage(browser) fl_page.checkAcceptAndContinueButtonExist() fl_page.takeScreenshot(ACTUAL_SCREENSHOT) # fl_page.checkLinkExist() browser.quit() sleep(30) assertSameImage(EXPECTED_SCREENSHOT, ACTUAL_SCREENSHOT, 0.1, 'first time landing test after clicking accept failed')
def assertCheckPoint(driver ,check_point_name, error_message, fail_threshold=0.054, sleep_s=0.5, make_asserts=True): sleep(sleep_s) actual_screenshot_path=getActualScreenshotPath(check_point_name) expected_screenshot_path=getExpectedScreenshotPath(check_point_name) takeScreenshot(driver, actual_screenshot_path) if make_asserts: assertSameImage(expected_screenshot_path, actual_screenshot_path,fail_threshold, error_message)
def test_happyflow_1_firefox(json_metadata): json_metadata['TEST_ID'] = 'TID_002' selenium_url = 'http://{}:4444/wd/hub'.format(SELENIUM_HUB_HOST) browser = webdriver.Remote( command_executor=selenium_url, desired_capabilities = { "browserName":"firefox", "version":"", # "platform":"LINUX" }) browser.get(FOOD_PAGE) browser.set_window_size(width, height) sleep(1) browser.save_screenshot(ACTUAL_SCREENSHOT) browser.quit() sleep(30) assertSameImage(EXPECTED_SCREENSHOT, ACTUAL_SCREENSHOT,IMAGE_TEST_THRESHOLD, 'first time landing test on firefox failed')
def test_happyflow_1_chrome(json_metadata): json_metadata['TEST_ID'] = 'TID_001' selenium_url = 'http://{}:4444/wd/hub'.format(SELENIUM_HUB_HOST) chrome_options = webdriver.ChromeOptions() mobile_emulation = {"deviceName": "Nexus 5"} chrome_options.add_experimental_option("mobileEmulation", mobile_emulation) # browser = webdriver.Remote( # command_executor=selenium_url, # desired_capabilities = { # "browserName":"chrome", # "version":"", # # "platform":"LINUX" # }, # desired_capabilities = chrome_options.to_capabilities() # ) # https://chromedriver.chromium.org/mobile-emulation browser = webdriver.Remote( command_executor=selenium_url, desired_capabilities=chrome_options.to_capabilities()) browser.get(FOOD_PAGE) # browser.set_window_size(width, height) sleep(1) browser.save_screenshot(ACTUAL_SCREENSHOT) browser.quit() sleep(30) assertSameImage(EXPECTED_SCREENSHOT, ACTUAL_SCREENSHOT, IMAGE_TEST_THRESHOLD, 'first time landing test on chrome failed')
def test_assert_image_testCall(): assertSameImage(TEST_PAIR_0_5_A, TEST_PAIR_0_5_B, 0.1, 'hello error message') pass