def exportVariables(self, exportedVariables=None, flat=False): """ return the used webelements variables as a dictionary """ if exportedVariables == None: exportedVariables = {} if flat: if self.name: prevValue = exportedVariables.get(self.name, None) if type(prevValue) == list: prevValue.append(self.value) elif prevValue != None: exportedVariables[self.name] = [prevValue, self.value()] else: exportedVariables[self.name] = self.value() elif self.id: exportedVariables[self.id] = self.value() else: if self.key: DictUtils.setNestedValue(exportedVariables, self.key, self.value()) Base.WebElement.exportVariables(self, exportedVariables, flat) return exportedVariables
def insertVariables(self, variableDict=None): """ Populate webElement and child webElements with (id/name/key):value dictionary: variableDict - the dictionary to use to populate the elements """ if variableDict == None: variableDict = {} for regeneration in self.regenerate: iterator = regeneration['using'] method = self.__getattribute__(regeneration['action']) limit = regeneration.get('limitedBy', None) if limit != None: limit = int(variableDict.get(limit, '0')) for instance, value in DictUtils.iterateOver( variableDict, self.prefix() + iterator): if limit != None and instance >= limit: break if acceptsArguments(method, 2): method(instance, value) elif acceptsArguments(method, 1): method(value) for child in self.childElements: child.insertVariables(variableDict)
def insertVariables(self, variableDict=None): """ Populate webElement and child webElements with (id/name/key):value dictionary: variableDict - the dictionary to use to populate the elements """ if variableDict == None: variableDict = {} for regeneration in self.regenerate: iterator = regeneration['using'] method = self.__getattribute__(regeneration['action']) limit = regeneration.get('limitedBy', None) if limit != None: limit = int(variableDict.get(limit, '0')) for instance, value in DictUtils.iterateOver(variableDict, self.prefix() + iterator): if limit != None and instance >= limit: break if acceptsArguments(method, 2): method(instance, value) elif acceptsArguments(method, 1): method(value) for child in self.childElements: child.insertVariables(variableDict)
def exportVariables(self, exportedVariables=None, flat=False): """ return the used webelements variables as a dictionary """ if exportedVariables == None: exportedVariables = {} if flat: if self.name: prevValue = exportedVariables.get(self.name, None) if type(prevValue) == list: prevValue.append(self.value) elif prevValue != None: exportedVariables[self.name] = [prevValue, self.value()] else: exportedVariables[self.name] = self.value() elif self.id: exportedVariables[self.id] = self.value() else: if self.key: DictUtils.setNestedValue(exportedVariables, self.key, self.value()) DOM.Input.exportVariables(self, exportedVariables, flat) return exportedVariables
def insertVariables(self, variableDict=None): if variableDict == None: variableDict = {} value = None if self.key: value = DictUtils.getNestedValue(variableDict, self.key) if self.fullId() and value == None: value = variableDict.get(self.fullId(), None) if self.id and value == None: value = variableDict.get(self.id, None) if self.name and value == None: value = variableDict.get(self.fullName(), None) if value != None: self.setValue(value) self._removeFromDictionary(variableDict)
def insertVariables(self, variableDict=None): """ Updates the value based on a dictionary, popping it out afterwards """ if variableDict == None: variableDict = {} Base.WebElement.insertVariables(self, variableDict) value = None removeFromDictionary = True if self.key: value = DictUtils.getNestedValue(variableDict, self.key) if self.fullId() and value == None: value = variableDict.get(self.fullId(), None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if self.id and value == None: value = variableDict.get(self.id, None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if self.name and value == None: value = variableDict.get(self.fullName(), None) if value == None: value = variableDict.get(self.name, None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if value != None: self.setValue(value) if removeFromDictionary: self._removeFromDictionary(variableDict)
def insertVariables(self, variableDict=None): """ Updates the value based on a dictionary, popping it out afterwards """ if variableDict == None: variableDict = {} DOM.Input.insertVariables(self, variableDict) value = None removeFromDictionary = True if self.key: value = DictUtils.getNestedValue(variableDict, self.key) if self.fullId() and value == None: value = variableDict.get(self.fullId(), None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if self.id and value == None: value = variableDict.get(self.id, None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if self.name and value == None: value = variableDict.get(self.fullName(), None) if value == None: value = variableDict.get(self.name, None) if value and type(value) in (types.ListType, types.TupleType): if len(value) > 1: removeFromDictionary = False value = value.pop(0) if value != None: self.setValue(value) if removeFromDictionary: self._removeFromDictionary(variableDict)