async def querySelectorAll_with_selenium_locator(self,
                                                  selenium_locator: str):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if self.selected_iframe is not None:
         return await self.selected_iframe.querySelectorAll(selector_value)
     else:
         return await self.get_page().querySelectorAll(selector_value)
Example #2
0
 async def querySelectorAll_with_selenium_locator(self,
                                                  selenium_locator: str):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         return await self.xpath(selector_value)
     else:
         return await self.querySelectorAll(selector_value)
Example #3
0
 async def click_with_selenium_locator(self,
                                       selenium_locator: str,
                                       options: dict = None,
                                       **kwargs: Any):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         await self.click_xpath(selector_value, options, **kwargs)
     else:
         await self.click(selector_value, options, **kwargs)
Example #4
0
 async def type_with_selenium_locator(self,
                                      selenium_locator: str,
                                      text: str,
                                      options: dict = None,
                                      **kwargs: Any):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         await self.type_xpath(selector_value, text, options, **kwargs)
     else:
         await super().type(selector_value, text, options, **kwargs)
 async def select_with_selenium_locator(self, selenium_locator: str,
                                        values: str):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         await self.get_selected_frame_or_page().evaluate('''
             element = document.evaluate('{selector_value}//option[contains(@value, "{values}")]', document, null, XPathResult.ANY_TYPE, null).iterateNext();
             element.selected = true;
         '''.format(selector_value=selector_value, values=values))
     else:
         return await self.get_selected_frame_or_page().select(
             selector_value, values)
 async def click_with_selenium_locator(self,
                                       selenium_locator: str,
                                       options: dict = None,
                                       **kwargs: Any):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if options is None:
         options = {}
     if self.selected_iframe is not None:
         return await self.selected_iframe.click(selector=selector_value,
                                                 **options)
     else:
         return await self.page.click(selector=selector_value, **options)
Example #7
0
 async def waitForSelector_with_selenium_locator(self, selenium_locator: str, timestr: str = None, visible=False, hidden=False):
     if timestr is None:
         timestr = '30s'
     timesecs = timestr_to_secs(timestr)
     options = {
         'timeout': timesecs * 1000,
         'visible': visible,
         'hidden': hidden
     }
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         return await self.waitForXPath(selector_value, options)
     else:
         return await self.waitForSelector(selector_value, options)
Example #8
0
 async def waitForSelector_with_selenium_locator(self,
                                                 selenium_locator: str,
                                                 timeout: float,
                                                 visible=False,
                                                 hidden=False):
     options = {
         'timeout': timeout * 1000,
         'visible': visible,
         'hidden': hidden
     }
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if SelectorAbstraction.is_xpath(selenium_locator):
         return await self.waitForXPath(selector_value, options)
     else:
         return await self.waitForSelector(selector_value, options)
Example #9
0
 async def select_from_list_by_label(self, locator, labels):
     evaluate = ''
     selector_value = SelectorAbstraction.get_selector(locator)
     if SelectorAbstraction.is_xpath(locator):
         evaluate = '''
             element = document.evaluate('{selector_value}//option[text()=\"{label}\"]', document, null, XPathResult.ANY_TYPE, null).iterateNext();
             element.selected = true;
         '''.format(selector_value=selector_value, label=labels)
     else:
         evaluate = '''
             selector_element = document.querySelector('{selector_value}');
             element = document.evaluate('//option[text()=\"{label}\"]', selector_element, null, XPathResult.ANY_TYPE, null).iterateNext();
             element.selected = true;
         '''.format(selector_value=selector_value, label=labels)
     return await self.library_ctx.get_current_page().evaluate_with_selenium_locator(evaluate)
    async def waitForSelector_with_selenium_locator(self,
                                                    selenium_locator: str,
                                                    timeout: float,
                                                    visible=False,
                                                    hidden=False):
        options = {'timeout': timeout * 1000, 'state': 'visible'}
        if visible is True:
            options['state'] = 'visible'
        if hidden is True:
            options['state'] = 'hidden'

        selector_value = SelectorAbstraction.get_selector(selenium_locator)
        return await self.get_page().waitForSelector(
            selector=selector_value,
            timeout=options['timeout'],
            state=options['state'])
Example #11
0
 async def type_with_selenium_locator(self,
                                      selenium_locator: str,
                                      text: str,
                                      options: dict = None,
                                      **kwargs: Any):
     selector_value = SelectorAbstraction.get_selector(selenium_locator)
     if options is None:
         options = {'state': 'visible'}
     if self.selected_iframe is not None:
         await self.selected_iframe.wait_for_selector(
             selector=selector_value, **options)
         return await self.selected_iframe.type(selector=selector_value,
                                                text=text)
     else:
         await self.page.wait_for_selector(selector=selector_value,
                                           **options)
         return await self.page.type(selector=selector_value, text=text)
Example #12
0
 async def select_from_list_by_value(self, locator, values):
     selector_value = SelectorAbstraction.get_selector(locator)
     return await self.library_ctx.get_current_page(
     ).get_selected_frame_or_page().selectOption(selector_value,
                                                 {'value': values})
Example #13
0
 async def select_from_list_by_label(self, locator, labels):
     labels = str2str(labels)
     selector_value = SelectorAbstraction.get_selector(locator)
     return await self.library_ctx.get_current_page(
     ).get_selected_frame_or_page().select_option(selector_value,
                                                  label=labels)