def click_location(self, name, partial=False, handle_alert=False): """Clicks a location present in the breadcrumbs by string name. Args: name: location name partial(bool): Whether to use partial match handle_alert: handle the browser alert and ensure page safe """ try: location = next( loc for loc in self._path_elements if (not partial and (self.browser.text(loc) == name)) or (partial and (name in self.browser.text(loc))) ) except StopIteration: partial_msg = " with partial match" if partial else "" locs = f" within locations: {self.locations}" raise WidgetOperationFailed( f'Breadcrumb location "{name}" not found{partial_msg}{locs}' ) self.browser.click(location, ignore_ajax=handle_alert) if handle_alert: self.browser.handle_alert(wait=2.0) self.browser.plugin.ensure_page_safe()
def select(self, locator, value): """Select or deselect checkbox depends on the value passed""" value = bool(value) current_value = self.checkbox_selected(locator) if value == current_value: return False self.browser.click(locator, parent=self) if self.checkbox_selected(locator) != value: raise WidgetOperationFailed( 'Failed to set the checkbox to requested value.') return True
def fill(self, value): value = bool(value) current_value = self.selected if value == current_value: return False else: self.click(handle_alert=True) if self.selected != value: raise WidgetOperationFailed( 'Failed to set the checkbox to requested value.') return True
def fill(self, value): value = bool(value) current_value = self.selected if value == current_value: return False else: self.click() if self.selected != value: # TODO: More verbose here raise WidgetOperationFailed('Failed to set the checkbox to requested value.') return True