Ejemplo n.º 1
0
    def test_shadow_element_actions(self):
        content = [{'css': 'lightning_card'}]
        timeout = 30
        driver = MockWebDriver(content=content, timeout=timeout)

        put_into_thread_store(driver=driver, timeout=timeout, func_mode=False)
        el = find_element_by_shadow('lightning_card')
        el.click()
        self.assertEqual('arguments[0].click();', driver.executed_script)
    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)
Ejemplo n.º 3
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)