Example #1
0
    def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')
            dialogs_replace()
            wait_for('present', [{'xpath': "//input[@type='submit']"}], 3.5)
            wait_for('present', [{
                'xpath': "//input[@name='test,name']"
            }], 80.0)
            self.assertEqual(self.driver.title, 'BlazeDemo')

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[2]/div/p[2]/a'
            }])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{'xpath': '/html/body/div[3]/h2'}])
            ActionChains(self.driver).double_click(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[3]/form/select[1]'
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[3]/form/select[1]/option[6]'
            }])
            ActionChains(self.driver).release(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_select = get_locator([{'name': 'toPort'}])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text('London')

            var_loc_keys = get_locator([{'css': 'body input.btn.btn-primary'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_as = get_locator([{'id': 'address'}])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                '123 Beautiful st.'.strip())

            var_loc_as = get_locator([{
                'xpath':
                '/html/body/div[2]/form/div[1]/label'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                self.vars['name'].strip())
            wait_for('visible', [{'name': 'toPort'}], 3.5)

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('B')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('B')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{
                'xpath':
                '//div[3]/form/select[1]//option[3]'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            var_loc_keys = get_locator([{
                'xpath':
                '//div[3]/form/select[2]//option[6]'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()
            switch_window('0')
            self.driver.execute_script("window.open('some.url');")
            switch_window('win_ser_local')
            switch_window('win_ser_1')
            switch_window('that_window')
            close_window('1')
            close_window('win_ser_local')
            close_window('win_ser_1')
            close_window('that_window')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).submit()
            self.driver.execute_script("alert('This is Sparta');")

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)

            source = get_locator([{'id': 'address'}])

            target = get_locator([{'name': 'toPort'}])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()
            switch_frame(self.driver.find_element(By.NAME, 'my_frame'))
            switch_frame(self.driver.find_element(By.NAME, 'top_frame'))
            switch_frame(
                self.driver.find_element(By.XPATH, "//*[@id='result']"))
            switch_frame(self.driver.find_element(By.CSS_SELECTOR,
                                                  '.my_class'))
            switch_frame(self.driver.find_element(By.ID, 'frame_id'))
            switch_frame('index=1')
            switch_frame('relative=parent')

            var_edit_content = get_locator([{'id': 'editor'}])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            sleep(3.5)
            self.driver.delete_all_cookies()

            var_loc_keys = get_locator([{
                'linktext':
                'destination of the week! The Beach!'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            self.vars['Title'] = self.driver.title

            var_loc_as = get_locator([{'xpath': "//*[@id='basics']/h2"}])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')

            var_loc_as = get_locator([{'xpath': "//*[@id='basics']/h1"}])

            self.vars['World'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('value')

            self.vars['Final'] = '{} {} by {}'.format(self.vars['Title'],
                                                      self.vars['Basic'],
                                                      self.vars['By'])

            self.vars['var_eval'] = self.driver.execute_script(
                'return 0 == false;')
            self.assertTrue(self.driver.execute_script('return 10 === 2*5;'),
                            '10 === 2*5')
            self.driver.get('http:\\blazemeter.com')

            dialogs_replace()

            dialog = dialogs_get_next_alert()
            self.assertIsNotNone(dialog, 'No dialog of type alert appeared')
            self.assertEqual(dialog, 'Alert Message',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_prompt()
            self.assertIsNotNone(dialog, 'No dialog of type prompt appeared')
            self.assertEqual(dialog, 'Enter value',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_confirm()
            self.assertIsNotNone(dialog, 'No dialog of type confirm appeared')
            self.assertEqual(dialog, 'Are you sure?',
                             "Dialog message didn't match")
            dialogs_answer_on_next_prompt('myvalue')
            dialogs_answer_on_next_confirm('#Ok')
            dialogs_answer_on_next_alert('#Ok')
            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 _1_Test_V2(self):
        with apiritif.smart_transaction('Test V2'):
            action_start({
                'param': 'http://blazedemo.com',
                'selectors': [],
                'tag': '',
                'type': 'go',
                'value': None
            })
            self.driver.get('http://blazedemo.com')

            dialogs_replace()
            waiter()
            action_end({
                'param': 'http://blazedemo.com',
                'selectors': [],
                'tag': '',
                'type': 'go',
                'value': None
            })
            action_start({
                'param': '750, 750',
                'selectors': [],
                'tag': 'window',
                'type': 'resize',
                'value': None
            })
            self.driver.set_window_size('750', '750')
            action_end({
                'param': '750, 750',
                'selectors': [],
                'tag': 'window',
                'type': 'resize',
                'value': None
            })
            action_start({
                'param': 0,
                'selectors': [],
                'tag': 'window',
                'type': 'switch',
                'value': None
            })
            switch_window(0)
            action_end({
                'param': 0,
                'selectors': [],
                'tag': 'window',
                'type': 'switch',
                'value': None
            })
            action_start({
                'param':
                None,
                'selectors': [{
                    'id': 'invalid_id'
                }, {
                    'xpath': self.vars['my_xpath_locator']
                }],
                'tag':
                '',
                'type':
                'mousedown',
                'value':
                None
            })

            var_loc_chain = get_locator([{
                'id': 'invalid_id'
            }, {
                'xpath': self.vars['my_xpath_locator']
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()
            action_end({
                'param':
                None,
                'selectors': [{
                    'id': 'invalid_id'
                }, {
                    'xpath': self.vars['my_xpath_locator']
                }],
                'tag':
                '',
                'type':
                'mousedown',
                'value':
                None
            })
            action_start({
                'param': None,
                'selectors': [{
                    'id': 'id_123'
                }],
                'tag': '',
                'type': 'mouseout',
                'value': None
            })

            var_loc_chain = get_locator([{'id': 'id_123'}])
            ActionChains(self.driver).move_to_element_with_offset(
                self.driver.find_element(var_loc_chain[0], var_loc_chain[1]),
                -10, -10).perform()
            action_end({
                'param': None,
                'selectors': [{
                    'id': 'id_123'
                }],
                'tag': '',
                'type': 'mouseout',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [{
                    'name': 'name_123'
                }],
                'tag': '',
                'type': 'mouseover',
                'value': None
            })

            var_loc_chain = get_locator([{'name': 'name_123'}])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()
            action_end({
                'param': None,
                'selectors': [{
                    'name': 'name_123'
                }],
                'tag': '',
                'type': 'mouseover',
                'value': None
            })
            action_start({
                'param':
                None,
                'selectors': ([{
                    'name': 'invalid_name'
                }, {
                    'xpath': '/html/body/div[2]/div/p[2]/a'
                }], [{
                    'css': 'invalid_css'
                }, {
                    'xpath': '/html/body/div[3]/form/div'
                }]),
                'tag':
                '',
                'type':
                'drag',
                'value':
                None
            })

            source = get_locator([{
                'name': 'invalid_name'
            }, {
                'xpath': '/html/body/div[2]/div/p[2]/a'
            }])

            target = get_locator([{
                'css': 'invalid_css'
            }, {
                'xpath': '/html/body/div[3]/form/div'
            }])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()
            waiter()
            action_end({
                'param':
                None,
                'selectors': ([{
                    'name': 'invalid_name'
                }, {
                    'xpath': '/html/body/div[2]/div/p[2]/a'
                }], [{
                    'css': 'invalid_css'
                }, {
                    'xpath': '/html/body/div[3]/form/div'
                }]),
                'tag':
                '',
                'type':
                'drag',
                'value':
                None
            })
            action_start({
                'param':
                'Choose your departure city:',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '/html/body/div[3]/h2'
                }],
                'tag':
                '',
                'type':
                'asserttext',
                'value':
                None
            })

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '/html/body/div[3]/h2'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                'Choose your departure city:'.strip())
            action_end({
                'param':
                'Choose your departure city:',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '/html/body/div[3]/h2'
                }],
                'tag':
                '',
                'type':
                'asserttext',
                'value':
                None
            })
            action_start({
                'param':
                'Find Flights',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '/html/body/div[3]/form/div/input'
                }],
                'tag':
                '',
                'type':
                'assertvalue',
                'value':
                None
            })

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                'Find Flights'.strip())
            action_end({
                'param':
                'Find Flights',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '/html/body/div[3]/form/div/input'
                }],
                'tag':
                '',
                'type':
                'assertvalue',
                'value':
                None
            })
            action_start({
                'param': 'BlazeDemo',
                'selectors': [],
                'tag': 'title',
                'type': 'assert',
                'value': None
            })
            self.assertEqual(self.driver.title, 'BlazeDemo')
            action_end({
                'param': 'BlazeDemo',
                'selectors': [],
                'tag': 'title',
                'type': 'assert',
                'value': None
            })
            action_start({
                'param': 'hEaDeR',
                'selectors': [],
                'tag': 'title',
                'type': 'store',
                'value': None
            })

            self.vars['hEaDeR'] = self.driver.title
            action_end({
                'param': 'hEaDeR',
                'selectors': [],
                'tag': 'title',
                'type': 'store',
                'value': None
            })
            action_start({
                'param': 'final_var',
                'selectors': [],
                'tag': 'string',
                'type': 'store',
                'value': 'test_text'
            })

            self.vars['final_var'] = 'test_text'
            action_end({
                'param': 'final_var',
                'selectors': [],
                'tag': 'string',
                'type': 'store',
                'value': 'test_text'
            })
            action_start({
                'param': 'Basic',
                'selectors': [{
                    'xpath': '/html/body/div[3]/h2'
                }],
                'tag': '',
                'type': 'storetext',
                'value': None
            })

            var_loc_as = get_locator([{'xpath': '/html/body/div[3]/h2'}])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')
            action_end({
                'param': 'Basic',
                'selectors': [{
                    'xpath': '/html/body/div[3]/h2'
                }],
                'tag': '',
                'type': 'storetext',
                'value': None
            })
            action_start({
                'param': '10 === 2*5',
                'selectors': [],
                'tag': 'eval',
                'type': 'assert',
                'value': None
            })
            self.assertTrue(self.driver.execute_script('return 10 === 2*5;'),
                            '10 === 2*5')
            action_end({
                'param': '10 === 2*5',
                'selectors': [],
                'tag': 'eval',
                'type': 'assert',
                'value': None
            })
            action_start({
                'param':
                'var_assert',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'assert',
                'value':
                'myFunction();\nfunction myFunction(){{\n btnNameVar="{}";\n return "support";\n}}'
                .format(self.vars['btnName1'])
            })
            self.assertTrue(self.driver.execute_script('return var_assert;'),
                            'var_assert')
            action_end({
                'param':
                'var_assert',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'assert',
                'value':
                'myFunction();\nfunction myFunction(){{\n btnNameVar="{}";\n return "support";\n}}'
                .format(self.vars['btnName1'])
            })

            action_start({
                'param':
                'var_eval',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'store',
                'value':
                'myFunction();\nfunction myFunction(){{\n btnNameVar="{}";\n return "support";\n}}'
                .format(self.vars['btnName1'])
            })

            self.vars['var_eval'] = self.driver.execute_script(
                'return myFunction();\nfunction myFunction(){{\n btnNameVar="{}";\n return "support";\n}};'
                .format(self.vars['btnName1']))
            action_end({
                'param':
                'var_eval',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'store',
                'value':
                'myFunction();\nfunction myFunction(){{\n btnNameVar="{}";\n return "support";\n}}'
                .format(self.vars['btnName1'])
            })
            action_start({
                'param':
                'var_eval',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'store',
                'value':
                '["{}", "{}", "{}", "{}"]'.format(self.vars['id1'],
                                                  self.vars['id2'],
                                                  self.vars['id3'],
                                                  self.vars['id4'])
            })

            self.vars['var_eval'] = self.driver.execute_script(
                'return ["{}", "{}", "{}", "{}"];'.format(
                    self.vars['id1'], self.vars['id2'], self.vars['id3'],
                    self.vars['id4']))
            action_end({
                'param':
                'var_eval',
                'selectors': [],
                'tag':
                'eval',
                'type':
                'store',
                'value':
                '["{}", "{}", "{}", "{}"]'.format(self.vars['id1'],
                                                  self.vars['id2'],
                                                  self.vars['id3'],
                                                  self.vars['id4'])
            })
            action_start({
                'param':
                None,
                'selectors': [{
                    'xpath': '/wrong/one'
                }, {
                    'xpath': '/html/body/div[3]/form/div/input'
                }],
                'tag':
                '',
                'type':
                'click',
                'value':
                None
            })

            var_loc_keys = get_locator([{
                'xpath': '/wrong/one'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()
            waiter()
            action_end({
                'param':
                None,
                'selectors': [{
                    'xpath': '/wrong/one'
                }, {
                    'xpath': '/html/body/div[3]/form/div/input'
                }],
                'tag':
                '',
                'type':
                'click',
                'value':
                None
            })
            action_start({
                'param':
                'KEY_ENTER',
                'selectors': [{
                    'xpath': '/doc/abc'
                }, {
                    'css':
                    'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input'
                }],
                'tag':
                '',
                'type':
                'keys',
                'value':
                None
            })

            var_loc_keys = get_locator([{
                'xpath': '/doc/abc'
            }, {
                'css':
                'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input'
            }])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)
            action_end({
                'param':
                'KEY_ENTER',
                'selectors': [{
                    'xpath': '/doc/abc'
                }, {
                    'css':
                    'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input'
                }],
                'tag':
                '',
                'type':
                'keys',
                'value':
                None
            })
            action_start({
                'param': 'myusername',
                'selectors': [{
                    'id': 'fjkafjk'
                }, {
                    'css': 'testCss'
                }],
                'tag': '',
                'type': 'type',
                'value': None
            })

            var_loc_keys = get_locator([{'id': 'fjkafjk'}, {'css': 'testCss'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('myusername')
            waiter()
            action_end({
                'param': 'myusername',
                'selectors': [{
                    'id': 'fjkafjk'
                }, {
                    'css': 'testCss'
                }],
                'tag': '',
                'type': 'type',
                'value': None
            })
            action_start({
                'param':
                'American Express',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '//*[@id="cardType"]'
                }],
                'tag':
                '',
                'type':
                'select',
                'value':
                None
            })

            var_loc_select = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '//*[@id="cardType"]'
            }])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text(
                        'American Express')
            waiter()
            action_end({
                'param':
                'American Express',
                'selectors': [{
                    'css': 'myclass'
                }, {
                    'xpath': '//*[@id="cardType"]'
                }],
                'tag':
                '',
                'type':
                'select',
                'value':
                None
            })
            action_start({
                'param': 'window.scrollTo(0, document.body.scrollHeight);',
                'selectors': [],
                'tag': 'eval',
                'type': 'script',
                'value': None
            })
            self.driver.execute_script(
                'window.scrollTo(0, document.body.scrollHeight);')
            waiter()
            action_end({
                'param': 'window.scrollTo(0, document.body.scrollHeight);',
                'selectors': [],
                'tag': 'eval',
                'type': 'script',
                'value': None
            })
            action_start({
                'param': 'for i in range(10):\n  if i % 2 == 0:\n    print(i)',
                'selectors': [],
                'tag': '',
                'type': 'rawcode',
                'value': None
            })

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)
            action_end({
                'param': 'for i in range(10):\n  if i % 2 == 0:\n    print(i)',
                'selectors': [],
                'tag': '',
                'type': 'rawcode',
                'value': None
            })
            action_start({
                'param': self.vars['red_pill'],
                'selectors': [],
                'tag': 'string',
                'type': 'echo',
                'value': None
            })
            print(self.vars['red_pill'])
            action_end({
                'param': self.vars['red_pill'],
                'selectors': [],
                'tag': 'string',
                'type': 'echo',
                'value': None
            })
            action_start({
                'param': '4.6s',
                'selectors': [],
                'tag': '',
                'type': 'pausefor',
                'value': None
            })
            sleep(4.6)
            action_end({
                'param': '4.6s',
                'selectors': [],
                'tag': '',
                'type': 'pausefor',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': 'cookies',
                'type': 'clear',
                'value': None
            })
            self.driver.delete_all_cookies()
            action_end({
                'param': None,
                'selectors': [],
                'tag': 'cookies',
                'type': 'clear',
                'value': None
            })
            action_start({
                'param': 'screen.png',
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            self.driver.save_screenshot('screen.png')
            action_end({
                'param': 'screen.png',
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            action_end({
                'param': None,
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            action_start({
                'param':
                'visible',
                'selectors': [{
                    'css': 'invalid_css'
                }, {
                    'name': 'inputName'
                }],
                'tag':
                '',
                'type':
                'waitfor',
                'value':
                '2h30m20s'
            })
            wait_for('visible', [{
                'css': 'invalid_css'
            }, {
                'name': 'inputName'
            }], 9020.0)
            action_end({
                'param':
                'visible',
                'selectors': [{
                    'css': 'invalid_css'
                }, {
                    'name': 'inputName'
                }],
                'tag':
                '',
                'type':
                'waitfor',
                'value':
                '2h30m20s'
            })
            action_start({
                'param': 'lo-la-lu',
                'selectors': [{
                    'id': 'editor'
                }],
                'tag': '',
                'type': 'editcontent',
                'value': None
            })

            var_edit_content = get_locator([{'id': 'editor'}])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            action_end({
                'param': 'lo-la-lu',
                'selectors': [{
                    'id': 'editor'
                }],
                'tag': '',
                'type': 'editcontent',
                'value': None
            })
            action_start({
                'param': '4.6s',
                'selectors': [],
                'tag': '',
                'type': 'pausefor',
                'value': None
            })
            sleep(4.6)
            action_end({
                'param': '4.6s',
                'selectors': [],
                'tag': '',
                'type': 'pausefor',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': 'cookies',
                'type': 'clear',
                'value': None
            })
            self.driver.delete_all_cookies()
            action_end({
                'param': None,
                'selectors': [],
                'tag': 'cookies',
                'type': 'clear',
                'value': None
            })
            action_start({
                'param': 'screen.png',
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            self.driver.save_screenshot('screen.png')
            action_end({
                'param': 'screen.png',
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            action_end({
                'param': None,
                'selectors': [],
                'tag': '',
                'type': 'screenshot',
                'value': None
            })
            action_start({
                'param': 'vacation.html',
                'selectors': [],
                'tag': 'window',
                'type': 'open',
                'value': None
            })
            open_window('vacation.html')
            action_end({
                'param': 'vacation.html',
                'selectors': [],
                'tag': 'window',
                'type': 'open',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': 'window',
                'type': 'maximize',
                'value': None
            })
            self.driver.maximize_window()
            action_end({
                'param': None,
                'selectors': [],
                'tag': 'window',
                'type': 'maximize',
                'value': None
            })
            action_start({
                'param': 1,
                'selectors': [],
                'tag': 'byidx',
                'type': 'switchframe',
                'value': None
            })
            switch_frame('index=1')
            action_end({
                'param': 1,
                'selectors': [],
                'tag': 'byidx',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': 'relative=parent',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            switch_frame('relative=parent')
            action_end({
                'param': 'relative=parent',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': 'my_frame',
                'selectors': [],
                'tag': 'byname',
                'type': 'switchframe',
                'value': None
            })
            switch_frame(self.driver.find_element(By.NAME, 'my_frame'))
            action_end({
                'param': 'my_frame',
                'selectors': [],
                'tag': 'byname',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': 'name=my_frame',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            switch_frame(self.driver.find_element(By.NAME, 'my_frame'))
            action_end({
                'param': 'name=my_frame',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': 'css=my_frame_cls',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            switch_frame(
                self.driver.find_element(By.CSS_SELECTOR, 'my_frame_cls'))
            action_end({
                'param': 'css=my_frame_cls',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': 'id=my_frame_id',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            switch_frame(self.driver.find_element(By.ID, 'my_frame_id'))
            action_end({
                'param': 'id=my_frame_id',
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': "xpath='//xpath'",
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            switch_frame(self.driver.find_element(By.XPATH, '//xpath'))
            action_end({
                'param': "xpath='//xpath'",
                'selectors': [],
                'tag': '',
                'type': 'switchframe',
                'value': None
            })
            action_start({
                'param': None,
                'selectors': [],
                'tag': 'window',
                'type': 'close',
                'value': None
            })
            close_window()
            action_end({
                'param': None,
                'selectors': [],
                'tag': 'window',
                'type': 'close',
                'value': None
            })
            action_start({
                'param': 'prompt',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': 'my input'
            })
            dialogs_answer_on_next_prompt('my input')
            action_end({
                'param': 'prompt',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': 'my input'
            })
            action_start({
                'param': 'confirm',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': '#Ok'
            })
            dialogs_answer_on_next_confirm('#Ok')
            action_end({
                'param': 'confirm',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': '#Ok'
            })
            action_start({
                'param': 'alert',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': '#Ok'
            })
            dialogs_answer_on_next_alert('#Ok')
            action_end({
                'param': 'alert',
                'selectors': [],
                'tag': '',
                'type': 'answerdialog',
                'value': '#Ok'
            })
            action_start({
                'param': 'alert',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'Exception occurred!'
            })

            dialog = dialogs_get_next_alert()
            self.assertIsNotNone(dialog, 'No dialog of type alert appeared')
            self.assertEqual(dialog, 'Exception occurred!',
                             "Dialog message didn't match")
            action_end({
                'param': 'alert',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'Exception occurred!'
            })
            action_start({
                'param': 'confirm',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'Are you sure?'
            })

            dialog = dialogs_get_next_confirm()
            self.assertIsNotNone(dialog, 'No dialog of type confirm appeared')
            self.assertEqual(dialog, 'Are you sure?',
                             "Dialog message didn't match")
            action_end({
                'param': 'confirm',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'Are you sure?'
            })
            action_start({
                'param': 'prompt',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'What is your age?'
            })

            dialog = dialogs_get_next_prompt()
            self.assertIsNotNone(dialog, 'No dialog of type prompt appeared')
            self.assertEqual(dialog, 'What is your age?',
                             "Dialog message didn't match")
            action_end({
                'param': 'prompt',
                'selectors': [],
                'tag': '',
                'type': 'assertdialog',
                'value': 'What is your age?'
            })
    def _1_Test_V2(self):
        with apiritif.smart_transaction('Test V2'):
            self.driver.get('http://blazedemo.com')

            dialogs_replace()
            self.driver.set_window_size('750', '750')
            switch_window(0)

            var_loc_chain = get_locator([{
                'id': 'invalid_id'
            }, {
                'xpath': self.vars['my_xpath_locator']
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{'id': 'id_123'}])
            ActionChains(self.driver).move_to_element_with_offset(
                self.driver.find_element(var_loc_chain[0], var_loc_chain[1]),
                -10, -10).perform()

            var_loc_chain = get_locator([{'name': 'name_123'}])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            source = get_locator([{
                'name': 'invalid_name'
            }, {
                'xpath': '/html/body/div[2]/div/p[2]/a'
            }])

            target = get_locator([{
                'css': 'invalid_css'
            }, {
                'xpath': '/html/body/div[3]/form/div'
            }])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '/html/body/div[3]/h2'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                'Choose your departure city:'.strip())

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                'Find Flights'.strip())
            self.assertEqual(self.driver.title, 'BlazeDemo')

            self.vars['hEaDeR'] = self.driver.title

            self.vars['final_var'] = 'test_text'

            var_loc_as = get_locator([{'xpath': '/html/body/div[3]/h2'}])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')
            self.assertTrue(self.driver.execute_script('return 10 === 2*5;'),
                            '10 === 2*5')

            self.vars['var_eval'] = self.driver.execute_script(
                'return 0 == false;')

            var_loc_keys = get_locator([{
                'xpath': '/wrong/one'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            var_loc_keys = get_locator([{
                'xpath': '/doc/abc'
            }, {
                'css':
                'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input'
            }])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{'id': 'fjkafjk'}, {'css': 'testCss'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('myusername')

            var_loc_select = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '//*[@id="cardType"]'
            }])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text(
                        'American Express')
            self.driver.execute_script(
                'window.scrollTo(0, document.body.scrollHeight);')

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)
            print(self.vars['red_pill'])
            sleep(4.6)
            self.driver.delete_all_cookies()
            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)
            wait_for('visible', [{
                'css': 'invalid_css'
            }, {
                'name': 'inputName'
            }], 3.5)
            wait_for('visible', [{
                'css': 'invalid_css'
            }, {
                'name': 'inputName'
            }], 9020.0)

            var_edit_content = get_locator([{'id': 'editor'}])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            sleep(4.6)
            self.driver.delete_all_cookies()
            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)
            self.driver.execute_script("window.open('vacation.html');")
            self.driver.maximize_window()
            switch_frame('index=1')
            switch_frame('relative=parent')
            switch_frame(self.driver.find_element(By.NAME, 'my_frame'))
            close_window()
            dialogs_answer_on_next_prompt('my input')
            dialogs_answer_on_next_confirm('#Ok')
            dialogs_answer_on_next_alert('#Ok')

            dialog = dialogs_get_next_alert()
            self.assertIsNotNone(dialog, 'No dialog of type alert appeared')
            self.assertEqual(dialog, 'Exception occurred!',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_confirm()
            self.assertIsNotNone(dialog, 'No dialog of type confirm appeared')
            self.assertEqual(dialog, 'Are you sure?',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_prompt()
            self.assertIsNotNone(dialog, 'No dialog of type prompt appeared')
            self.assertEqual(dialog, 'What is your age?',
                             "Dialog message didn't match")