def test_get_locator_timeout(self):
        content = [{'css': 'existed_css'}]
        timeout = 30
        driver = MockWebDriver(content=content, timeout=timeout)

        put_into_thread_store(driver=driver, timeout=timeout, func_mode=False)

        # exception should be raised when raise_exception is True
        missing_locators = [{'css': 'missing_css'}, {'xpath': 'missing_xpath'}]
        self.assertRaises(NoSuchElementException, get_locator,
                          missing_locators, None, False, True)
        self.assertEqual(30, driver.waiting_time)

        # exception should not be raised when raise_exception is False
        driver.waiting_time = 0
        locators = get_locator(missing_locators,
                               parent_el=None,
                               ignore_implicit_wait=True,
                               raise_exception=False)
        self.assertEqual(locators, (BYS['css'], 'missing_css'))
        # actual waiting time is 0 when setting ignore_implicit_wait to True
        self.assertEqual(0, driver.waiting_time)

        driver.waiting_time = 0
        existed_locators = [{'css': 'existed_css'}]
        get_locator(existed_locators)
        self.assertEqual(30, driver.waiting_time)
예제 #2
0
    def test_get_locator_timeout(self):
        content = [{'css': 'existed_css'}]
        timeout = 30
        driver = MockWebDriver(content=content, timeout=timeout)

        apiritif.put_into_thread_store(driver=driver,
                                       timeout=timeout,
                                       func_mode=False)

        missing_locators = [{'css': 'missing_css'}, {'xpath': 'missing_xpath'}]
        self.assertRaises(NoSuchElementException, get_locator,
                          missing_locators)
        self.assertEqual(30, driver.waiting_time)

        driver.waiting_time = 0
        existed_locators = [{'css': 'existed_css'}]
        get_locator(existed_locators)
        self.assertEqual(30, driver.waiting_time)
예제 #3
0
    def _1_None(self):
        with apiritif.smart_transaction('None'):

            for i in get_loop_range(self.vars['start'], self.vars['end'], self.vars['step']):
                self.vars['i'] = str(i)

                var_loc_keys = get_locator([{'id': 'id_{}'.format(self.vars['i'])}])
                self.driver.find_element(
                    var_loc_keys[0],
                    var_loc_keys[1]).click()
예제 #4
0
    def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')
            dialogs_replace()

            var_loc_wait = 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")
예제 #5
0
    def _1_Conditions_test(self):
        with apiritif.smart_transaction('Conditions test'):
            self.driver.get('http://blazedemo.com')

            waiter()

            test = self.driver.execute_script(
                'return document.getElementsByName("fromPort")[0].length > 0;')
            if test:

                var_loc_keys = get_locator([{
                    'id': 'wrong_id'
                }, {
                    'xpath':
                    '/html/body/div[3]/form/div/input'
                }])
                self.driver.find_element(var_loc_keys[0],
                                         var_loc_keys[1]).click()
                waiter()
                sleep(1.0)

                test = self.driver.execute_script(
                    'return document.getElementsByClassName("table")[0].rows.length > 5;'
                )
                if test:

                    var_loc_keys = get_locator([{
                        'xpath':
                        '/html/body/div[2]/table/tbody/tr[5]/td[1]/input'
                    }])
                    self.driver.find_element(var_loc_keys[0],
                                             var_loc_keys[1]).click()
                    waiter()

                    test = self.driver.execute_script(
                        'return document.getElementById("{}").value === \'\';'.
                        format(self.vars['input_name_id']))
                    if test:

                        var_loc_keys = get_locator([{
                            'id':
                            self.vars['input_name_id']
                        }])
                        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('John Doe')
                        waiter()
                    else:

                        var_loc_keys = get_locator([{
                            'id':
                            self.vars['input_name_id']
                        }])
                        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('Jack Green')
                        waiter()

                    var_loc_keys = get_locator([{
                        'xpath':
                        '/html/body/div[2]/form/div[11]/div/input'
                    }])
                    self.driver.find_element(var_loc_keys[0],
                                             var_loc_keys[1]).click()
                    waiter()
                    sleep(5.0)
            else:

                test = self.driver.execute_script(
                    'return document.getElementsByClassName("table")[0].rows.length > 5;'
                )
                if test:

                    var_loc_keys = get_locator([{'id': self.vars['elem2_id']}])
                    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('my text')
                    waiter()

                    test = self.driver.execute_script(
                        'return window.screen.width > 1000;')
                    if test:
                        self.driver.save_screenshot('file_1000')
                    else:
                        self.driver.save_screenshot('file')
                else:

                    var_loc_keys = get_locator([{
                        'xpath':
                        '/html/body/div[3]/input'
                    }])
                    self.driver.find_element(var_loc_keys[0],
                                             var_loc_keys[1]).click()
                    waiter()
