Browse Source

Subclassing Demo Initial Commit

bernhardbuhl 3 years ago
commit
1885634172
7 changed files with 198 additions and 0 deletions
  1. 18 0
      README.md
  2. 7 0
      baangtIA.py
  3. 11 0
      examples/globals.json
  4. BIN
      examples/simpleAutomationpractice.xlsx
  5. 152 0
      globalSetting.json
  6. 9 0
      myTestCaseSequence.py
  7. 1 0
      requirements.txt

+ 18 - 0
README.md

@@ -0,0 +1,18 @@
+# Aim
+
+This is a simple example showing how easy it is to subclass single classes (most probably only methods of these classes)
+and other than that use the power of baangt.
+
+# What we find here:
+* baangtIA.py --> the baangt interactive starter
+* requirements.txt --> instructions for your virtual environment (only baangt - all other dependencies are loaded from there)
+* README.md --> this file
+* teststepmaster.py --> The subclassed file with a new method
+* examples/globals.json --> The settings file, where we'll tell baangt to use a different TestStepMaster class
+* examples/simpleAutomationpractice.xlsx --> The testrun, testcase and testdata we want to execute
+
+# How to use it:
+* Start with ``python baangtIA.py``
+    * Examples-Folder TestRun and Settings-file already selected
+* Execute
+* As you'd expect you'll find "here runs our code!" in the logs, everything else runs normal!

+ 7 - 0
baangtIA.py

@@ -0,0 +1,7 @@
+from gevent import monkey
+monkey.patch_all()
+from baangt.base.CliAndInteractive import run
+
+if __name__ == '__main__':
+    run()
+

+ 11 - 0
examples/globals.json

@@ -0,0 +1,11 @@
+{
+    "TC.ParallelRuns": "1",
+    "TC.Lines": "",
+    "TC.dontCloseBrowser": "True",
+    "TC.slowExecution": "False",
+    "TC.NetworkInfo": "False",
+    "CL.testCaseSequenceMaster": "myTestCaseSequence",
+    "TC.BrowserAttributes": "",
+    "TX.DEBUG": "True",
+    "TC.Browser": "FF"
+}

BIN
examples/simpleAutomationpractice.xlsx


+ 152 - 0
globalSetting.json

