def test_3_t3(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': 't3', 'testSuiteName': 'scr', }) with apiritif.transaction_logged('t3'): self.driver.get('some.strange.url') 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 */', { 'status': 'success', 'message': '', })
def test_1_(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': '/', 'testSuiteName': 'loc_sc_remote', }) with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, "//input[@type='submit']")), 'Element "//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") 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 */', { 'status': 'success', 'message': '', })
def test_requests(self): self.driver.implicitly_wait(3.5) with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, _tpl.apply("//input[@type='submit']"))), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s') self.assertEqual(self.driver.title, _tpl.apply('BlazeDemo')) body = self.driver.page_source re_pattern = re.compile(r'contained_text') self.assertEqual(0, len(re.findall(re_pattern, body)), "Assertion: 'contained_text' found in BODY") with apiritif.transaction_logged('empty'): pass
def test_1_(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': '/', 'testSuiteName': 'loc_sc_remote', }) with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until( econd.presence_of_element_located( (By.XPATH, "//input[@type='submit']")), 'Element "//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") 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 */', { 'status': 'success', 'message': '', })
def test_2_empty(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': 'empty', 'testSuiteName': 'loc_sc_remote', }) with apiritif.transaction_logged('empty'): pass 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 */', { 'status': 'success', 'message': '', })
def test_2_t2(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': 't2', 'testSuiteName': 'scr', }) 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), }) raise else: self.driver.execute_script('/* FLOW_MARKER test-case-stop */', { 'status': 'success', 'message': '', })
def test_1_Test(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': 'Test', 'testSuiteName': 'DemoTest-Selenium', }) with apiritif.transaction_logged('Test'): self.driver.get('chrome://newtab/') self.driver.get('https://www.google.com/') self.driver.find_element(By.NAME, 'q').click() self.driver.find_element(By.NAME, 'q').clear() self.driver.find_element(By.NAME, 'q').send_keys('Selenium Test') self.driver.find_element(By.NAME, 'q').send_keys(Keys.ENTER) 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 */', { 'status': 'success', 'message': '', })
def test_1_t1(self): try: self.driver.execute_script('/* FLOW_MARKER test-case-start */', { 'testCaseName': 't1', 'testSuiteName': 'scr', }) 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 */', { 'status': 'success', 'message': '', })
def test_requests(self): self.driver.implicitly_wait(3.5) with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until( econd.presence_of_element_located( (By.XPATH, _tpl.apply("//input[@type='submit']"))), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s' ) self.assertEqual(self.driver.title, _tpl.apply('BlazeDemo')) ActionChains(self.driver).move_to_element( self.driver.find_element( By.XPATH, _tpl.apply('/html/body/div[2]/div/p[2]/a'))).perform() ActionChains(self.driver).double_click( self.driver.find_element( By.XPATH, _tpl.apply('/html/body/div[3]/h2'))).perform() ActionChains(self.driver).click_and_hold( self.driver.find_element( By.XPATH, _tpl.apply('/html/body/div[3]/form/select[1]'))).perform() ActionChains(self.driver).release( self.driver.find_element( By.XPATH, _tpl.apply('/html/body/div[3]/form/select[1]/option[6]')) ).perform() Select(self.driver.find_element( By.NAME, _tpl.apply('toPort'))).select_by_visible_text( _tpl.apply('London')) self.driver.find_element( By.CSS_SELECTOR, _tpl.apply('body input.btn.btn-primary')).send_keys(Keys.ENTER) self.assertEqual( _tpl.apply( self.driver.find_element( By.ID, _tpl.apply('address')).get_attribute('value')).strip(), _tpl.apply('123 Beautiful st.').strip()) self.assertEqual( _tpl.apply( self.driver.find_element( By.XPATH, _tpl.apply('/html/body/div[2]/form/div[1]/label')). get_attribute('innerText')).strip(), _tpl.apply('${name}').strip()) WebDriverWait(self.driver, 3.5).until( econd.visibility_of_element_located( (By.NAME, _tpl.apply('toPort'))), "Element 'toPort' failed to appear within 3.5s") self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys( _tpl.apply('B')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).clear() self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys( _tpl.apply('B')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys( Keys.ENTER) self.driver.find_element(By.NAME, _tpl.apply('toPort')).clear() self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys( Keys.ENTER) self.driver.find_element( By.XPATH, _tpl.apply('//div[3]/form/select[1]//option[3]')).click() self.driver.find_element( By.XPATH, _tpl.apply('//div[3]/form/select[2]//option[6]')).click() self.wnd_mng.switch(_tpl.apply('0')) self.wnd_mng.switch(_tpl.apply('win_ser_local')) self.wnd_mng.switch(_tpl.apply('win_ser_1')) self.wnd_mng.switch(_tpl.apply('that_window')) self.wnd_mng.close(_tpl.apply('1')) self.wnd_mng.close(_tpl.apply('win_ser_local')) self.wnd_mng.close(_tpl.apply('win_ser_1')) self.wnd_mng.close(_tpl.apply('that_window')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).submit() self.driver.execute_script(_tpl.apply("alert('This is Sparta');")) ActionChains(self.driver).drag_and_drop( self.driver.find_element(By.ID, _tpl.apply('address')), self.driver.find_element(By.NAME, _tpl.apply('toPort'))).perform() self.frm_mng.switch( self.driver.find_element(By.NAME, _tpl.apply('my_frame'))) self.frm_mng.switch(1) self.frm_mng.switch('relative=parent') if self.driver.find_element( By.ID, 'editor').get_attribute('contenteditable'): self.driver.execute_script( 'arguments[0].innerHTML = %s;' % _tpl.str_repr(_tpl.apply('lo-la-lu')), self.driver.find_element(By.ID, 'editor')) else: raise NoSuchElementException( "The element (By.ID, 'editor') is not contenteditable element" ) sleep(3.5) self.driver.delete_all_cookies() self.driver.find_element( By.LINK_TEXT, _tpl.apply('destination of the week! The Beach!')).click() _vars['Title'] = _tpl.apply(self.driver.title) _vars['Basic'] = _tpl.apply( self.driver.find_element( By.XPATH, _tpl.apply( "//*[@id='basics']/h2")).get_attribute('innerText')) _vars['World'] = _tpl.apply( self.driver.find_element( By.XPATH, _tpl.apply("//*[@id='basics']/h1")).get_attribute('value')) _vars['Final'] = _tpl.apply('${Title} ${Basic} by ${By}') self.driver.get(_tpl.apply('http:\\blazemeter.com')) print(_tpl.apply('${red_pill}')) body = self.driver.page_source re_pattern = re.compile(r'contained_text') self.assertEqual(0, len(re.findall(re_pattern, body)), "Assertion: 'contained_text' found in BODY") with apiritif.transaction_logged('empty'): pass
def test_me(self): with apiritif.transaction_logged('hello there'): time.sleep(0.1) self.assertEqual(2 + 2, 4)
def test_requests(self): self.driver.implicitly_wait(60.0) with apiritif.transaction_logged('Test'): self.driver.get(_tpl.apply('https://www.demoblaze.com/')) self.driver.find_element(By.ID, _tpl.apply('itemc')).click()
def test_9_transaction_logged(self): with transaction_logged("Label") as tran: logging.warning("TODO: capture logging to assert for result")
def test_requests(self): self.driver.implicitly_wait(60.0) with apiritif.transaction_logged(u'Test'): self.driver.get( _tpl.apply( u'https://abstracta.github.io/examples/resources/edit-content/edit-content.html' )) self.frm_mng.switch(u'index=0') self.driver.find_element(By.CSS_SELECTOR, _tpl.apply(u'body')).click() if self.driver.find_element( By.ID, 'tinymce').get_attribute('contenteditable'): self.driver.execute_script( 'arguments[0].innerHTML = %s;' % _tpl.str_repr(_tpl.apply(u'<p>test 9999<br></p>')), self.driver.find_element(By.ID, 'tinymce')) else: raise NoSuchElementException( "The element (By.ID, 'tinymce') is not contenteditable element" ) self.assertEqual( _tpl.apply( self.driver.find_element( By.CSS_SELECTOR, _tpl.apply('p')).get_attribute('innerText')).strip(), _tpl.apply(u'test 9999').strip()) if self.driver.find_element( By.CSS_SELECTOR, '#tinymce').get_attribute('contenteditable'): self.driver.execute_script( 'arguments[0].innerHTML = %s;' % _tpl.str_repr(_tpl.apply(u'<p>test 99<br></p>')), self.driver.find_element(By.CSS_SELECTOR, '#tinymce')) else: raise NoSuchElementException( "The element (By.CSS_SELECTOR, '#tinymce') is not contenteditable element" ) self.assertEqual( _tpl.apply( self.driver.find_element( By.CSS_SELECTOR, _tpl.apply('p')).get_attribute('innerText')).strip(), _tpl.apply(u'test 99').strip()) if self.driver.find_element( By.XPATH, "//body[@id='tinymce']").get_attribute('contenteditable'): self.driver.execute_script( 'arguments[0].innerHTML = %s;' % _tpl.str_repr(_tpl.apply(u'<p>test 0<br></p>')), self.driver.find_element(By.XPATH, "//body[@id='tinymce']")) else: raise NoSuchElementException( 'The element (By.XPATH, "//body[@id=\'tinymce\']") is not contenteditable element' ) self.assertEqual( _tpl.apply( self.driver.find_element( By.CSS_SELECTOR, _tpl.apply('p')).get_attribute('innerText')).strip(), _tpl.apply(u'test 0').strip()) self.frm_mng.switch(u'relative=parent') self.driver.find_element(By.CSS_SELECTOR, _tpl.apply(u'body')).click()
def test_2_empty(self): with apiritif.transaction_logged('empty'): pass
def test_1_(self): with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, "//input[@type='submit']")), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s') self.assertEqual(self.driver.title, 'BlazeDemo') ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, '/html/body/div[2]/div/p[2]/a')).perform() ActionChains(self.driver).double_click(self.driver.find_element(By.XPATH, '/html/body/div[3]/h2')).perform() ActionChains(self.driver).click_and_hold(self.driver.find_element(By.XPATH, '/html/body/div[3]/form/select[1]')).perform() ActionChains(self.driver).release(self.driver.find_element(By.XPATH, '/html/body/div[3]/form/select[1]/option[6]')).perform() Select(self.driver.find_element(By.NAME, 'toPort')).select_by_visible_text('London') self.driver.find_element(By.CSS_SELECTOR, 'body input.btn.btn-primary').send_keys(Keys.ENTER) self.assertEqual(self.driver.find_element(By.ID, 'address').get_attribute('value').strip(), '123 Beautiful st.'.strip()) self.assertEqual(self.driver.find_element(By.XPATH, '/html/body/div[2]/form/div[1]/label').get_attribute('innerText').strip(), self.vars['name'].strip()) WebDriverWait(self.driver, 3.5).until(econd.visibility_of_element_located((By.NAME, 'toPort')), "Element 'toPort' failed to appear within 3.5s") self.driver.find_element(By.NAME, 'toPort').send_keys('B') self.driver.find_element(By.NAME, 'toPort').clear() self.driver.find_element(By.NAME, 'toPort').send_keys('B') self.driver.find_element(By.NAME, 'toPort').send_keys(Keys.ENTER) self.driver.find_element(By.NAME, 'toPort').clear() self.driver.find_element(By.NAME, 'toPort').send_keys(Keys.ENTER) self.driver.find_element(By.XPATH, '//div[3]/form/select[1]//option[3]').click() self.driver.find_element(By.XPATH, '//div[3]/form/select[2]//option[6]').click() self.wnd_mng.switch('0') self.driver.execute_script("window.open('some.url');") self.wnd_mng.switch('win_ser_local') self.wnd_mng.switch('win_ser_1') self.wnd_mng.switch('that_window') self.wnd_mng.close('1') self.wnd_mng.close('win_ser_local') self.wnd_mng.close('win_ser_1') self.wnd_mng.close('that_window') self.driver.find_element(By.NAME, 'toPort').submit() self.driver.execute_script("alert('This is Sparta');") for i in range(10): if ((i % 2) == 0): print(i) ActionChains(self.driver).drag_and_drop(self.driver.find_element(By.ID, 'address'), self.driver.find_element(By.NAME, 'toPort')).perform() self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame')) self.frm_mng.switch('index=1') self.frm_mng.switch('relative=parent') if self.driver.find_element(By.ID, 'editor').get_attribute('contenteditable'): self.driver.execute_script(('arguments[0].innerHTML = %s;' % 'lo-la-lu'), self.driver.find_element(By.ID, 'editor')) else: raise NoSuchElementException("The element (By.ID, 'editor') is not contenteditable element") sleep(3.5) self.driver.delete_all_cookies() self.driver.find_element(By.LINK_TEXT, 'destination of the week! The Beach!').click() self.vars['Title'] = self.driver.title self.vars['Basic'] = self.driver.find_element(By.XPATH, "//*[@id='basics']/h2").get_attribute('innerText') self.vars['World'] = self.driver.find_element(By.XPATH, "//*[@id='basics']/h1").get_attribute('value') self.vars['Final'] = '{} {} by {}'.format(self.vars['Title'], self.vars['Basic'], self.vars['By']) self.driver.get('http:\\blazemeter.com') print(self.vars['red_pill']) self.driver.save_screenshot('screen.png') filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'), ('screenshot-%d.png' % (time() * 1000))) self.driver.save_screenshot(filename) 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")
def test_requests(self): self.driver.implicitly_wait(3.5) with apiritif.transaction_logged('/'): self.driver.get('http://blazedemo.com/') WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, _tpl.apply("//input[@type='submit']"))), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s') self.assertEqual(self.driver.title, _tpl.apply('BlazeDemo')) ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, _tpl.apply('/html/body/div[2]/div/p[2]/a'))).perform() ActionChains(self.driver).double_click(self.driver.find_element(By.XPATH, _tpl.apply('/html/body/div[3]/h2'))).perform() ActionChains(self.driver).click_and_hold(self.driver.find_element(By.XPATH, _tpl.apply('/html/body/div[3]/form/select[1]'))).perform() ActionChains(self.driver).release(self.driver.find_element(By.XPATH, _tpl.apply('/html/body/div[3]/form/select[1]/option[6]'))).perform() Select(self.driver.find_element(By.NAME, _tpl.apply('toPort'))).select_by_visible_text(_tpl.apply('London')) self.driver.find_element(By.CSS_SELECTOR, _tpl.apply('body input.btn.btn-primary')).send_keys(Keys.ENTER) self.assertEqual(_tpl.apply(self.driver.find_element(By.ID, _tpl.apply('address')).get_attribute('value')).strip(), _tpl.apply('123 Beautiful st.').strip()) self.assertEqual(_tpl.apply(self.driver.find_element(By.XPATH, _tpl.apply('/html/body/div[2]/form/div[1]/label')).get_attribute('innerText')).strip(), _tpl.apply('${name}').strip()) WebDriverWait(self.driver, 3.5).until(econd.visibility_of_element_located((By.NAME, _tpl.apply('toPort'))), "Element 'toPort' failed to appear within 3.5s") self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys(_tpl.apply('B')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).clear() self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys(_tpl.apply('B')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys(Keys.ENTER) self.driver.find_element(By.NAME, _tpl.apply('toPort')).clear() self.driver.find_element(By.NAME, _tpl.apply('toPort')).send_keys(Keys.ENTER) self.driver.find_element(By.XPATH, _tpl.apply('//div[3]/form/select[1]//option[3]')).click() self.driver.find_element(By.XPATH, _tpl.apply('//div[3]/form/select[2]//option[6]')).click() self.wnd_mng.switch(_tpl.apply('0')) self.driver.execute_script(_tpl.apply("window.open('some.url');")) self.wnd_mng.switch(_tpl.apply('win_ser_local')) self.wnd_mng.switch(_tpl.apply('win_ser_1')) self.wnd_mng.switch(_tpl.apply('that_window')) self.wnd_mng.close(_tpl.apply('1')) self.wnd_mng.close(_tpl.apply('win_ser_local')) self.wnd_mng.close(_tpl.apply('win_ser_1')) self.wnd_mng.close(_tpl.apply('that_window')) self.driver.find_element(By.NAME, _tpl.apply('toPort')).submit() self.driver.execute_script(_tpl.apply("alert('This is Sparta');")) ActionChains(self.driver).drag_and_drop(self.driver.find_element(By.ID, _tpl.apply('address')), self.driver.find_element(By.NAME, _tpl.apply('toPort'))).perform() self.frm_mng.switch(self.driver.find_element(By.NAME, _tpl.apply('my_frame'))) self.frm_mng.switch(1) self.frm_mng.switch('relative=parent') if self.driver.find_element(By.ID, 'editor').get_attribute('contenteditable'): self.driver.execute_script( 'arguments[0].innerHTML = %s;' % _tpl.str_repr(_tpl.apply('lo-la-lu')), self.driver.find_element(By.ID, 'editor') ) else: raise NoSuchElementException("The element (By.ID, 'editor') is not contenteditable element") sleep(3.5) self.driver.delete_all_cookies() self.driver.find_element(By.LINK_TEXT, _tpl.apply('destination of the week! The Beach!')).click() _vars['Title'] = _tpl.apply(self.driver.title) _vars['Basic'] = _tpl.apply(self.driver.find_element(By.XPATH, _tpl.apply("//*[@id='basics']/h2")).get_attribute('innerText')) _vars['World'] = _tpl.apply(self.driver.find_element(By.XPATH, _tpl.apply("//*[@id='basics']/h1")).get_attribute('value')) _vars['Final'] = _tpl.apply('${Title} ${Basic} by ${By}') self.driver.get(_tpl.apply('http:\\blazemeter.com')) print(_tpl.apply('${red_pill}')) body = self.driver.page_source re_pattern = re.compile(r'contained_text') self.assertEqual(0, len(re.findall(re_pattern, body)), "Assertion: 'contained_text' found in BODY") with apiritif.transaction_logged('empty'): pass