예제 #6
0
    def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')
            dialogs_replace()

            var_loc_wait = 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')

            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())

            var_loc_wait = get_locator([{'name': 'toPort'}])
            WebDriverWait(self.driver, 3.5).until(
                econd.visibility_of_element_located(
                    (var_loc_wait[0], var_loc_wait[1])),
                "Element 'name':'toPort' failed to appear within 3.5s")

            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()
            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')

            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()
            self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame'))
            self.frm_mng.switch('index=1')
            self.frm_mng.switch('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_Shadow_locators_test(self):
        with apiritif.smart_transaction('Shadow locators test'):

            self.assertEqual(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button').
                get_attribute('innerText').strip(), 'text'.strip())

            self.assertEqual(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button[name={}]'
                    .format(self.vars['button_name'])).get_attribute(
                        'innerText').strip(), 'text'.strip())

            self.assertEqual(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button').
                get_attribute('value').strip(), 'value'.strip())

            self.assertEqual(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button').
                get_attribute('value').strip(), 'value'.strip())

            if find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'new text'),
                    find_element_by_shadow(
                        'c-basic, lightning-accordion-section, .slds-button'))
            else:
                raise NoSuchElementException((
                    "The element (shadow: '%s') is not a contenteditable element"
                    %
                    ('c-basic, lightning-accordion-section, .slds-button', )))

            if find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'new text'),
                    find_element_by_shadow(
                        'c-basic, lightning-accordion-section, .slds-button'))
            else:
                raise NoSuchElementException((
                    "The element (shadow: '%s') is not a contenteditable element"
                    %
                    ('c-basic, lightning-accordion-section, .slds-button', )))

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').click()
            waiter()

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').click()
            waiter()

            ActionChains(self.driver).double_click(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            ActionChains(self.driver).double_click(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            ActionChains(self.driver).context_click(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            ActionChains(self.driver).context_click(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            ActionChains(self.driver).click_and_hold(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            ActionChains(self.driver).click_and_hold(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            ActionChains(self.driver).release(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            ActionChains(self.driver).release(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            ActionChains(self.driver).move_to_element_with_offset(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'), -10,
                -10).perform()

            ActionChains(self.driver).move_to_element_with_offset(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'), -10,
                -10).perform()

            ActionChains(self.driver).move_to_element(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            ActionChains(self.driver).move_to_element(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()

            target = get_locator([{'id': 'id12'}])
            ActionChains(self.driver).drag_and_drop(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'),
                self.driver.find_element(target[0], target[1])).perform()
            waiter()

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

            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            target = get_locator([{'id': 'id12'}])
            ActionChains(self.driver).drag_and_drop(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button'),
                self.driver.find_element(target[0], target[1])).perform()
            waiter()

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

            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).perform()
            waiter()

            Select(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).select_by_visible_text('value')
            waiter()

            Select(
                find_element_by_shadow(
                    'c-basic, lightning-accordion-section, .slds-button')
            ).select_by_visible_text('value')
            waiter()

            self.vars['my_var'] = find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('innerText')

            self.vars['my_var'] = find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('innerText')

            self.vars['my_var'] = find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('value')

            self.vars['my_var'] = find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).get_attribute('value')

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').clear()
            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).send_keys('text')
            waiter()

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').clear()
            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).send_keys('text')
            waiter()

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').submit()

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button').submit()

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).send_keys(Keys.ENTER)

            find_element_by_shadow(
                'c-basic, lightning-accordion-section, .slds-button'
            ).send_keys(Keys.ENTER)

            wait_for('visible', [{'shadow': 'toPort'}], 5.0)
            wait_for('notvisible', [{
                'shadow':
                'c-basic, lightning-accordion-section, .slds-button'
            }], 2.0)
    def _1_Foreach_test(self):
        with apiritif.smart_transaction('Foreach test'):

            elements = get_elements([{
                'css': 'input'
            }, {
                'xpath': '/table/input/'
            }])
            for el in elements:
                self.assertEqual(
                    el.get_attribute('innerText').strip(), 'text'.strip())

                var_loc_as = get_locator([{
                    'css': 'style'
                }, {
                    'xpath': '//tr'
                }], el)
                self.assertEqual(
                    el.find_element(
                        var_loc_as[0],
                        var_loc_as[1]).get_attribute('innerText').strip(),
                    'text'.strip())
                self.assertEqual(
                    el.get_attribute('value').strip(), 'value'.strip())
                self.assertEqual(
                    el.get_attribute('value').strip(), 'value'.strip())

                if el.get_attribute('contenteditable'):
                    self.driver.execute_script(
                        ("arguments[0].innerHTML = '%s';" % 'new text'), el)
                else:
                    raise NoSuchElementException((
                        "The element '%s' (tag name: '%s', text: '%s') is not a contenteditable element"
                        % ('el', el.tag_name, el.text)))

                if el.get_attribute('contenteditable'):
                    self.driver.execute_script(
                        ("arguments[0].innerHTML = '%s';" % 'new text'), el)
                else:
                    raise NoSuchElementException((
                        "The element '%s' (tag name: '%s', text: '%s') is not a contenteditable element"
                        % ('el', el.tag_name, el.text)))
                el.click()
                waiter()

                var_loc_keys = get_locator([{
                    'css': 'input-cls'
                }, {
                    'xpath': '//input'
                }], el)
                el.find_element(var_loc_keys[0], var_loc_keys[1]).click()
                waiter()
                ActionChains(self.driver).double_click(el).perform()
                waiter()
                ActionChains(self.driver).double_click(el).perform()
                waiter()
                ActionChains(self.driver).context_click(el).perform()
                waiter()
                ActionChains(self.driver).context_click(el).perform()
                waiter()
                ActionChains(self.driver).click_and_hold(el).perform()
                ActionChains(self.driver).click_and_hold(el).perform()
                ActionChains(self.driver).release(el).perform()
                ActionChains(self.driver).release(el).perform()
                ActionChains(self.driver).move_to_element_with_offset(
                    el, -10, -10).perform()
                ActionChains(self.driver).move_to_element_with_offset(
                    el, -10, -10).perform()
                ActionChains(self.driver).move_to_element(el).perform()
                ActionChains(self.driver).move_to_element(el).perform()

                target = get_locator([{'id': 'id12'}])
                ActionChains(self.driver).drag_and_drop(
                    el, self.driver.find_element(target[0],
                                                 target[1])).perform()
                waiter()

                source = get_locator([{'id': 'id34'}])
                ActionChains(self.driver).drag_and_drop(
                    self.driver.find_element(source[0], source[1]),
                    el).perform()
                waiter()

                target = get_locator([{'id': 'id12'}])
                ActionChains(self.driver).drag_and_drop(
                    el, self.driver.find_element(target[0],
                                                 target[1])).perform()
                waiter()

                source = get_locator([{'id': 'id34'}])
                ActionChains(self.driver).drag_and_drop(
                    self.driver.find_element(source[0], source[1]),
                    el).perform()
                waiter()
                Select(el).select_by_visible_text('value')
                waiter()
                Select(el).select_by_visible_text('value')
                waiter()

                self.vars['my_var'] = el.get_attribute('innerText')

                self.vars['my_var'] = el.get_attribute('innerText')

                self.vars['my_var'] = el.get_attribute('value')

                self.vars['my_var'] = el.get_attribute('value')
                el.clear()
                el.send_keys('text')
                waiter()
                el.clear()
                el.send_keys('text')
                waiter()
                el.submit()
                el.submit()
                el.send_keys(Keys.ENTER)
                el.send_keys(Keys.ENTER)
    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")
예제 #11
0
    def _1_Shadow_locators_test(self):
        with apiritif.smart_transaction('Shadow locators test'):

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            self.assertEqual(var_loc_as.get_attribute('innerText').strip(), 'text'.strip())

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            self.assertEqual(var_loc_as.get_attribute('innerText').strip(), 'text'.strip())

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            self.assertEqual(var_loc_as.get_attribute('value').strip(), 'value'.strip())

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            self.assertEqual(var_loc_as.get_attribute('value').strip(), 'value'.strip())

            var_edit_content = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            if var_edit_content.get_attribute('contenteditable'):
                self.driver.execute_script(("arguments[0].innerHTML = '%s';" % 'new text'), var_edit_content)
            else:
                raise NoSuchElementException(("The element (shadow: '%s') is not a contenteditable element" % ('c-basic, lightning-accordion-section, .slds-button',)))

            var_edit_content = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            if var_edit_content.get_attribute('contenteditable'):
                self.driver.execute_script(("arguments[0].innerHTML = '%s';" % 'new text'), var_edit_content)
            else:
                raise NoSuchElementException(("The element (shadow: '%s') is not a contenteditable element" % ('c-basic, lightning-accordion-section, .slds-button',)))

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.click()

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.click()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).double_click(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).double_click(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).context_click(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).context_click(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).click_and_hold(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).click_and_hold(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).release(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).release(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).move_to_element_with_offset(var_loc_chain, -10, -10).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).move_to_element_with_offset(var_loc_chain, -10, -10).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).move_to_element(var_loc_chain).perform()

            var_loc_chain = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).move_to_element(var_loc_chain).perform()

            source = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            target = get_locator([{'id': 'id12'}])
            ActionChains(self.driver).drag_and_drop(source, self.driver.find_element(
                target[0],
                target[1])).perform()

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

            target = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).drag_and_drop(self.driver.find_element(
                source[0],
                source[1]), target).perform()

            source = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            target = get_locator([{'id': 'id12'}])
            ActionChains(self.driver).drag_and_drop(source, self.driver.find_element(
                target[0],
                target[1])).perform()

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

            target = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            ActionChains(self.driver).drag_and_drop(self.driver.find_element(
                source[0],
                source[1]), target).perform()

            var_loc_select = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            Select(var_loc_select).select_by_visible_text('value')

            var_loc_select = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            Select(var_loc_select).select_by_visible_text('value')

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            self.vars['my_var'] = var_loc_as.get_attribute('innerText')

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            self.vars['my_var'] = var_loc_as.get_attribute('innerText')

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            self.vars['my_var'] = var_loc_as.get_attribute('value')

            var_loc_as = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')

            self.vars['my_var'] = var_loc_as.get_attribute('value')

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.clear()
            send_keys(var_loc_keys, 'text')

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.clear()
            send_keys(var_loc_keys, 'text')

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.submit()

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            var_loc_keys.submit()

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            send_keys(var_loc_keys, Keys.ENTER)

            var_loc_keys = find_element_by_shadow('c-basic, lightning-accordion-section, .slds-button')
            send_keys(var_loc_keys, Keys.ENTER)