def test_create_two_batch_info_both_have_same_id(monkeypatch): monkeypatch.delenv("APPLITOOLS_BATCH_ID") bi1 = BatchInfo() bi2 = BatchInfo() assert bi1.id == PROCESS_DEFAULT_BATCH_ID assert bi2.id == PROCESS_DEFAULT_BATCH_ID
def test_set_batch_id_in_different_ways(): raw_id = "2020-02-24T15:51:08.098515" bi = BatchInfo().with_batch_id(raw_id) assert bi.id == raw_id bi = BatchInfo() bi.id = raw_id assert bi.id == raw_id with patch.dict(os.environ, {"APPLITOOLS_BATCH_ID": "some id"}): bi = BatchInfo() assert bi.id == "some id"
class Table_Sort_Test: eyes = Eyes() eyes.api_key = TestData.API_KEY try: driver = webdriver.Chrome() eyes.open(driver, TestData.APP_NAME, "Table Sort", TestData.VIEW_PORT) batch = BatchInfo('Data Driven Test') driver.get(TestData.BASE_URL) btnlogin = driver.find_element(By.XPATH, '//*[@id="log-in"]') txtusername = driver.find_element(By.ID, 'username') txtpassword = driver.find_element(By.ID, 'password') txtusername.clear() txtusername.send_keys(TestData.USERNAME) txtpassword.clear() txtpassword.send_keys(TestData.PASSWORD) btnlogin.click() driver.execute_script( "window.scrollTo(0, document.body.scrollHeight);") eyes.check_window('Validate values before sorting Amount column', 10) amount = driver.find_element(By.ID, 'amount') amount.click() eyes.check_window('Validate amount column after sorting', 10) eyes.close() finally: driver.quit() eyes.abort()
class ValidateLoginUIElements(): eyes = Eyes() # Initialize the eyes SDK and set your private API key. eyes.api_key = TestData.API_KEY try: # Open a Chrome browser. driver = webdriver.Chrome() eyes.open(driver, TestData.APP_NAME, "Validate Login UI Elements", TestData.VIEW_PORT) batch = BatchInfo('Login UI Test') driver.get(TestData.BASE_URL) eyes.check_window('Login UI Elements', 10) # End the test. eyes.close() finally: # Close the browser. driver.quit() # If the test was aborted before eyes.close was called, ends the test as aborted. eyes.abort()
class CanvasChart: eyes = Eyes() eyes.api_key = TestData.API_KEY try: driver = webdriver.Chrome() eyes.open(driver, TestData.APP_NAME, "Canvas Chart", TestData.VIEW_PORT) batch = BatchInfo('Canvas Chart Test') driver.get(TestData.BASE_URL) btnlogin = driver.find_element(By.XPATH, '//*[@id="log-in"]') txtusername = driver.find_element(By.ID, 'username') txtpassword = driver.find_element(By.ID, 'password') txtusername.clear() txtusername.send_keys(TestData.USERNAME) txtpassword.clear() txtpassword.send_keys(TestData.PASSWORD) btnlogin.click() compare_exp = driver.find_element(By.ID, 'showExpensesChart') compare_exp.click() eyes.check_window('Validate expenses between 2017 and 2018', 10) show_data = driver.find_element(By.ID, 'addDataset') show_data.click() eyes.check_window('Validate expenses between 2017, 2018 and 2019', 10) eyes.close() finally: driver.quit() eyes.abort()
def test_serialization_of_batch_info(): bi = BatchInfo(name="Name", batch_sequence_name="BatchName").with_batch_id("custom-id") res = json.loads(json_utils.to_json(bi)) print(res) assert res["name"] == "Name" assert res["batchSequenceName"] == "BatchName" assert res["notifyOnCompletion"] == False assert res["id"] == "custom-id"
def setBatching(self, value): b = BatchInfo(value) b.id_ = value self.eyes.batch = b self.eyes.open(self.driver, "Test app", value, { 'width': 1680, 'height': 800 }) self.eyes.force_full_page_screenshot = True self.eyes.use_css_transition = True
def setUp(self): self.eyes = Eyes() self.eyes.api_key = os.environ.get("APPLITOOLS_API_KEY") batch = BatchInfo("Hackathon") batch.id_ = '666' self.eyes.batch = batch super().setUp() self.eyes.open( self.driver, "Hackathon", self._testMethodName, {"width": self.BROWSER_WIDTH, "height": self.BROWSER_HEIGHT}, )
def test_create_batch_info(monkeypatch): now = datetime.now() batch_name = "Name" monkeypatch.delenv("APPLITOOLS_BATCH_ID") with patch("applitools.common.config.datetime") as mocked_datetime: mocked_datetime.now.return_value = now bi = BatchInfo(batch_name) bi.sequence_name = "sequence name" assert bi.name == batch_name assert bi.id == PROCESS_DEFAULT_BATCH_ID assert bi.started_at == now assert bi.sequence_name == "sequence name"
def test_set_env_params_in_batch_info(): with patch.dict( os.environ, { "APPLITOOLS_BATCH_NAME": "name", "APPLITOOLS_BATCH_ID": "id", "APPLITOOLS_BATCH_SEQUENCE": "sequence name", }, ): bi = BatchInfo() assert bi.name == "name" assert bi.id == "id" assert bi.sequence_name == "sequence name"
class DataDriven(): eyes = Eyes() eyes.api_key = TestData.API_KEY try: driver = webdriver.Chrome() eyes.open(driver, TestData.APP_NAME, "Data Driven Test", TestData.VIEW_PORT) batch = BatchInfo('Data Driven Test') driver.get(TestData.BASE_URL) btnlogin = driver.find_element(By.XPATH, '//*[@id="log-in"]') btnlogin.click() eyes.check_window('Username and Password alert window check', 10) txtusername = driver.find_element(By.ID, 'username') txtpassword = driver.find_element(By.ID, 'password') chkremember = driver.find_element(By.CLASS_NAME, 'form-check-input') txtusername.click() txtusername.send_keys(TestData.USERNAME) btnlogin.click() eyes.check_window('Entered username only alert check', 10) txtusername.clear() txtpassword.send_keys(TestData.PASSWORD) btnlogin.click() eyes.check_window('Entered password only alert check', 10) txtusername.click() txtusername.send_keys(TestData.USERNAME) chkremember.click() btnlogin.click() eyes.check_window('Verify that the user has successfully logged in', 10) driver.back() eyes.check_window( 'Verify that the username is remembered and Remember Me checkbox is checked', 10) # End the test. eyes.close() finally: # Close the browser. driver.quit() # If the test was aborted before eyes.close was called, ends the test as aborted. eyes.abort()
def test_create_batch_info(monkeypatch): uuid_value = str(uuid.uuid4()) now = datetime.now() batch_name = "Name" monkeypatch.delenv("APPLITOOLS_BATCH_ID") with patch("uuid.uuid4") as mock_uuid: mock_uuid.return_value = uuid_value with patch("applitools.common.config.datetime") as mocked_datetime: mocked_datetime.now.return_value = now bi = BatchInfo(batch_name) bi.sequence_name = "sequence name" assert bi.name == batch_name assert bi.id == uuid_value assert bi.started_at == now assert bi.sequence_name == "sequence name"
def _start_session(self): # type: () -> None logger.debug("_start_session()") self.__ensure_viewport_size() # initialization of Eyes parameters if empty from ENV variables if self.configure.batch is None: logger.info("No Batch set") self.configure.batch = BatchInfo() else: logger.info("Batch is {}".format(self.configure.batch)) self._server_connector.update_config(self.get_configuration()) self._create_session_start_info() # Actually start the session. self._running_session = self._server_connector.start_session( self._session_start_info) self._should_match_once_on_timeout = self._running_session.is_new_session
class DynamicContent: eyes = Eyes() eyes.api_key = TestData.API_KEY try: driver = webdriver.Chrome() eyes.open(driver, TestData.APP_NAME, "Dynamic Content", TestData.VIEW_PORT) batch = BatchInfo('Dynamic Content') driver.get(TestData.FLASH_SALE_URL) eyes.check_window('Validate flash sale GIFs are displayed', 10) eyes.close() finally: # Close the browser. driver.quit() # If the test was aborted before eyes.close was called, ends the test as aborted. eyes.abort()
def test_create_batch_with_batch_id(): bi = BatchInfo("My name").with_batch_id("custom id") assert bi.id == "custom id"
def test_batch_info_with_date(): now = datetime.now() bi = BatchInfo(None, now) assert bi.started_at == now