How to use apiritif - 10 common examples

To help you get started, we’ve selected a few apiritif examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blazemeter / taurus / tests / resources / selenium / test_old_flow.py View on Github external
def test_1_t1(self):
        try:
            self.driver.execute_script('/* FLOW_MARKER test-case-start */', {
                'testCaseName': 't1',
                'testSuiteName': 'sdsdsds-Selenium',
            })
            with apiritif.transaction_logged('t1'):
                self.driver.get('http://blazedemo.com/purchase.php')
                self.driver.find_element(By.CSS_SELECTOR, 'input.btn.btn-primary').click()
        except AssertionError as exc:
            self.driver.execute_script('/* FLOW_MARKER test-case-stop */', {
                'status': 'failed',
                'message': str(exc),
            })
            raise
        except BaseException as exc:
            self.driver.execute_script('/* FLOW_MARKER test-case-stop */', {
                'status': 'broken',
                'message': str(exc),
            })
            raise
        else:
            self.driver.execute_script('/* FLOW_MARKER test-case-stop */', {
github Blazemeter / taurus / tests / resources / selenium / test_old_flow.py View on Github external
def test_2_t2(self):
        try:
            self.driver.execute_script('/* FLOW_MARKER test-case-start */', {
                'testCaseName': 't2',
                'testSuiteName': 'sdsdsds-Selenium',
            })
            with apiritif.transaction_logged('t2'):
                self.driver.get('https://www.belarus.by/en/')
                body = self.driver.page_source
                re_pattern = re.compile('In God we trust')
                self.assertNotEqual(0, len(re.findall(re_pattern, body)),
                                    "Assertion: 'In God we trust' not found in BODY")
        except AssertionError as exc:
            self.driver.execute_script('/* FLOW_MARKER test-case-stop */', {
                'status': 'failed',
                'message': str(exc),
            })
            raise
        except BaseException as exc:
            self.driver.execute_script('/* FLOW_MARKER test-case-stop */', {
                'status': 'broken',
                'message': str(exc),
            })
github Blazemeter / taurus / bzt / resources / selenium_extras.py View on Github external
def _send_marker(stage, params):
    driver = get_from_thread_store("driver")
    driver.execute_script('/* FLOW_MARKER test-case-%s */' % stage, params)
github Blazemeter / taurus / tests / resources / selenium / generated_from_requests_remote.py View on Github external
def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')

            var_loc_wait = self.loc_mng.get_locator([{
                'xpath': "//input[@type='submit']",
            }])
            WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((
                var_loc_wait[0],
                var_loc_wait[1])), 'Element \'xpath\':"//input[@type=\'submit\']" failed to appear within 3.5s')
            self.assertEqual(self.driver.title, 'BlazeDemo')
            body = self.driver.page_source
            re_pattern = re.compile('contained_text')
            self.assertEqual(0, len(re.findall(re_pattern, body)), "Assertion: 'contained_text' found in BODY")
github Blazemeter / taurus / tests / resources / selenium / generated_from_requests_appium_browser.py View on Github external
def setUp(self):
        self.driver = None
        self.driver = webdriver.Remote(command_executor='http://localhost:4723/wd/hub', desired_capabilities={
            'browserName': 'chrome',
            'deviceName': '',
            'platformName': 'android',
        })
        self.driver.implicitly_wait(3.5)
        self.loc_mng = LocatorsManager(self.driver)
        self.vars = {

        }
        apiritif.put_into_thread_store(func_mode=False, driver=self.driver)
github Blazemeter / taurus / tests / resources / selenium / generated_from_requests_remote.py View on Github external
'app': '',
                                           'browserName': 'firefox',
                                           'deviceName': '',
                                           'javascriptEnabled': 'True',
                                           'platformName': 'linux',
                                           'platformVersion': '',
                                           'seleniumVersion': '',
                                           'version': '54.0',
                                       })
        self.driver.implicitly_wait(3.5)
        self.loc_mng = LocatorsManager(self.driver)
        self.vars = {

        }
        add_flow_markers()
        apiritif.put_into_thread_store(func_mode=False, driver=self.driver)
github Blazemeter / taurus / tests / resources / selenium / generated_from_requests.py View on Github external
def setUp(self):
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file', 'webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(3.5)
        self.wnd_mng = WindowManager(self.driver)
        self.frm_mng = FrameManager(self.driver)
        self.loc_mng = LocatorsManager(self.driver)
        self.vars = {
            'name': 'Name',
            'red_pill': 'take_it',
        }
        apiritif.put_into_thread_store(func_mode=False, driver=self.driver)
github Blazemeter / taurus / tests / resources / selenium / test_old_flow.py View on Github external
def teardown():
    (_, driver, _, _) = apiritif.get_from_thread_store()
    driver.quit()
github Blazemeter / taurus / tests / resources / selenium / generated_from_requests.py View on Github external
def test_requests(self):
        self.driver.implicitly_wait(3.5)

        with apiritif.transaction_logged(self.template('/')):
            self.driver.get(self.template('http://blazedemo.com/'))

            WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, self.template("//input[@type='submit']"))), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s')
            self.assertEqual(self.driver.title, self.template('BlazeDemo'))
            ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, self.template('/html/body/div[2]/div/p[2]/a'))).perform()
            ActionChains(self.driver).double_click(self.driver.find_element(By.XPATH, self.template('/html/body/div[3]/h2'))).perform()
            ActionChains(self.driver).click_and_hold(self.driver.find_element(By.XPATH, self.template('/html/body/div[3]/form/select[1]'))).perform()
            ActionChains(self.driver).release(self.driver.find_element(By.XPATH, self.template('/html/body/div[3]/form/select[1]/option[6]'))).perform()
            Select(self.driver.find_element(By.NAME, self.template('toPort'))).select_by_visible_text(self.template('London'))
            self.driver.find_element(By.CSS_SELECTOR, self.template('body input.btn.btn-primary')).send_keys(Keys.ENTER)
            self.assertEqual(self.template(self.driver.find_element(By.ID, self.template('address')).get_attribute('value')).strip(), self.template('123 Beautiful st.').strip())
            self.assertEqual(self.template(self.driver.find_element(By.XPATH, self.template('/html/body/div[2]/form/div[1]/label')).get_attribute('innerText')).strip(), self.template('${name}').strip())
            WebDriverWait(self.driver, 3.5).until(econd.visibility_of_element_located((By.NAME, self.template('toPort'))), "Element 'toPort' failed to appear within 3.5s")
            self.driver.find_element(By.NAME, self.template('toPort')).send_keys(self.template('B'))
            self.driver.find_element(By.NAME, self.template('toPort')).clear()
            self.driver.find_element(By.NAME, self.template('toPort')).send_keys(self.template('B'))
github Blazemeter / taurus / tests / resources / selenium / test_new_flow.py View on Github external
def _1_t1(self):
        with apiritif.smart_transaction('t1'):
            self.driver.get('http://blazedemo.com/purchase.php')
            self.driver.find_element(By.CSS_SELECTOR, 'input.btn.btn-primary').click()