diff --git a/dashboard/UI-Test/.gitignore b/dashboard/UI-Test/.gitignore new file mode 100644 index 0000000000..e586db349d --- /dev/null +++ b/dashboard/UI-Test/.gitignore @@ -0,0 +1,14 @@ +.vscode/ +tmp/ +wtlog.log +geckodriver.log + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + diff --git a/dashboard/UI-Test/README.md b/dashboard/UI-Test/README.md new file mode 100644 index 0000000000..9c82746c40 --- /dev/null +++ b/dashboard/UI-Test/README.md @@ -0,0 +1,92 @@ +[WTRobot](https://pypi.org/project/wtrobot/) is a keyword driven UI/frontend testing framework. + +## Setup + +### Install + +```console + +> pip install wtrobot + +``` + +> NOTE + +- Selenium_drivers folders have your selenium webdrivers geckodrivers(for firefox) and chromedrivers(for chrome and chromium) + +- If script fails due to drivers issue, you need to find appropriate selenium webdriver according to your browser version + + - [firefox](https://github.com/mozilla/geckodriver/releases) & [chrome/chromium](https://chromedriver.chromium.org/downloads) + +- Unzip or untar the executable and place in selenium_drivers dir. + +## Executing Script + +- Write all your test cases into test.yaml and execute + +```console + +> wtrobot + +``` + +> NOTE + +- If config(in `config.json`) is missing on initial run, tool will ask you for few configuration question and create `config.json` file. +- Make sure files which you mention as config(in `config.json`) should exist else will exit with error. + +## Syntax of test.yaml file + +- Write your WTRobot test cases in `test.yaml` files + +``` + +sequence: + +- testcase 1 + +- testcase 2 ... + +test: + +- testcase 1: + +- scenario: + +- step 1: + +name: + +action: goto | click | input | hover | scroll ... + +target: text | xpath | css path + +value: + +- step 2: + +... + +- testcase 2: + +... + +``` + +[sample example](examples/test.yaml) + +[detailed syntax](examples/syntax_docs.rst) + +- Scenario and name are just detailed text description about your test case scenario and steps, they are useful for detailed logging + +- There are only four important section to be considered while writing this script file + + - `action`: what to perform (e.g. click, input and etc) + + - `target`: on what to perform (e.g. Text widget on web page, xpath of widget and etc) + + - `value`: with what data (e.g. if an input field then what value to input) + + - `assert`: after performing some action, what you want to validate. + + - It can be text, element, url diff --git a/dashboard/UI-Test/config.json b/dashboard/UI-Test/config.json new file mode 100644 index 0000000000..4ae5a56ace --- /dev/null +++ b/dashboard/UI-Test/config.json @@ -0,0 +1,8 @@ +{ + "script_filepath": "test.yaml", + "browser": "firefox", + "webdriver_path": "selenium_drivers/geckodriver", + "locale": "en_US", + "log": "wtlog.log", + "dev": false +} \ No newline at end of file diff --git a/dashboard/UI-Test/requirements.txt b/dashboard/UI-Test/requirements.txt new file mode 100644 index 0000000000..7bebac39bb --- /dev/null +++ b/dashboard/UI-Test/requirements.txt @@ -0,0 +1 @@ +wtrobot \ No newline at end of file diff --git a/dashboard/UI-Test/selenium_drivers/README.md b/dashboard/UI-Test/selenium_drivers/README.md new file mode 100644 index 0000000000..d67eb9699d --- /dev/null +++ b/dashboard/UI-Test/selenium_drivers/README.md @@ -0,0 +1,9 @@ +Driver version currently shipped: +- Chrome/Chromium = v105.0.5195.19 +- Firefox(gecko) = v0.31.0 + +> NOTE: +- Selenium_drivers folders have your selenium webdrivers geckodrivers(for firefox) and chromedrivers(for chrome and chromium) +- If script fails due to drivers issue, you need to find appropriate selenium webdriver according to your browser version(choose latest if your browser is upto to date) + - [firefox](https://github.com/mozilla/geckodriver/releases) & [chrome/chromium](https://chromedriver.chromium.org/downloads) +- Unzip or untar the executable and place in selenium_drivers dir. \ No newline at end of file diff --git a/dashboard/UI-Test/selenium_drivers/chromedriver b/dashboard/UI-Test/selenium_drivers/chromedriver new file mode 100755 index 0000000000..5925b1ef7e Binary files /dev/null and b/dashboard/UI-Test/selenium_drivers/chromedriver differ diff --git a/dashboard/UI-Test/selenium_drivers/geckodriver b/dashboard/UI-Test/selenium_drivers/geckodriver new file mode 100755 index 0000000000..bac836bb55 Binary files /dev/null and b/dashboard/UI-Test/selenium_drivers/geckodriver differ diff --git a/dashboard/UI-Test/test.yaml b/dashboard/UI-Test/test.yaml new file mode 100644 index 0000000000..23ec989082 --- /dev/null +++ b/dashboard/UI-Test/test.yaml @@ -0,0 +1,65 @@ +sequence: +- testcase 1 +- testcase 2 +test: +- testcase 1: + - scenario: invalid pbench-dashboard login + - step 1: + action: goto + target: http://10.1.170.201 + targets: + - http://10.1.170.201 + - step 2: + action: click + target: Login + targets: + - Login + - step 3: + action: input + target: //*[@id="username"] + value: user + targets: + - //*[@id="username"] + - step 4: + action: input + target: //*[@id="password"] + value: password + targets: + - //*[@id="password"] + - step 5: + action: click + target: Login + wait after action: 3 + assert: text=Bad login + targets: + - Login +- testcase 2: + - scenario: Valid pbench-dashboard login + - step 1: + action: goto + target: http://10.1.170.201 + targets: + - http://10.1.170.201 + - step 2: + action: click + target: Login + targets: + - Login + - step 3: + action: input + target: //*[@id="username"] + value: vishalvvr + targets: + - //*[@id="username"] + - step 4: + action: input + target: //*[@id="password"] + value: Redhat@123 + targets: + - //*[@id="password"] + - step 5: + action: click + target: Login + targets: + - Login + assert: text=Logged in successfully!