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