@@ -0,0 +1,152 @@
+{
+    "settings": {
+        "TC.slowExecution": {
+            "hint": "Stop execution for 1 second after each step. Great for tracing errors!",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False"],
+            "displayText": "Slow execution"
+        },
+        "TC.dontCloseBrowser":  {
+            "hint": "When the browser or script finds an error, it usually takes a screenshot and moves on to the next testcase. With this setting to True the browser session will stop right at the error.",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False"],
+            "displayText": "Don't close Browser"
+        },
+        "TC.Browser": {
+            "hint": "Choose browser for this test run",
+            "type": "select",
+            "default": "FF",
+            "options": ["FF", "Chrome", "Safari", "Edge", "REMOTE", "REMOTE_V4"],
+            "displayText": "Browser"
+        },
+        "TC.BrowserAttributes": {
+            "hint": "Choose browser attributes for this test run and Browser",
+            "type": "select",
+            "default": "",
+            "options": ["{'HEADLESS':'True'}",
+                        "{'browserName': 'firefox', 'seleniumGridIp': 'localhost', 'seleniumGridPort': '4444'}",
+                        ""],
+            "displayText": "Browser attributes"
+        },
+        "TC.BrowserWindowSize": {
+            "hint": "Size of the browser window",
+            "type": "text",
+            "default": "1024x768",
+            "displayText": "Browser Size"
+        },
+        "TC.BrowserZoomFactor": {
+            "hint": "Set the Zoom Factor level for the browser window. Default = 100. Switch e.g. to 70 or 120",
+            "type": "text",
+            "default": "100",
+            "displayText": "Zoom Factor"
+        },
+        "TC.ParallelRuns": {
+            "hint": "How many sessions do you want to run in parallel",
+            "type": "text",
+            "default": "",
+            "displayText": "Parallel execution"
+        },
+        "TC.Lines":  {
+            "hint": "Lines to execute for this test case. Syntax: 1, 5, 9, 10-50, 700-900",
+            "type": "text",
+            "default": "",
+            "options:": "",
+            "displayText": "Lines from Testfile"
+        },
+        "TC.NetworkInfo": {
+            "hint": "Trace Network status Information",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "Trace Network Info"
+        },
+        "TC.ExportAllFields": {
+            "hint": "Ignore other settings and export all fields of the testDataFile to export format",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "Export all fields"
+        },
+        "TC.Stage": {
+            "hint": "Set the Stage (usually DEV, QA, PQA, FQA, PROD, etc.). It is common to have master data or settings per stage. If that doesn't apply to you, use 'other'",
+            "type": "text",
+            "default": "other",
+            "options": ["DEV", "PQA", "FQA", "PROD"],
+            "displayText": "Stage"
+        },
+        "TC.Release": {
+            "hint": "set particular version to test ",
+            "type": "text",
+            "default": "",
+            "options": "",
+            "displayText": "Current Release"
+        },
+        "TX.DEBUG": {
+            "hint": "Don't start new thread for execution. Use same thread. Used sometimes for debugging",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "Debug execution"
+        },
+        "TC.RestartBrowser": {
+            "hint": "After each TestCase restart the browser",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "Restart Browser"
+        },
+        "TC.UseRotatingProxies": {
+            "hint": "Use rotating proxies for each new browser Session",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "Rotate Proxies"
+        },
+        "TC.ReReadProxies": {
+            "hint": "Constantly search for available and working Proxy-Servers",
+            "type": "bool",
+            "default": "False",
+            "options": ["True", "False" ],
+            "displayText": "ReRead Proxies"
+        },
+        "CL.browserFactory":{
+            "hint": "Class for BrowserFactory, if you subclassed that by yourself",
+            "type": "text",
+            "default": "baangt.base.BrowserFactory.BrowserFactory",
+            "displayText": "Class BrowserFactory"
+        },
+        "CL.browserHandling":{
+            "hint": "Class for BrowserHandling, if you subclassed that by yourself",
+            "type": "text",
+            "default": "baangt.base.BrowserHandling.BrowserHandling.BrowserDriver",
+            "displayText": "Class BrowserHandling"
+        },
+        "CL.testCaseSequenceMaster":{
+            "hint": "Class for TestCase-Sequence, if you subclassed that by yourself",
+            "type": "text",
+            "default": "baangt.TestCaseSequenceMaster.TestCaseSequenceMaster",
+            "displayText": "Class TC-Sequence"
+        },
+        "TC.TestStepClass": {
+            "hint": "Class for TestStep, if you subclassed this by yourself. This is uncommon to be set in Globals. Are you sure about it?",
+            "type": "text",
+            "default": "",
+            "displayText": "Class for TestStep"
+        },
+        "TC.TestDataFileName": {
+            "hint": "Name and Path of the datafile, that should be used instead of the datafile, that is specified in the TestRun Definition",
+            "type": "text",
+            "default": "",
+            "displayText": "Datafile"
+        },
+        "TC.LogLevel": {
+            "hint": "Set the level of logging. Standard = 'debug'. For production you might want to change to another value",
+            "type": "select",
+            "default": "",
+            "options": ["", "Debug", "Info", "Warning", "Error"],
+            "displayText": "LogLevel"
+        }
+    }
+}

+ 9 - 0
myTestCaseSequence.py

@@ -0,0 +1,9 @@
+from baangt.TestCaseSequence.TestCaseSequenceMaster import TestCaseSequenceMaster
+from logging import getLogger
+
+logger = getLogger("pyC")
+
+class myTestCaseSequence(TestCaseSequenceMaster):
+    def execute(self):
+        logger.critical("here runs our code!")
+        super().execute()

+ 1 - 0
requirements.txt

@@ -0,0 +1 @@
+baangt