|
@@ -232,141 +232,188 @@ class TestStepMaster:
|
|
|
if not TestStepMaster.ifQualifyForExecution(self.globalRelease, lRelease):
|
|
|
logger.debug(f"we skipped this line due to {lRelease} disqualifies according to {self.globalRelease} ")
|
|
|
return
|
|
|
- if lActivity == "GOTOURL":
|
|
|
- if lValue:
|
|
|
- self.browserSession.goToUrl(lValue)
|
|
|
- elif lLocator:
|
|
|
- self.browserSession.goToUrl(lLocator)
|
|
|
- else:
|
|
|
- logger.critical("GotoURL without URL called. Aborting. "
|
|
|
- "Please provide URL either in Value or Locator columns")
|
|
|
- elif lActivity == "SETTEXT":
|
|
|
- self.browserSession.findByAndSetText(xpath=xpath, css=css, id=id, value=lValue, timeout=lTimeout,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "SETTEXTIF":
|
|
|
- self.browserSession.findByAndSetTextIf(xpath=xpath, css=css, id=id, value=lValue, timeout=lTimeout,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "FORCETEXT":
|
|
|
- self.browserSession.findByAndForceText(xpath=xpath, css=css, id=id, value=lValue, timeout=lTimeout,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "FORCETEXTIF":
|
|
|
- if lValue:
|
|
|
- self.browserSession.findByAndForceText(xpath=xpath, css=css, id=id, value=lValue, timeout=lTimeout,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "FORCETEXTJS":
|
|
|
- if lValue:
|
|
|
- self.browserSession.findByAndForceViaJS(xpath=xpath, css=css, id=id, value=lValue, timeout=lTimeout,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "SETANCHOR":
|
|
|
- if not lLocator:
|
|
|
+
|
|
|
+ if lActivity[0:3] == "ZZ_":
|
|
|
+ # custom command. Do nothing and return
|
|
|
+ return
|
|
|
+ elif lActivity.lower() == "if":
|
|
|
+ lActivity = "if_"
|
|
|
+ elif lActivity.lower() == "else":
|
|
|
+ lActivity = "else_"
|
|
|
+ elif lActivity.lower() == "assert":
|
|
|
+ lActivity = "assert_"
|
|
|
+ try:
|
|
|
+ kwargs = locals()
|
|
|
+ del kwargs["self"]
|
|
|
+ getattr(self, lActivity.lower())(**kwargs)
|
|
|
+ except AttributeError:
|
|
|
+ raise BaseException(f"Unknown command in TestStep {lActivity}")
|
|
|
+ self.timing.takeTime(lTimingString)
|
|
|
+
|
|
|
+ def gotourl(self, **kwargs):
|
|
|
+ if kwargs["lValue"]:
|
|
|
+ self.browserSession.goToUrl(kwargs["lValue"])
|
|
|
+ elif kwargs["lLocator"]:
|
|
|
+ self.browserSession.goToUrl(kwargs["lLocator"])
|
|
|
+ else:
|
|
|
+ logger.critical("GotoURL without URL called. Aborting. "
|
|
|
+ "Please provide URL either in Value or Locator columns")
|
|
|
+
|
|
|
+
|
|
|
+ def settext(self, **kwargs):
|
|
|
+ self.browserSession.findByAndSetText(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], value=kwargs["lValue"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def settextif(self, **kwargs):
|
|
|
+ self.browserSession.findByAndSetTextIf(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], value=kwargs["lValue"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def forcetext(self, **kwargs):
|
|
|
+ self.browserSession.findByAndForceText(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], value=kwargs["lValue"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def forcetextif(self, **kwargs):
|
|
|
+ if kwargs["lValue"]:
|
|
|
+ self.browserSession.findByAndForceText(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], value=kwargs["lValue"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def forcetextjs(self, **kwargs):
|
|
|
+ if kwargs["lValue"]:
|
|
|
+ self.browserSession.findByAndForceViaJS(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], value=kwargs["lValue"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def setanchor(self, **kwargs):
|
|
|
+ if not kwargs["lLocator"]:
|
|
|
self.anchor = None
|
|
|
self.anchorLocator = None
|
|
|
self.anchorLocatorType = None
|
|
|
else:
|
|
|
- found = self.browserSession.findBy(xpath=xpath, css=css, id=id, timeout=lTimeout)
|
|
|
+ found = self.browserSession.findBy(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], timeout=kwargs["lTimeout"])
|
|
|
if found:
|
|
|
self.anchor = self.browserSession.element
|
|
|
- self.anchorLocator = lLocator
|
|
|
- self.anchorLocatorType = lLocatorType
|
|
|
- logger.debug(f"Anchor set: {lLocatorType} {lLocator}")
|
|
|
+ self.anchorLocator = kwargs["lLocator"]
|
|
|
+ self.anchorLocatorType = kwargs["lLocatorType"]
|
|
|
+ logger.debug(f'Anchor set: {kwargs["lLocatorType"]} {kwargs["lLocator"]}')
|
|
|
else:
|
|
|
- logger.error(f"Anchor should be set, but can't be found in the current page: {lLocatorType}, {lLocator}")
|
|
|
- raise ValueError(f"Anchor should be set, but can't be found in the current page: {lLocatorType}, {lLocator}")
|
|
|
- elif lActivity == 'HANDLEIFRAME':
|
|
|
- self.browserSession.handleIframe(lLocator)
|
|
|
- elif lActivity == 'SWITCHWINDOW':
|
|
|
- lWindow = lValue
|
|
|
+ logger.error(f'Anchor should be set, but can\'t be found in the current page: {kwargs["lLocatorType"]}, {kwargs["lLocator"]}')
|
|
|
+ raise ValueError(f'Anchor should be set, but can\'t be found in the current page: {kwargs["lLocatorType"]}, {kwargs["lLocator"]}')
|
|
|
+
|
|
|
+ def handleiframe(self, **kwargs):
|
|
|
+ self.browserSession.handleIframe(kwargs["lLocator"])
|
|
|
+
|
|
|
+ def switchwindow(self, **kwargs):
|
|
|
+ lWindow = kwargs["lValue"]
|
|
|
if lWindow.isnumeric():
|
|
|
lWindow = int(lWindow)
|
|
|
- self.browserSession.handleWindow(windowNumber=lWindow, timeout=lTimeout)
|
|
|
- elif lActivity == "CLICK":
|
|
|
- self.browserSession.findByAndClick(xpath=xpath, css=css, id=id, timeout=lTimeout, optional=lOptional)
|
|
|
- elif lActivity == "CLICKIF":
|
|
|
- self.browserSession.findByAndClickIf(xpath=xpath, css=css, id=id, timeout=lTimeout, value=lValue,
|
|
|
- optional=lOptional)
|
|
|
- elif lActivity == "PAUSE":
|
|
|
- self.browserSession.sleep(seconds=float(lValue))
|
|
|
- elif lActivity == "IF":
|
|
|
+ self.browserSession.handleWindow(windowNumber=lWindow, timeout=kwargs["lTimeout"])
|
|
|
+
|
|
|
+ def click(self, **kwargs):
|
|
|
+ self.browserSession.findByAndClick(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"],
|
|
|
+ timeout=kwargs["lTimeout"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def clickif(self, **kwargs):
|
|
|
+ self.browserSession.findByAndClickIf(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"],
|
|
|
+ timeout=kwargs["lTimeout"], value=kwargs["lValue"], optional=kwargs["lOptional"])
|
|
|
+
|
|
|
+ def pause(self, **kwargs):
|
|
|
+ self.browserSession.sleep(seconds=float(kwargs["lValue"]))
|
|
|
+
|
|
|
+ def if_(self, **kwargs):
|
|
|
# Originally we had only Comparisons. Now we also want to check for existance of Field
|
|
|
- if not lValue and lLocatorType and lLocator:
|
|
|
- lValue = self.browserSession.findBy(xpath=xpath, css=css, id=id, optional=lOptional,
|
|
|
- timeout=lTimeout)
|
|
|
-
|
|
|
- self.__doComparisons(lComparison=lComparison, value1=lValue, value2=lValue2)
|
|
|
- logger.debug(f"IF-condition original Value: {original_value} (transformed: {lValue}) {lComparison} {lValue2} "
|
|
|
- f"evaluated to: {self.ifIsTrue} ")
|
|
|
- elif lActivity == "ELSE":
|
|
|
+ if not kwargs["lValue"] and kwargs["lLocatorType"] and kwargs["lLocator"]:
|
|
|
+ kwargs["lValue"] = self.browserSession.findBy(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"], optional=kwargs["lOptional"],
|
|
|
+ timeout=kwargs["lTimeout"])
|
|
|
+
|
|
|
+ self.__doComparisons(kwargs["lComparison"], value1=kwargs["lValue"], value2=kwargs["lValue"])
|
|
|
+ logger.debug(f'IF-condition original Value: {kwargs["original_value"]} (transformed: {kwargs["lValue"]}) '
|
|
|
+ f'{kwargs["lComparison"]} {kwargs["lValue"]} evaluated to: {self.ifIsTrue} ')
|
|
|
+
|
|
|
+ def else_(self, **kwargs):
|
|
|
if not self.ifIsTrue: # don't run else statement if "if" statement is true
|
|
|
- self.manageNestedCondition(condition=lActivity)
|
|
|
+ self.manageNestedCondition(condition=kwargs["lActivity"])
|
|
|
logger.debug("Executing ELSE-condition")
|
|
|
else:
|
|
|
self.ifIsTrue = False
|
|
|
- elif lActivity == "ENDIF":
|
|
|
- self.manageNestedCondition(condition=lActivity)
|
|
|
- elif lActivity == "REPEAT":
|
|
|
+
|
|
|
+ def endif(self, **kwargs):
|
|
|
+ self.manageNestedCondition(condition=kwargs["lActivity"])
|
|
|
+
|
|
|
+ def repeat(self, **kwargs):
|
|
|
self.repeatActive += 1
|
|
|
self.repeatIsTrue = True
|
|
|
self.repeatCommands.append({})
|
|
|
- if original_value not in self.testRunInstance.json_dict:
|
|
|
- self.testRunInstance.json_dict[original_value] = []
|
|
|
- self.testRunInstance.json_dict[original_value].append(lValue)
|
|
|
- self.repeatReplaceDataDictionary.append(lValue)
|
|
|
- self.repeatCount.append(lValue2)
|
|
|
- elif lActivity == 'GOBACK':
|
|
|
+ if kwargs["original_value"] not in self.testRunInstance.json_dict:
|
|
|
+ self.testRunInstance.json_dict[kwargs["original_value"]] = []
|
|
|
+ self.testRunInstance.json_dict[kwargs["original_value"]].append(kwargs["lValue"])
|
|
|
+ self.repeatReplaceDataDictionary.append(kwargs["lValue"])
|
|
|
+ self.repeatCount.append(kwargs["lValue"])
|
|
|
+
|
|
|
+ def goback(self, **kwargs):
|
|
|
self.browserSession.goBack()
|
|
|
- elif lActivity == 'APIURL':
|
|
|
- self.apiSession.setBaseURL(lValue)
|
|
|
- elif lActivity == 'ENDPOINT':
|
|
|
- self.apiSession.setEndPoint(lValue)
|
|
|
- elif lActivity == 'POST':
|
|
|
- self.apiSession.postURL(content=lValue)
|
|
|
- elif lActivity == 'GET':
|
|
|
+
|
|
|
+ def apiurl(self, **kwargs):
|
|
|
+ self.apiSession.setBaseURL(kwargs["lValue"])
|
|
|
+
|
|
|
+ def endpoint(self, **kwargs):
|
|
|
+ self.apiSession.setEndPoint(kwargs["lValue"])
|
|
|
+
|
|
|
+ def post(self, **kwargs):
|
|
|
+ self.apiSession.postURL(content=kwargs["lValue"])
|
|
|
+
|
|
|
+ def get(self, **kwargs):
|
|
|
self.apiSession.getURL()
|
|
|
- elif lActivity == 'HEADER':
|
|
|
- self.apiSession.setHeaders(setHeaderData=lValue)
|
|
|
- elif lActivity == 'SAVE':
|
|
|
- self.doSaveData(lValue, lValue2, lLocatorType, lLocator)
|
|
|
- elif lActivity == 'CLEAR':
|
|
|
+
|
|
|
+ def header(self, **kwargs):
|
|
|
+ self.apiSession.setHeaders(setHeaderData=kwargs["lValue"])
|
|
|
+
|
|
|
+ def save(self, **kwargs):
|
|
|
+ self.doSaveData(kwargs["lValue"], kwargs["lValue"], kwargs["lLocatorType"], kwargs["lLocator"])
|
|
|
+
|
|
|
+ def clear(self, **kwargs):
|
|
|
# Clear a variable:
|
|
|
- if self.testcaseDataDict.get(lValue):
|
|
|
- del self.testcaseDataDict[lValue]
|
|
|
- elif lActivity == 'SAVETO':
|
|
|
+ if self.testcaseDataDict.get(kwargs["lValue"]):
|
|
|
+ del self.testcaseDataDict[kwargs["lValue"]]
|
|
|
+
|
|
|
+ def saveto(self, **kwargs):
|
|
|
# In this case, we need to parse the real field, not the representation of the replaced field value
|
|
|
- self.doSaveData(command['Value'], lValue2, lLocatorType, lLocator)
|
|
|
- elif lActivity == 'SUBMIT':
|
|
|
+ self.doSaveData(kwargs["command"]['Value'], kwargs["lValue"], kwargs["lLocatorType"], kwargs["lLocator"])
|
|
|
+
|
|
|
+ def submit(self, **kwargs):
|
|
|
self.browserSession.submit()
|
|
|
- elif lActivity == "ADDRESS_CREATE":
|
|
|
- # Create Address with option lValue and lValue2
|
|
|
- AddressCreate(lValue, lValue2)
|
|
|
+
|
|
|
+ def address_create(self, **kwargs):
|
|
|
+ # Create Address with option kwargs["lValue"] and kwargs["lValue"]
|
|
|
+ AddressCreate(kwargs["lValue"], kwargs["lValue"])
|
|
|
# Update testcaseDataDict with addressDict returned from
|
|
|
AddressCreate.returnAddress()
|
|
|
self.testcaseDataDict.update(AddressCreate.returnAddress())
|
|
|
- elif lActivity == 'ASSERT':
|
|
|
- value_found = self.browserSession.findByAndWaitForValue(xpath=xpath, css=css, id=id, optional=lOptional,
|
|
|
- timeout=lTimeout)
|
|
|
- if not self.__doComparisons(lComparison=lComparison, value1=value_found, value2=lValue):
|
|
|
- logger.error(f"Condition {value_found} {lComparison} {lValue} was not met during assert.")
|
|
|
- raise baangtTestStepException(f"Expected Value: {lValue}, Value found :{value_found} ")
|
|
|
- elif lActivity == 'IBAN':
|
|
|
+
|
|
|
+ def assert_(self, **kwargs):
|
|
|
+ value_found = self.browserSession.findByAndWaitForValue(xpath=kwargs["xpath"], css=kwargs["css"], id=kwargs["id"],
|
|
|
+ optional=kwargs["lOptional"], timeout=kwargs["lTimeout"])
|
|
|
+ if not self.__doComparisons(kwargs["lComparison"], value1=value_found, value2=kwargs["lValue"]):
|
|
|
+ logger.error(f'Condition {value_found} {kwargs["lComparison"]} {kwargs["lValue"]} was not met during assert.')
|
|
|
+ raise baangtTestStepException(f'Expected Value: {kwargs["lValue"]}, Value found :{value_found} ')
|
|
|
+
|
|
|
+ def iban(self, **kwargs):
|
|
|
# Create Random IBAN. Value1 = Input-Parameter for IBAN-Function. Value2=Fieldname
|
|
|
- self.__getIBAN(lValue, lValue2)
|
|
|
- elif lActivity == 'PDFCOMPARE':
|
|
|
- self.doPDFComparison(lValue)
|
|
|
- elif lActivity == 'CHECKLINKS':
|
|
|
+ self.__getIBAN(kwargs["lValue"], kwargs["lValue2"])
|
|
|
+
|
|
|
+ def pdfcompare(self, **kwargs):
|
|
|
+ self.doPDFComparison(kwargs["lValue"])
|
|
|
+
|
|
|
+ def checklinks(self, **kwargs):
|
|
|
self.checkLinks()
|
|
|
- elif lActivity == 'ALERTIF':
|
|
|
+
|
|
|
+ def alertif(self, **kwargs):
|
|
|
self.browserSession.confirmAlertIfAny()
|
|
|
- elif lActivity == GC.TESTCASESTATUS_STOP.upper():
|
|
|
+
|
|
|
+ def tcstoptestcase(self, **kwargs):
|
|
|
self.testcaseDataDict[GC.TESTCASESTATUS_STOP] = "X" # will stop the test case
|
|
|
- elif lActivity == GC.TESTCASESTATUS_STOPERROR.upper():
|
|
|
+
|
|
|
+ def tcstoptestcaseerror(self, **kwargs):
|
|
|
self.testcaseDataDict[GC.TESTCASESTATUS_STOPERROR] = "X" # will stop the test case and set error
|
|
|
- elif lActivity[0:3] == "ZZ_":
|
|
|
- # custom command. Do nothing and return
|
|
|
- return
|
|
|
- else:
|
|
|
- raise BaseException(f"Unknown command in TestStep {lActivity}")
|
|
|
|
|
|
- self.timing.takeTime(lTimingString)
|
|
|
|
|
|
def _extractAllSingleValues(self, command):
|
|
|
lActivity = command["Activity"].upper()
|