diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5a93236 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.iso filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..9539a0f --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,35 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + ziemniak: pyrka + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: 3.10 + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..3bfabfc --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,36 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/Automatyzacja/Utilities/BaseClass.py b/Automatyzacja/Utilities/BaseClass.py new file mode 100644 index 0000000..3fae572 --- /dev/null +++ b/Automatyzacja/Utilities/BaseClass.py @@ -0,0 +1,26 @@ +import pytest +import logging +import inspect +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +@pytest.mark.usefixtures("setupBrowser") + +class BaseClass: + + def verifyLinkPresence(self,text): + element = WebDriverWait(self.driver, 10).until( + EC.presence_of_element_located((By.link,text))) + + def getLogger(self): + loggerName = inspect.stack()[1][3] + logger = logging.getLogger(loggerName) + fileHandler = logging.FileHandler('logfile.log') + formatter = logging.Formatter("[%(levelname)s] - %(asctime)s - %(name)s : %(message)s") + fileHandler.setFormatter(formatter) + + logger.addHandler(fileHandler) # filehandler object + + logger.setLevel(logging.DEBUG) + return logger \ No newline at end of file diff --git a/Automatyzacja/Utilities/__pycache__/BaseClass.cpython-39.pyc b/Automatyzacja/Utilities/__pycache__/BaseClass.cpython-39.pyc new file mode 100644 index 0000000..2a196e5 Binary files /dev/null and b/Automatyzacja/Utilities/__pycache__/BaseClass.cpython-39.pyc differ diff --git a/Automatyzacja/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..20f0749 Binary files /dev/null and b/Automatyzacja/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/__pycache__/singleDiskBackup.cpython-39.pyc b/Automatyzacja/__pycache__/singleDiskBackup.cpython-39.pyc new file mode 100644 index 0000000..b7d9ae3 Binary files /dev/null and b/Automatyzacja/__pycache__/singleDiskBackup.cpython-39.pyc differ diff --git a/Automatyzacja/__pycache__/test_Main.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/test_Main.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..4680de0 Binary files /dev/null and b/Automatyzacja/__pycache__/test_Main.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/__pycache__/test_hdd.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/test_hdd.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..11ad2ee Binary files /dev/null and b/Automatyzacja/__pycache__/test_hdd.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/__pycache__/test_logIn.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/test_logIn.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..d0f5c39 Binary files /dev/null and b/Automatyzacja/__pycache__/test_logIn.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/__pycache__/test_logIn.cpython-39.pyc b/Automatyzacja/__pycache__/test_logIn.cpython-39.pyc new file mode 100644 index 0000000..de236c3 Binary files /dev/null and b/Automatyzacja/__pycache__/test_logIn.cpython-39.pyc differ diff --git a/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..837394f Binary files /dev/null and b/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39.pyc b/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39.pyc new file mode 100644 index 0000000..cf761e0 Binary files /dev/null and b/Automatyzacja/__pycache__/test_singleDiskBackup.cpython-39.pyc differ diff --git a/Automatyzacja/__pycache__/test_storages.cpython-39-pytest-7.1.2.pyc b/Automatyzacja/__pycache__/test_storages.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..4887ecf Binary files /dev/null and b/Automatyzacja/__pycache__/test_storages.cpython-39-pytest-7.1.2.pyc differ diff --git a/Automatyzacja/conftest.py b/Automatyzacja/conftest.py new file mode 100644 index 0000000..3f14923 --- /dev/null +++ b/Automatyzacja/conftest.py @@ -0,0 +1,32 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +#endregion + +def pytest_addoption(parser): + parser.addoption( + "--browser_name", action="store", default="chrome", help="help text here" + ) + +@pytest.fixture(scope="class") +def setupBrowser(request): + browser_name = request.config.getoption("browser_name") + if browser_name == "chrome": + driver = webdriver.Chrome(executable_path="D:\\chromedriver.exe") + + elif browser_name == "firefox": + pass + #firefox invocation + + else: + pass + #IE invo + + driver.get("https://3be5838c-0e80-4f15-9003-3a1d5b749330.testing.xopero.com") + driver.maximize_window() + request.cls.driver = driver + yield + driver.close() \ No newline at end of file diff --git a/Automatyzacja/logfile.log b/Automatyzacja/logfile.log new file mode 100644 index 0000000..7c15dd3 --- /dev/null +++ b/Automatyzacja/logfile.log @@ -0,0 +1,160 @@ +[INFO] - 2022-06-30 15:07:13,419 - test_restoreBMR : BMR restore stared +[INFO] - 2022-06-30 15:07:16,117 - test_restoreBMR : Main device set to restore +[INFO] - 2022-06-30 15:09:00,837 - test_restoreBMR : BMR restore stared +[INFO] - 2022-06-30 15:09:03,851 - test_restoreBMR : Main device set to restore +[INFO] - 2022-06-30 15:14:12,644 - test_restoreBMR : BMR restore stared +[INFO] - 2022-06-30 15:14:15,620 - test_restoreBMR : Main device set to restore +[INFO] - 2022-06-30 15:14:54,556 - test_restoreBMR : BMR restore stared +[INFO] - 2022-06-30 15:14:57,644 - test_restoreBMR : Main device set to restore +[INFO] - 2022-06-30 15:14:58,235 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:14:59,964 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:15:53,406 - test_restoreBMR : BMR restore stared +[INFO] - 2022-06-30 15:15:56,107 - test_restoreBMR : Main device set to restore +[INFO] - 2022-06-30 15:16:44,623 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:16:47,285 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:16:47,285 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:22:42,074 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:22:44,718 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:22:44,718 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:22:45,169 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:22:48,447 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:24:21,793 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:24:24,611 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:24:24,611 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:24:25,021 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:24:27,643 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:25:39,030 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:25:41,895 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:25:41,895 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:25:42,293 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:25:45,352 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:35:12,335 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:35:15,427 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:35:15,428 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:35:15,820 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:35:17,683 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:36:27,421 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:36:30,165 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:36:30,165 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:36:30,549 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:36:33,443 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:38:11,733 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:38:14,657 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:38:14,657 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:38:15,323 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:38:17,714 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:38:48,269 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:38:50,980 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:38:50,980 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:38:51,447 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:38:53,512 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:38:59,207 - test_restoreBMR : Directory to restore set +[INFO] - 2022-06-30 15:40:31,640 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:40:34,658 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:40:34,658 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:40:35,214 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:40:37,831 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:40:43,588 - test_restoreBMR : Directory to restore set +[INFO] - 2022-06-30 15:41:21,980 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:41:25,210 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:41:25,210 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:41:25,614 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:41:27,311 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-06-30 15:41:33,063 - test_restoreBMR : Directory to restore set +[INFO] - 2022-06-30 15:42:01,413 - test_restoreBMR : BMR restore started +[INFO] - 2022-06-30 15:42:04,304 - test_restoreBMR : Main device set to restore +[ERROR] - 2022-06-30 15:42:04,304 - test_restoreBMR : Plan list not found +[INFO] - 2022-06-30 15:42:04,730 - test_restoreBMR : Restore Plan choosen +[INFO] - 2022-06-30 15:42:07,675 - test_restoreBMR : Restore type set as BMR +[INFO] - 2022-07-01 10:22:18,177 - test_login : User sucessfully logged +[INFO] - 2022-07-01 10:22:24,789 - test_Add_Device : There are no devices to activate +[INFO] - 2022-07-01 10:26:04,239 - test_login : User sucessfully logged +[INFO] - 2022-07-01 10:26:14,594 - test_Add_Device : There are no devices to activate +[INFO] - 2022-07-01 10:26:28,144 - test_addPlan : Plan name set as 'Backup HDD' +[INFO] - 2022-07-01 10:26:28,737 - test_addPlan : Main device choosen +[ERROR] - 2022-07-01 10:26:34,217 - test_addPlan : Creating plan Failed +[INFO] - 2022-07-01 10:27:26,395 - test_login : User sucessfully logged +[INFO] - 2022-07-01 10:27:32,627 - test_Add_Device : There are no devices to activate +[INFO] - 2022-07-01 10:27:46,490 - test_addPlan : Plan name set as 'Backup HDD' +[INFO] - 2022-07-01 10:27:47,155 - test_addPlan : Main device choosen +[INFO] - 2022-07-01 10:27:48,103 - test_addPlan : Disk 'G:' set for backup +[INFO] - 2022-07-01 10:27:50,425 - test_addPlan : Storage for HDD backup set as Xopero Storage +[INFO] - 2022-07-01 10:27:51,056 - test_addPlan : Schedule set for 11:11 +[INFO] - 2022-07-01 10:27:52,118 - test_addPlan : Plan 'Backup HDD' started succesfully +[INFO] - 2022-07-01 10:27:57,655 - test_systemDisk : Plan name set as 'System Disk Backup' +[INFO] - 2022-07-01 10:27:58,255 - test_systemDisk : Main device choosen +[INFO] - 2022-07-01 10:27:59,279 - test_systemDisk : Disk 'C:' set for backup +[INFO] - 2022-07-01 10:27:59,690 - test_systemDisk : Storage for HDD backup set as Xopero Storage +[INFO] - 2022-07-01 10:28:00,273 - test_systemDisk : Schedule set for 11:11 +[INFO] - 2022-07-01 10:28:03,340 - test_systemDisk : Plan 'System Disk Backup' started succesfully +[INFO] - 2022-07-01 10:28:08,813 - test_Xopero_Disk_Variable : Plan name set as 'Xopero Var Backup' +[INFO] - 2022-07-01 10:28:09,325 - test_Xopero_Disk_Variable : Main device choosen +[INFO] - 2022-07-01 10:28:12,805 - test_Xopero_Disk_Variable : Storage for HDD backup set as Xopero Storage +[INFO] - 2022-07-01 10:28:13,321 - test_Xopero_Disk_Variable : Schedule set for 11:11 +[INFO] - 2022-07-01 10:28:16,390 - test_Xopero_Disk_Variable : Plan 'System Disk Backup' started succesfully +[INFO] - 2022-07-01 10:28:19,060 - test_prePlan : Predefined plan was successfuly added to device +[WARNING] - 2022-07-01 10:28:21,415 - test_prePlan : Plan 'System Disk Backup' already exist +[INFO] - 2022-07-01 10:28:21,736 - test_prePlan : Plan 'Endpoint&Server Total Protection' started as Full backup +[INFO] - 2022-07-01 10:28:33,138 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:35,952 - test_restore_file_image : Restore set as RAW +[INFO] - 2022-07-01 10:28:37,436 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:38,854 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:41,276 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:41,276 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:43,395 - test_restore_file_image : Restore set as VHD +[INFO] - 2022-07-01 10:28:43,395 - test_restore_file_image : Restore set as VHD +[INFO] - 2022-07-01 10:28:44,733 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:44,733 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:46,087 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:46,087 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:48,397 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:48,397 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:48,397 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:50,504 - test_restore_file_image : Restore set as VHDX +[INFO] - 2022-07-01 10:28:50,504 - test_restore_file_image : Restore set as VHDX +[INFO] - 2022-07-01 10:28:50,504 - test_restore_file_image : Restore set as VHDX +[INFO] - 2022-07-01 10:28:52,199 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:52,199 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:52,199 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:53,605 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:53,605 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:53,605 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:28:56,163 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:56,163 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:56,163 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:56,163 - test_restore_file_image : Restore Plan choosen +[INFO] - 2022-07-01 10:28:58,480 - test_restore_file_image : Restore set as VMDK +[INFO] - 2022-07-01 10:28:58,480 - test_restore_file_image : Restore set as VMDK +[INFO] - 2022-07-01 10:28:58,480 - test_restore_file_image : Restore set as VMDK +[INFO] - 2022-07-01 10:28:58,480 - test_restore_file_image : Restore set as VMDK +[INFO] - 2022-07-01 10:28:59,812 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:59,812 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:59,812 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:28:59,812 - test_restore_file_image : Folder already exist, starting restore +[INFO] - 2022-07-01 10:29:01,181 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:29:01,181 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:29:01,181 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:29:01,181 - test_restore_file_image : Restore started successfuly +[INFO] - 2022-07-01 10:29:01,208 - test_restoreBMR : BMR restore started +[INFO] - 2022-07-01 10:29:17,956 - test_add_SMB_Storage : Name for SMB storage set as 'SMB' +[INFO] - 2022-07-01 10:29:18,367 - test_add_SMB_Storage : Creating password for SMB +[INFO] - 2022-07-01 10:29:23,141 - test_add_SMB_Storage : Password for SMB storage set +[CRITICAL] - 2022-07-01 10:29:31,322 - test_add_SMB_Storage : SMB storage creation failed +[INFO] - 2022-07-01 10:29:35,639 - test_add_NFS_Storage : Name for NFS storage set as 'NFS' +[INFO] - 2022-07-01 10:29:39,058 - test_add_NFS_Storage : NFS storage created +[INFO] - 2022-07-01 10:29:43,380 - test_add_S3_Storage : Name for S3 storage set as 'Minio S3' +[INFO] - 2022-07-01 10:29:43,725 - test_add_S3_Storage : Creating password for MinioS3 +[INFO] - 2022-07-01 10:29:48,371 - test_add_S3_Storage : Password for MinioS3 storage set +[INFO] - 2022-07-01 10:29:51,763 - test_add_S3_Storage : S3 storage created +[INFO] - 2022-07-01 10:30:00,989 - test_xoperoStorage : Xopero storage is avaiable +[INFO] - 2022-07-01 13:49:18,293 - test_add_SMB_Storage : Name for SMB storage set as 'SMB' +[INFO] - 2022-07-01 13:49:18,696 - test_add_SMB_Storage : Creating password for SMB +[INFO] - 2022-07-01 13:49:23,392 - test_add_SMB_Storage : Password for SMB storage set +[CRITICAL] - 2022-07-01 13:49:31,967 - test_add_SMB_Storage : SMB storage creation failed +[INFO] - 2022-07-01 13:49:36,432 - test_add_NFS_Storage : Name for NFS storage set as 'NFS' +[INFO] - 2022-07-01 13:49:40,282 - test_add_NFS_Storage : NFS storage created +[INFO] - 2022-07-01 13:49:44,670 - test_add_S3_Storage : Name for S3 storage set as 'Minio S3' +[INFO] - 2022-07-01 13:49:45,101 - test_add_S3_Storage : Creating password for MinioS3 +[INFO] - 2022-07-01 13:49:49,824 - test_add_S3_Storage : Password for MinioS3 storage set +[INFO] - 2022-07-01 13:49:53,755 - test_add_S3_Storage : S3 storage created +[INFO] - 2022-07-01 13:50:02,992 - test_xoperoStorage : Xopero storage is avaiable diff --git a/Automatyzacja/pageObjects/__pycache__/devicesPage.cpython-39.pyc b/Automatyzacja/pageObjects/__pycache__/devicesPage.cpython-39.pyc new file mode 100644 index 0000000..e68758b Binary files /dev/null and b/Automatyzacja/pageObjects/__pycache__/devicesPage.cpython-39.pyc differ diff --git a/Automatyzacja/pageObjects/__pycache__/loginPage.cpython-39.pyc b/Automatyzacja/pageObjects/__pycache__/loginPage.cpython-39.pyc new file mode 100644 index 0000000..18c1367 Binary files /dev/null and b/Automatyzacja/pageObjects/__pycache__/loginPage.cpython-39.pyc differ diff --git a/Automatyzacja/pageObjects/__pycache__/planPage.cpython-39.pyc b/Automatyzacja/pageObjects/__pycache__/planPage.cpython-39.pyc new file mode 100644 index 0000000..4fd1307 Binary files /dev/null and b/Automatyzacja/pageObjects/__pycache__/planPage.cpython-39.pyc differ diff --git a/Automatyzacja/pageObjects/__pycache__/storagePage.cpython-39.pyc b/Automatyzacja/pageObjects/__pycache__/storagePage.cpython-39.pyc new file mode 100644 index 0000000..e1299a2 Binary files /dev/null and b/Automatyzacja/pageObjects/__pycache__/storagePage.cpython-39.pyc differ diff --git a/Automatyzacja/pageObjects/devicesPage.py b/Automatyzacja/pageObjects/devicesPage.py new file mode 100644 index 0000000..587802f --- /dev/null +++ b/Automatyzacja/pageObjects/devicesPage.py @@ -0,0 +1,64 @@ +from selenium.webdriver.common.by import By + +class DevicePage: + + device = (By.XPATH,"/html/body/app-root/app-main/app-menu/section/nav[1]/a[1]") + assingPlan = (By.XPATH,"//*[contains(text(),'Assign plan')]") + mainRestore = (By.XPATH,"//*[contains(text(),'Main')]/../../footer/button[1]") + availablePlans = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-resource-backups/div/div[3]/ng-select") + restoreLast = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-resource-backups/div/div[3]/div/app-browser-container/app-browser/div/div/app-browser-backups/div/div/div[2]/div/button") + restore_as_iscis = (By.XPATH,"//*[contains(text(),'iSCSI target')]") + restoreAll = (By.XPATH,"//*[contains(text(),'Restore all')]") + fileImage = (By.XPATH,"//*[contains(text(),'file image')]") + restoreSelected = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-data-to-restore/div/div[4]/button") + fistDisk = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-data-to-restore/div/div[3]/div/app-hdd/div/div/div/div[1]/div/mat-checkbox") + selectDirectory = (By.XPATH,"//*[contains(text(),'Select directory')]") + startNow = (By.XPATH,"//*[contains(text(),'Start now')]") + imageFormat = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-new-restore/div/app-restore-hdd-container/app-restore-hdd/div/div[1]/app-disk-image-options/div/div[2]/ng-select/div") + BMR = (By.XPATH,"//*[contains(text(),'BMR')]") + + + def __init__(self,driver): + self.driver = driver + + def devicePage(self): + self.driver.find_element(*DevicePage.device).click() + + def AssignPlan(self): + self.driver.find_element(*DevicePage.assingPlan).click() + + def mainDeviceRestore(self): + self.driver.find_element(*DevicePage.mainRestore).click() + + def PlanList(self): + self.driver.find_element(*DevicePage.availablePlans).click() + + def RestoreLast(self): + self.driver.find_element(*DevicePage.restoreLast).click() + + def as_ISCSI(self): + self.driver.find_element(*DevicePage.restore_as_iscis).click() + + def RestoreAll(self): + self.driver.find_element(*DevicePage.restoreAll).click() + + def FileImage(self): + self.driver.find_element(*DevicePage.fileImage).click() + + def RestoreSelected(self): + self.driver.find_element(*DevicePage.restoreSelected).click() + + def FirstDisk(self): + self.driver.find_element(*DevicePage.fistDisk).click() + + def SelectDirectory(self): + self.driver.find_element(*DevicePage.selectDirectory).click() + + def StartNow(self): + self.driver.find_element(*DevicePage.startNow).click() + + def ImageFormat(self): + self.driver.find_element(*DevicePage.imageFormat).click() + + def BareMetalRestore(self): + self.driver.find_element(*DevicePage.BMR).click() \ No newline at end of file diff --git a/Automatyzacja/pageObjects/loginPage.py b/Automatyzacja/pageObjects/loginPage.py new file mode 100644 index 0000000..36e987a --- /dev/null +++ b/Automatyzacja/pageObjects/loginPage.py @@ -0,0 +1,18 @@ +from selenium.webdriver.common.by import By +import time + +class LogInPage: + + login = (By.NAME, "login") + password = (By.ID,'mat-input-1') + submitButton = (By.XPATH,"//button[@type='submit']") + + def __init__(self,driver): + self.driver = driver + + def logIn(self): + time.sleep(1) + self.driver.find_element(*LogInPage.login).send_keys('login') + self.driver.find_element(*LogInPage.password).send_keys("password") + self.driver.find_element(*LogInPage.submitButton).click() + return diff --git a/Automatyzacja/pageObjects/planPage.py b/Automatyzacja/pageObjects/planPage.py new file mode 100644 index 0000000..0431301 --- /dev/null +++ b/Automatyzacja/pageObjects/planPage.py @@ -0,0 +1,112 @@ +from selenium.webdriver.common.by import By + + +class PlanPage: + + plans = (By.XPATH,"//*[contains(text(),'Plans')]") + addPlan = (By.XPATH,"//*[contains(text(),'Add plan')]") + planName = (By.NAME,"backupPlanName") + runPlan = (By.CSS_SELECTOR,"button[aria-label='button']") + runFull = (By.XPATH,"//div[@class='cdk-overlay-pane']/div/div/button[2]") + runIncremental = (By.XPATH,"//div[@class='cdk-overlay-pane']/div/div/button[3]") + closePlanDashboard = (By.CSS_SELECTOR,"button[aria-label='Close']") + howToProtect = (By.XPATH,"//*[contains(text(),'How to protect')]") + fileLevel = (By.XPATH,"//*[contains(text(),'File-level')]") + imageLevel = (By.XPATH,"//*[contains(text(),'Image-level')]") + whichDevices = (By.XPATH,"//*[contains(text(),'Which devices?')]") + mainDeviceCheckbox = (By.CLASS_NAME, "mat-checkbox") + applyButton = (By.XPATH,"//*[contains(text(),'Apply')]") + whatToProtect = (By.XPATH,"//*[contains(text(),'What to protect?')]") + deviceName = (By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-rule/div/div[3]/div[2]/div[2]/div/h3') + diskCheckbox = (By.CSS_SELECTOR,"label[class='mat-checkbox-layout']") + saveChoice = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-add-device-rule/div/div[3]/button/span[1]") + whereToStore = (By.XPATH,"//*[contains(text(),'Where to store?')]") + xoperoStorage = (By.XPATH,"//*[contains(text(),'Xopero Storage')]") + when = (By.XPATH,"//*[contains(text(),'When?')]") + startAt = (By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + saveRun = (By.XPATH,"//*[contains(text(),'Save&Run')]") + next = (By.XPATH,"//*[contains(text(),'Next')]") + saveSchedule = (By.XPATH,"//button[@type='submit']") + + + def __init__(self,driver): + self.driver = driver + + def planPage(self): + return self.driver.find_element(*PlanPage.plans).click() + + def AddPlan(self): + return self.driver.find_element(*PlanPage.addPlan).click() + + def PlanName(self): + return self.driver.find_element(*PlanPage.planName) + + def RunPlan(self,planRow): + return planRow.find_element(*PlanPage.runPlan).click() + + def RunFull(self,planRow): + return planRow.find_element(*PlanPage.runFull).click() + + def RunIncremental(self,planRow): + return planRow.find_element(*PlanPage.runIncremental).click() + + def ClosePlanDashboard(self): + return self.driver.find_element(*PlanPage.closePlanDashboard).click() + + def HowToProtect(self): + return self.driver.find_element(*PlanPage.howToProtect).click() + + def FileLevel(self): + return self.driver.find_element(*PlanPage.fileLevel).click() + + def ImageLevel(self): + return self.driver.find_element(*PlanPage.imageLevel).click() + + def WhichDevices(self): + return self.driver.find_element(*PlanPage.whichDevices).click() + + def MainDeviceCheckbox(self,main): + return main.find_element(*PlanPage.mainDeviceCheckbox).click() + + def ApplyButton(self): + return self.driver.find_element(*PlanPage.applyButton).click() + + def WhatToProtect(self): + return self.driver.find_element(*PlanPage.whatToProtect).click() + + def DeviceName(self): + return self.driver.find_element(*PlanPage.deviceName).click() + + def DiskCheckBox(self,diskletter): + return diskletter.find_element(*PlanPage.diskCheckbox).click() + + def SaveChoice(self): + return self.driver.find_element(*PlanPage.saveChoice).click() + + def WhereToStore(self): + return self.driver.find_element(*PlanPage.whereToStore).click() + + def XoperoStorage(self): + return self.driver.find_element(*PlanPage.xoperoStorage).click() + + def When(self): + return self.driver.find_element(*PlanPage.when).click() + + def StartAt(self): + return self.driver.find_element(*PlanPage.startAt) + + def SaveRun(self): + return self.driver.find_element(*PlanPage.saveRun).click() + + def Next(self): + return self.driver.find_element(*PlanPage.next).click() + + def SaveSchedule(self): + return self.driver.find_element(*PlanPage.saveSchedule).click() + + + + + + + diff --git a/Automatyzacja/pageObjects/storagePage.py b/Automatyzacja/pageObjects/storagePage.py new file mode 100644 index 0000000..6587ff8 --- /dev/null +++ b/Automatyzacja/pageObjects/storagePage.py @@ -0,0 +1,102 @@ +from selenium.webdriver.common.by import By + + +class StoragePage: + + storagesPage = (By.XPATH,'/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]') + addStorage = (By.XPATH,'/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[1]/ng-component/button/span[1]') + storageName = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field/div/div[1]/div[2]/input") + localPath = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-local/mat-form-field/div/div[1]/div/input") + save = (By.XPATH,"//*[contains(text(),'Save')]") + storageType = (By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/ng-select/div') + networkLocation = (By.XPATH,"//*[contains(text(),'Network location')]") + SMBuserName = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-smb/app-controlled-input/mat-form-field/div/div[1]/div[1]/input") + selectPassword = (By.XPATH,"//*[contains(text(),'Select or add')]") + addPassword = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-list-container/app-passwords-list/div/div[3]/button") + passwordName = (By.NAME,"passwordName") + passwords = (By.CSS_SELECTOR,"input[type='password']") + smbPath = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-smb/mat-form-field/div/div[1]/div/input") + nfsShare = (By.XPATH,"//*[contains(text(),'Network File Storage')]") + nfsPath = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-nfs/app-controlled-input/mat-form-field/div/div[1]/div[1]/input") + s3 = (By.XPATH,"//*[contains(text(),'S3 storage')]") + s3Login = (By.XPATH,"//span[text()='Access key ID']/../../../input") + s3serviceUrl = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-amazon/app-controlled-input[2]/mat-form-field/div/div[1]/div[1]/input") + s3BucketName = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-amazon/app-controlled-input[3]/mat-form-field/div/div[1]/div[1]/input") + Backblaze = (By.XPATH,"//*[contains(text(),'Backblaze B2')]") + BackblazeBucket = (By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-backblaze/app-controlled-input[2]/mat-form-field/div/div[1]/div[1]/input") + + def __init__(self,driver): + self.driver = driver + + def storagePage(self): + return self.driver.find_element(*StoragePage.storagesPage).click() + + def AddStorage(self): + return self.driver.find_element(*StoragePage.addStorage).click() + + def StorageName(self): + return self.driver.find_element(*StoragePage.storageName) + + def LocalPath(self): + return self.driver.find_element(*StoragePage.localPath) + + def Save(self): + return self.driver.find_element(*StoragePage.save).click() + + def StorageTypeSelect(self): + return self.driver.find_element(*StoragePage.storageType).click() + + def Type_SMB(self): + return self.driver.find_element(*StoragePage.networkLocation).click() + + def SMBusername(self): + return self.driver.find_element(*StoragePage.SMBuserName) + + def SelectPassword(self): + return self.driver.find_element(*StoragePage.selectPassword).click() + + def AddNewPassword(self): + return self.driver.find_element(*StoragePage.addPassword).click() + + def PasswordName(self): + return self.driver.find_element(*StoragePage.passwordName) + + def Passwords(self): + return self.driver.find_elements(*StoragePage.passwords) + + def SMBpath(self): + return self.driver.find_element(*StoragePage.smbPath) + + def Type_NFS(self): + return self.driver.find_element(*StoragePage.nfsShare).click() + + def NFSpath(self): + return self.driver.find_element(*StoragePage.nfsPath) + + def S3(self): + return self.driver.find_element(*StoragePage.s3).click() + + def LoginS3(self): + return self.driver.find_element(*StoragePage.s3Login) + + def S3Url(self): + return self.driver.find_element(*StoragePage.s3serviceUrl) + + def S3Bucket(self): + return self.driver.find_element(*StoragePage.s3BucketName) + + def BackBlaze(self): + return self.driver.find_element(*StoragePage.Backblaze).click() + + def BackBlazeBucket(self): + return self.driver.find_element(*StoragePage.BackblazeBucket) + + + + + + + + + + \ No newline at end of file diff --git a/Automatyzacja/test.py b/Automatyzacja/test.py new file mode 100644 index 0000000..a5a5698 --- /dev/null +++ b/Automatyzacja/test.py @@ -0,0 +1,3 @@ +import os +f = os.popen('ifconfig eth0 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1') +your_ip=f.read() \ No newline at end of file diff --git a/Automatyzacja/test_Main.py b/Automatyzacja/test_Main.py new file mode 100644 index 0000000..4fef23f --- /dev/null +++ b/Automatyzacja/test_Main.py @@ -0,0 +1,33 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from Utilities.BaseClass import BaseClass +from pageObjects.loginPage import LogInPage +from pageObjects.planPage import PlanPage +from pageObjects.storagePage import StoragePage +import time +#endregion + +class Test_Login(BaseClass): + + def test_login(self): + log = self.getLogger() + time.sleep(5) + logInPage = LogInPage(self.driver) + logInPage.logIn() + time.sleep(2) + try: + #assert self.driver.current_url == "http://localhost:28555/devices" + log.info("User sucessfully logged") + except: + log.critical("LogIn Failed") + raise + + + + + + diff --git a/Automatyzacja/test_hdd.py b/Automatyzacja/test_hdd.py new file mode 100644 index 0000000..49745ef --- /dev/null +++ b/Automatyzacja/test_hdd.py @@ -0,0 +1,405 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from Utilities.BaseClass import BaseClass +from pageObjects.loginPage import LogInPage +from pageObjects.planPage import PlanPage +from pageObjects.storagePage import StoragePage +from pageObjects.devicesPage import DevicePage +import time +import socket +from selenium.webdriver.support.relative_locator import locate_with +from selenium.common.exceptions import NoSuchElementException +from selenium.common.exceptions import StaleElementReferenceException +#endregion + +class Test_HDD(BaseClass): + + def test_addPlan(self): + + log = self.getLogger() + self.driver.implicitly_wait(5) + + logInPage = LogInPage(self.driver) + logInPage.logIn() + time.sleep(2) + #assert self.driver.current_url == "http://localhost:28555/devices" + + planPage = PlanPage(self.driver) + planPage.planPage() + time.sleep(2) + #assert self.driver.current_url == "http://localhost:28555/plans/backup" + + try: + + if self.driver.find_element(By.XPATH,"//*[text()='Backup HDD']").is_displayed(): + log.warning("Plan 'Backup HDD' already exist") + planRow = self.driver.find_element(By.XPATH,"//*[text()='Backup HDD']/../..") + planPage.RunPlan(planRow) + planPage.RunIncremental(planRow) + log.info("Plan 'Backup HDD' started as incremental backup") + planPage.ClosePlanDashboard() + + else: + pass + + except: + + planPage.AddPlan() + planPage.PlanName().clear() + planPage.PlanName().send_keys("Backup HDD") + log.info("Plan name set as 'Backup HDD' ") + planPage.HowToProtect() + planPage.ImageLevel() + planPage.WhichDevices() + main = self.driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + planPage.MainDeviceCheckbox(main) + log.info("Main device choosen") + planPage.ApplyButton() + planPage.WhatToProtect() + planPage.DeviceName() + + try: + + diskLetter = self.driver.find_element(By.XPATH,"//*[contains(text(),'(G:)')]/../../../..") + planPage.DiskCheckBox(diskLetter) + log.info("Disk 'G:' set for backup") + planPage.SaveChoice() + planPage.ApplyButton() + planPage.WhereToStore() + time.sleep(1) + planPage.XoperoStorage() + time.sleep(1) + log.info("Storage for HDD backup set as Xopero Storage") + planPage.When() + planPage.StartAt().send_keys('1111') + planPage.Next() + planPage.SaveSchedule() + log.info("Schedule set for 11:11") + time.sleep(1) + planPage.SaveRun() + log.info("Plan 'Backup HDD' started succesfully") + + except: + + log.error("Creating plan Failed") + raise + + def test_systemDisk(self): + log = self.getLogger() + self.driver.implicitly_wait(5) + planPage = PlanPage(self.driver) + #planPage.planPage() + + try: + + if self.driver.find_element(By.XPATH,"//*[text()='System Disk Backup']").is_displayed(): + log.warning("Plan 'System Disk Backup' already exist") + planRow = self.driver.find_element(By.XPATH,"//*[text()='System Disk Backup']/../..") + planPage.RunPlan(planRow) + planPage.RunIncremental(planRow) + log.info("Plan 'System Disk Backup' started as incremental backup") + planPage.ClosePlanDashboard() + + else: + pass + + except: + + planPage.AddPlan() + planPage.PlanName().clear() + planPage.PlanName().send_keys("System Disk Backup") + log.info("Plan name set as 'System Disk Backup' ") + planPage.HowToProtect() + planPage.ImageLevel() + planPage.WhichDevices() + main = self.driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + planPage.MainDeviceCheckbox(main) + log.info("Main device choosen") + planPage.ApplyButton() + planPage.WhatToProtect() + planPage.DeviceName() + + try: + + diskLetter = self.driver.find_element(By.XPATH,"//*[contains(text(),'(C:)')]/../../../..") + planPage.DiskCheckBox(diskLetter) + log.info("Disk 'C:' set for backup") + planPage.SaveChoice() + planPage.ApplyButton() + planPage.WhereToStore() + planPage.XoperoStorage() + log.info("Storage for HDD backup set as Xopero Storage") + planPage.When() + planPage.StartAt().send_keys('1111') + planPage.Next() + planPage.SaveSchedule() + log.info("Schedule set for 11:11") + time.sleep(2) + planPage.SaveRun() + time.sleep(1) + log.info("Plan 'System Disk Backup' started succesfully") + + except: + + log.error("Creating plan Failed") + raise + + def test_Xopero_Disk_Variable(self): + + log = self.getLogger() + self.driver.implicitly_wait(5) + planPage = PlanPage(self.driver) + #planPage.planPage() + + + try: + + if self.driver.find_element(By.XPATH,"//*[text()='Xopero Var Backup']").is_displayed(): + log.warning("Plan 'System Disk Backup' already exist") + planRow = self.driver.find_element(By.XPATH,"//*[text()='System Disk Backup']/../..") + planPage.RunPlan(planRow) + planPage.RunIncremental(planRow) + log.info("Plan 'Xopero Var Backup' started as incremental backup") + planPage.ClosePlanDashboard() + + else: + pass + except: + + planPage.AddPlan() + planPage.PlanName().clear() + planPage.PlanName().send_keys("Xopero Var Backup") + log.info("Plan name set as 'Xopero Var Backup' ") + planPage.HowToProtect() + planPage.ImageLevel() + planPage.WhichDevices() + main = self.driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + planPage.MainDeviceCheckbox(main) + log.info("Main device choosen") + planPage.ApplyButton() + planPage.WhatToProtect() + planPage.DeviceName() + + try: + self.driver.find_element(By.CSS_SELECTOR,"div[class='item__content']").click() + self.driver.find_element(By.XPATH,"//*[contains(text(),'Set global rules')]").click() + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-rule/div/div[3]/div/div[2]/app-rule/div/app-paths/div/form/ng-select").click() + self.driver.find_element(By.XPATH, "//*[contains(text(),'SYSTEM_DISK')]").click() + planPage.ApplyButton() + planPage.WhereToStore() + time.sleep(1) + planPage.XoperoStorage() + time.sleep(1) + log.info("Storage for HDD backup set as Xopero Storage") + planPage.When() + planPage.StartAt().send_keys('1111') + planPage.Next() + planPage.SaveSchedule() + log.info("Schedule set for 11:11") + time.sleep(2) + planPage.SaveRun() + time.sleep(1) + + log.info("Plan 'System Disk Backup' started succesfully") + + except: + + log.error("Creating plan Failed") + raise + + def test_prePlan(self): + + log = self.getLogger() + self.driver.implicitly_wait(5) + devicePage = DevicePage(self.driver) + devicePage.devicePage() + planPage = PlanPage(self.driver) + + time.sleep(1) + devicePage.AssignPlan() + self.driver.find_element(By.XPATH,'//*[contains(text(),"Endpoint&Server Total Protection")]').click() + + time.sleep(1) + #assert self.driver.find_element(By.XPATH,"//*[text()='Endpoint&Server Total Protection']").is_displayed() + log.info("Predefined plan was successfuly added to device") + + planPage.planPage() + time.sleep(2) + try: + if self.driver.find_element(By.XPATH,"//*[text()='Endpoint&Server Total Protection']").is_displayed(): + log.warning("Plan 'System Disk Backup' already exist") + planRow = self.driver.find_element(By.XPATH,"//*[contains(text(),'Endpoint&Server Total Protection')]/../..") + planPage.RunPlan(planRow) + planPage.RunFull(planRow) + log.info("Plan 'Endpoint&Server Total Protection' started as Full backup") + planPage.ClosePlanDashboard() + except: + log.error("Error during runnin predefined plan") + raise + + def test_restoreISCSI(self): + log = self.getLogger() + self.driver.implicitly_wait(5) + + devicePage = DevicePage(self.driver) + devicePage.devicePage() + time.sleep(1) + devicePage.mainDeviceRestore() + time.sleep(1) + #devicePage.PlanList() + # + ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,) + planlist = WebDriverWait(self.driver, 10,ignored_exceptions=ignored_exceptions)\ + .until(EC.presence_of_element_located((devicePage.availablePlans)),log.error("Plan list not found")) + + try: + self.driver.find_element(By.XPATH,"//*[contains(text(),'Backup HDD')]").click() + try: + devicePage.RestoreLast() + devicePage.as_ISCSI() + devicePage.RestoreAll() + + hostname = socket.gethostname() + #ip = socket.gethostbyname(hostname) + ip = '192.168.4.237' + + ethernet = self.driver.find_element(By.XPATH,"//h4[contains(text(),'Ethernet')]/..") + ipPanel = ethernet.find_element(By.CSS_SELECTOR,"p[class='ng-star-inserted']").text + assert ipPanel in ip + + self.driver.find_element(By.XPATH,"//*[contains(text(),'Run iSCSI')]").click() + log.info("Uruchomiono restore poprzez iSCSI") + + except: + log.error("Error during starting restore plan") + raise + except: + log.error("Did not find indicated plan to restore") + raise + + def test_restore_file_image(self,getData): + + log = self.getLogger() + self.driver.implicitly_wait(5) + + self.driver.refresh() + devicePage = DevicePage(self.driver) + devicePage.devicePage() + + devicePage.mainDeviceRestore() + #devicePage.PlanList() + # + ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,) + planlist = WebDriverWait(self.driver, 10,ignored_exceptions=ignored_exceptions)\ + .until(EC.presence_of_element_located((devicePage.availablePlans)),log.error("Plan list not found")) + + planlist.click() + # + try: + self.driver.find_element(By.XPATH,"//*[contains(text(),'Backup HDD')]").click() + log.info("Restore Plan choosen") + try: + devicePage.RestoreLast() + devicePage.FileImage() + devicePage.FirstDisk() + devicePage.RestoreSelected() + + devicePage.ImageFormat() + formats = self.driver.find_elements(By.CSS_SELECTOR,"div[role='option']") + for format in formats: + if format.text == getData["type"]: + log.info("Restore set as %s" %(getData["type"])) + format.click() + break + + devicePage.SelectDirectory() + + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]/div/app-icon").click() + folderTree = self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]") + mainTree = self.driver.find_elements(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]/ul/li") + + #iteration through folders + avoidin stale element reference + for i in range(1,len(mainTree)): + ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,) + element = WebDriverWait(self.driver, 5,ignored_exceptions=ignored_exceptions)\ + .until(EC.presence_of_element_located((By.XPATH, "/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]/ul/li[%i]"%(i)))) + if element.text == 'Backup HDD': + log.info("Folder already exist, starting restore") + element.find_element(By.TAG_NAME,'mat-checkbox').click() + self.driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + time.sleep(1) + devicePage.StartNow() + log.info("Restore started successfuly") + return + else: + pass + + + time.sleep(1) + log.info("Restore folder not found, creating new one") + x = self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]/div") + x.find_element(By.CSS_SELECTOR,"svg[data-icon='folder-plus']").click() + folderTree.find_element(By.CSS_SELECTOR,"input[data-placeholder='New catalog name']").send_keys('Backup HDD') + folderTree.find_element(By.CSS_SELECTOR,"button[title='Add catalog']").click() + log.info("Restore folder created") + time.sleep(1) + self.driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + time.sleep(1) + self.driver.find_element(By.XPATH,"//*[contains(text(),'Start now')]").click() + log.info("Restore started sucessfuly") + + except: + log.error('Error during lunching restore') + raise + except: + log.warning('Intended plan not found') + raise + + + @pytest.fixture(params= [{'type':'RAW','plan':'Backup HDD'},{'type':'VHD','plan':'Backup HDD'},{'type':'VHDX','plan':'Backup HDD'},{'type':'VMDK','plan':'Backup HDD'}]) + def getData(self, request): + return request.param + + def test_restoreBMR(self): + log = self.getLogger() + self.driver.implicitly_wait(5) + + logInPage = LogInPage(self.driver) + devicePage = DevicePage(self.driver) + planPage = PlanPage(self.driver) + log.info('BMR restore started') + logInPage.logIn() + time.sleep(1) + devicePage.devicePage() + + devicePage.mainDeviceRestore() + log.info("Main device set to restore") + ignored_exceptions=(NoSuchElementException,StaleElementReferenceException,) + planlist = WebDriverWait(self.driver, 10,ignored_exceptions=ignored_exceptions)\ + .until(EC.presence_of_element_located((devicePage.availablePlans)),log.error("Plan list not found")) + planlist.click() + + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'Backup HDD')]").is_displayed() + self.driver.find_element(By.XPATH,"//*[contains(text(),'Backup HDD')]").click() + log.info("Restore Plan choosen") + devicePage.RestoreLast() + devicePage.BareMetalRestore() + log.info("Restore type set as BMR") + devicePage.FirstDisk() + devicePage.RestoreSelected() + devicePage.SelectDirectory() + BrowseDevices = self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]") + + diskLetter = BrowseDevices.find_element(By.XPATH,"//*[contains(text(),'(G:)')]/../../../..") + #time.sleep(1) + diskCheckbox = WebDriverWait(diskLetter,10)\ + .until(EC.element_to_be_clickable((By.CSS_SELECTOR,"label[class='mat-checkbox-layout']"))) + diskCheckbox.click() + #self.driver.execute_script("arguments[0].click();",diskLetter.find_element(By.CSS_SELECTOR,"label[class='mat-checkbox-layout']")) + time.sleep(5) + log.info("Directory to restore set") + \ No newline at end of file diff --git a/Automatyzacja/test_storages.py b/Automatyzacja/test_storages.py new file mode 100644 index 0000000..da2df7c --- /dev/null +++ b/Automatyzacja/test_storages.py @@ -0,0 +1,224 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from Utilities.BaseClass import BaseClass +from pageObjects.loginPage import LogInPage +from pageObjects.planPage import PlanPage +from pageObjects.storagePage import StoragePage +import time +#endregion + +class Test_Storages(BaseClass): + + def test_add_Local_Storage(self): + + self.driver.implicitly_wait(5) + log = self.getLogger() + logInPage = LogInPage(self.driver) + logInPage.logIn() + time.sleep(2) + assert self.driver.current_url == "https://3be5838c-0e80-4f15-9003-3a1d5b749330.testing.xopero.com/devices" + + storagePage = StoragePage(self.driver) + storagePage.storagePage() + storagePage.AddStorage() + storagePage.StorageName().clear() + storagePage.StorageName().send_keys('Lokal') + log.info("Name for local storage set as 'Lokal'") + storagePage.LocalPath().send_keys('D:\\storage beta') + storagePage.Save() + + self.driver.refresh() + time.sleep(2) + + try: + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'Lokal')]").is_displayed() + log.info("Local storage created") + except: + log.critical("Local storage creation failed") + raise + + def test_add_SMB_Storage(self): + + self.driver.implicitly_wait(5) + log = self.getLogger() + + time.sleep(2) + storagePage = StoragePage(self.driver) + storagePage.storagePage() + storagePage.AddStorage() + time.sleep(2) + + storagePage.StorageName().clear() + storagePage.StorageName().send_keys('SMB') + log.info("Name for SMB storage set as 'SMB'") + storagePage.StorageTypeSelect() + storagePage.Type_SMB() + storagePage.SMBusername().send_keys('admin') + storagePage.SelectPassword() + + log.info("Creating password for SMB") + storagePage.AddNewPassword() + storagePage.PasswordName().send_keys("Admin") + passwords = storagePage.Passwords() + for password in passwords: + password.send_keys("Admin_123") + time.sleep(2) + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-form-container/app-passwords-form/form/div[3]/app-save-button/button/span[1]/span").click() + time.sleep(2) + log.info("Password for SMB storage set") + + + storagePage.SMBpath().send_keys(r"\\192.168.0.198\Public\MStasiak") + + storagePage.Save() + self.driver.refresh() + time.sleep(2) + try: + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'Lokal')]").is_displayed() + log.info("SMB storage created") + except: + log.critical("SMB storage creation failed") + raise + + def test_add_NFS_Storage(self): + self.driver.implicitly_wait(5) + log = self.getLogger() + + time.sleep(2) + storagePage = StoragePage(self.driver) + storagePage.storagePage() + storagePage.AddStorage() + time.sleep(2) + + storagePage.StorageName().clear() + storagePage.StorageName().send_keys('NFS') + log.info("Name for NFS storage set as 'NFS'") + + storagePage.StorageTypeSelect() + storagePage.Type_NFS() + storagePage.NFSpath().send_keys("192.168.0.198:/StorageNFS/Marek") + storagePage.Save() + + self.driver.refresh() + time.sleep(2) + try: + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'NFS')]").is_displayed() + log.info("NFS storage created") + except: + log.critical("NFS storage creation failed") + raise + + def test_add_S3_Storage(self): + self.driver.implicitly_wait(5) + log = self.getLogger() + + time.sleep(2) + storagePage = StoragePage(self.driver) + storagePage.storagePage() + storagePage.AddStorage() + time.sleep(2) + + storagePage.StorageName().clear() + storagePage.StorageName().send_keys('Minio S3') + log.info("Name for S3 storage set as 'Minio S3'") + + + storagePage.StorageTypeSelect() + storagePage.S3() + storagePage.LoginS3().send_keys("minioadmin") + storagePage.SelectPassword() + + log.info("Creating password for MinioS3") + storagePage.AddNewPassword() + storagePage.PasswordName().send_keys("minio") + passwords = storagePage.Passwords() + for password in passwords: + password.send_keys("minioadmin") + time.sleep(2) + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-form-container/app-passwords-form/form/div[3]/app-save-button/button/span[1]/span").click() + time.sleep(2) + log.info("Password for MinioS3 storage set") + + storagePage.S3Url().send_keys("http://192.168.4.237:9000") + storagePage.S3Bucket().send_keys("storage") + storagePage.Save() + + self.driver.refresh() + time.sleep(2) + try: + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'Minio S3')]").is_displayed() + log.info("S3 storage created") + except: + log.critical("S3 storage creation failed") + raise + + def test_add_BackBlaze_storage(self): + self.driver.implicitly_wait(5) + log = self.getLogger() # + logInPage = LogInPage(self.driver) # + logInPage.logIn() + + time.sleep(2) + storagePage = StoragePage(self.driver) + storagePage.storagePage() + storagePage.AddStorage() + time.sleep(2) + + storagePage.StorageName().clear() + storagePage.StorageName().send_keys('BackBlaze') + log.info("Name for Blackblaze storage set as 'Backblaze'") + + storagePage.StorageTypeSelect() + storagePage.BackBlaze() + storagePage.LoginS3().send_keys("0032ff820db6e990000000006") + + storagePage.SelectPassword() + + log.info("Creating password for BackBlaze") + storagePage.AddNewPassword() + storagePage.PasswordName().send_keys("Backblaze") + passwords = storagePage.Passwords() + for password in passwords: + password.send_keys("K003XGuH9NSu9rTu/lSQ6kVcc8W1jEk") + time.sleep(2) + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-form-container/app-passwords-form/form/div[3]/app-save-button/button/span[1]/span").click() + time.sleep(2) + log.info("Password for BackBlaze storage set") + + dropdown = self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-backblaze/ng-select") + dropdown.click() + self.driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/app-backblaze/ng-select/ng-dropdown-panel/div[2]/div[2]/div[4]/div").click() + log.info("Storage region set") + + storagePage.BackBlazeBucket().send_keys("Wuwuwu") + time.sleep(1) + storagePage.Save() + + self.driver.refresh() + time.sleep(2) + try: + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'BackBlaze')]").is_displayed() + log.info("Backblaze storage created") + except: + log.critical("Backblaze storage creation failed") + raise + + def test_xoperoStorage(self): + storagePage = StoragePage(self.driver) + log = self.getLogger() + try: + + self.driver.implicitly_wait(5) + time.sleep(2) + storagePage.storagePage() + time.sleep(1) + assert self.driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage #1')]").is_displayed() + log.info("Xopero storage is avaiable") + except: + log.critical("Xopero storage is not avaiable!") + raise + return \ No newline at end of file diff --git a/File50MB.7z.iso b/File50MB.7z.iso new file mode 100644 index 0000000..fa5af5a --- /dev/null +++ b/File50MB.7z.iso @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23c7b46f89fa7c3c6d44f12d17cd284a0f7f45ec185855b14187896ea9f0c42e +size 52428800 diff --git a/FileBackUp/Main.py b/FileBackUp/Main.py new file mode 100644 index 0000000..71ca2a3 --- /dev/null +++ b/FileBackUp/Main.py @@ -0,0 +1,28 @@ +#region Imports +import sideTasks +import fileBackupPath +import fileRestore +import pathBackup +import systemVariable +import xoperoVariable +import time +from selenium import webdriver +#endregion + +PATH = "D:\chromedriver.exe" +driver = webdriver.Chrome(PATH) # or ...Chrome(executable_path=sciezka) + +sideTasks.logowanie(driver) + +fileBackupPath.fileBackupCLD(driver,"fileBackup") +pathBackup.pathBackup(driver,"By Path","E:\\abecadlo") + +xoperoVariables = ["HOMES","USERS_DOCUMENTS","USERS_DESKTOP","USERS_DOWNLOADS"] +for variable in xoperoVariables: + planName = 'Zmienna %s' %(variable) + xoperoVariable.xoperoVar(driver,planName,variable) + time.sleep(1) + +systemVariable.systemVar(driver,"System Var","smieci") + +fileRestore.FileRestore_Cloud(driver,"Xopero Storage #1 (XoperoOneEmea)","fileBackup") diff --git a/FileBackUp/__pycache__/fileBackupPath.cpython-39.pyc b/FileBackUp/__pycache__/fileBackupPath.cpython-39.pyc new file mode 100644 index 0000000..553387e Binary files /dev/null and b/FileBackUp/__pycache__/fileBackupPath.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/fileRestore.cpython-39.pyc b/FileBackUp/__pycache__/fileRestore.cpython-39.pyc new file mode 100644 index 0000000..fa90983 Binary files /dev/null and b/FileBackUp/__pycache__/fileRestore.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/pathBackup.cpython-39.pyc b/FileBackUp/__pycache__/pathBackup.cpython-39.pyc new file mode 100644 index 0000000..fc9700a Binary files /dev/null and b/FileBackUp/__pycache__/pathBackup.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/sideTasks.cpython-39.pyc b/FileBackUp/__pycache__/sideTasks.cpython-39.pyc new file mode 100644 index 0000000..3bd3f26 Binary files /dev/null and b/FileBackUp/__pycache__/sideTasks.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/supportTask.cpython-39.pyc b/FileBackUp/__pycache__/supportTask.cpython-39.pyc new file mode 100644 index 0000000..5039223 Binary files /dev/null and b/FileBackUp/__pycache__/supportTask.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/systemVariable.cpython-39.pyc b/FileBackUp/__pycache__/systemVariable.cpython-39.pyc new file mode 100644 index 0000000..ec38f7f Binary files /dev/null and b/FileBackUp/__pycache__/systemVariable.cpython-39.pyc differ diff --git a/FileBackUp/__pycache__/xoperoVariable.cpython-39.pyc b/FileBackUp/__pycache__/xoperoVariable.cpython-39.pyc new file mode 100644 index 0000000..ea4aef1 Binary files /dev/null and b/FileBackUp/__pycache__/xoperoVariable.cpython-39.pyc differ diff --git a/FileBackUp/fileBackupPath.py b/FileBackUp/fileBackupPath.py new file mode 100644 index 0000000..89156d7 --- /dev/null +++ b/FileBackUp/fileBackupPath.py @@ -0,0 +1,60 @@ +import supportTask + +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + +def fileBackupCLD(driver,planName): + driver.implicitly_wait(5) + driver.find_element(By.XPATH,"//*[contains(text(),'Plans')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Add plan')]").click() + + driver.find_element(By.NAME,"backupPlanName").clear() + driver.find_element(By.NAME,"backupPlanName").send_keys("%s" %(planName)) + + driver.find_element(By.XPATH,"//*[contains(text(),'How to protect')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'File-level')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Which devices?')]").click() + + mainDevice = driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + mainDevice.find_element(By.CLASS_NAME, "mat-checkbox").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'What to protect?')]").click() + + driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-rule/div/div[3]/div[2]/div[2]/div/h3').click() + + + folderTree = driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-add-device-rule/div/div[2]/app-files-browser/app-files/ul") + y = R"D:\pliki\jsony jira" ##<--- wstaw ścieżkę backupu + y=y.replace(":","") + backupPath = y.split("\\") + fileName = backupPath.pop(-1) + + for folder in backupPath: + folderName = folderTree.find_element(By.XPATH,"//span[text()='%s']/../.." %(folder)) + folderName.find_element(By.CSS_SELECTOR,"svg[data-icon='plus']").click() + + fileNameElem = folderTree.find_element(By.XPATH,"//*[contains(text(),'%s')]" %(fileName)) + driver.find_element(locate_with(By.CLASS_NAME, "mat-checkbox-layout").to_left_of(fileNameElem)).click() + + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-add-device-rule/div/div[3]/button/span[1]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Where to store?')]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'When?')]").click() + startAt = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + startAt.send_keys('1111') + driver.find_element(By.XPATH,"//*[contains(text(),'Next')]").click() + driver.find_element(By.XPATH,"//button[@type='submit']").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Save&Run')]").click() + + return + + + diff --git a/FileBackUp/fileRestore.py b/FileBackUp/fileRestore.py new file mode 100644 index 0000000..f208077 --- /dev/null +++ b/FileBackUp/fileRestore.py @@ -0,0 +1,67 @@ +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +from selenium.webdriver.common.action_chains import ActionChains +import time + +def FileRestore_Cloud(driver,storage,backupName): + driver.implicitly_wait(5) + + driver.find_element(By.XPATH,'/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]/span[2]').click() + + time.sleep(3) + location = driver.find_element(By.XPATH,"//*[contains(text(),'%s')]" %(storage)) ##<--- wstaw nazwę magazynu, z którego chcesz przywracać + parentLocation1 = location.find_element(By.XPATH,'./../..') + parentLocation1.find_element(By.CLASS_NAME, "mat-button-wrapper").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Select resource')]").click() + driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-select-worker/div/div[2]/app-filters-table/button').click() + x = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-select-worker/div/div[2]/app-filters-table/form/div/app-filters/app-filter-input/input') + x.send_keys('STASIAK-M') + + time.sleep(2) + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + time.sleep(2) + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-select-worker/div/div[3]/div/div/div/div").click() + time.sleep(1) + + try: + driver.find_element(By.XPATH,"//*[contains(text(),'View available plans')]").is_displayed() + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-resource-backups/div/div[3]/ng-select").click() + driver.find_element(By.XPATH,"//*[contains(text(),'%s')]" %(backupName)).click() + except: + pass + + driver.implicitly_wait(5) + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-resource-backups/div/div[3]/div[2]/app-browser-container/app-browser/div/div/app-browser-backups/div/div/div[2]/div/button/span[1]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Restore all')]").click() + time.sleep(1) + + driver.find_element(By.XPATH,"//*[contains(text(),'Select directory')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'New directory')]").click() + + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]/app-aside/ng-component/app-browse-device-files/div/div[3]/app-files-browser/app-files/ul/li[2]/div/app-icon").click() + + folderTree = driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[4]") + restorePath = R"backup\Cloud" ##<--- wstaw ścieżkę backupu + restorePath=restorePath.replace(":","") + backupPath = restorePath.split("\\") + fileName = backupPath.pop(-1) + + for folder in backupPath: + time.sleep(1) + folderTree.find_element(By.XPATH,"//span[text()='%s']/../../app-icon/fa-icon" %(folder)).click() + #folderName.find_element(By.XPATH,"//*/app-icon").click() + + fileNameElem = folderTree.find_element(By.XPATH,"//span[text()='%s']" %(fileName)) + time.sleep(1) + driver.find_element(locate_with(By.CSS_SELECTOR, "label[class='mat-checkbox-layout']").to_left_of(fileNameElem)).click() + + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Start now')]").click() + print("Test 1 - Uruchomienie FB restore z CLD: Pass") + + return() \ No newline at end of file diff --git a/FileBackUp/pathBackup.py b/FileBackUp/pathBackup.py new file mode 100644 index 0000000..03bcc84 --- /dev/null +++ b/FileBackUp/pathBackup.py @@ -0,0 +1,48 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + +def pathBackup(driver,planName,backupPath): + driver.implicitly_wait(5) + try: + driver.find_element(By.XPATH,"//*[contains(text(),'Plans')]").click() + except: + pass + driver.find_element(By.XPATH,"//*[contains(text(),'Add plan')]").click() + + driver.find_element(By.NAME,"backupPlanName").clear() + driver.find_element(By.NAME,"backupPlanName").send_keys("%s" %(planName)) + + driver.find_element(By.XPATH,"//*[contains(text(),'How to protect')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'File-level')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Which devices?')]").click() + + mainDevice = driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + mainDevice.find_element(By.CLASS_NAME, "mat-checkbox").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'What to protect?')]").click() + + + selectItems = driver.find_element(By.XPATH,"//div[text()='Select items to back up using']/..") + selectItems.find_element(By.CSS_SELECTOR,"div[role='combobox']").click() + selectItems.find_element(By.XPATH,"//*[contains(text(),'Set global rules')]").click() + driver.find_element(By.CSS_SELECTOR,"input[formcontrolname='path']").send_keys(backupPath) + #driver.find_element(By.CSS_SELECTOR,"svg[data-icon='check']").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Where to store?')]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'When?')]").click() + startAt = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + startAt.send_keys('1111') + driver.find_element(By.XPATH,"//*[contains(text(),'Next')]").click() + driver.find_element(By.XPATH,"//button[@type='submit']").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Save&Run')]").click() + + + diff --git a/FileBackUp/sideTasks.py b/FileBackUp/sideTasks.py new file mode 100644 index 0000000..b849219 --- /dev/null +++ b/FileBackUp/sideTasks.py @@ -0,0 +1,36 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + +def logowanie(driver): + try: + driver.get("http://localhost:28555") # <-- url usługi + driver.maximize_window() + time.sleep(2) + + + log = driver.find_element(By.NAME,'login') + log.send_keys('admin@xopero.com') # <-- login + time.sleep(1) + + pas = driver.find_element(By.ID,'mat-input-1') + pas.send_keys("Admin_123") #<-- hasło + + driver.find_element(By.XPATH,"//button[@type='submit']").click() + time.sleep(1) + title = driver.current_url + + if title == 'http://localhost:28555/devices': + print ("Test 1 - Logowanie: Pass") + return + + else: + print("Test 1 - Logowanie: Failed") + return + + except: + print("Test 1 - Logowanie: Failed") + exit() + + diff --git a/FileBackUp/supportTask.py b/FileBackUp/supportTask.py new file mode 100644 index 0000000..73e9dab --- /dev/null +++ b/FileBackUp/supportTask.py @@ -0,0 +1,57 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + + +def kontrolaZadania(driver): + try: + time.sleep(1) + print(" Zadanie w trakcie wykonywania") + x = True + + while x: + if driver.find_element(By.XPATH,'//*[@id="mat-badge-content-7"]').is_displayed(): + time.sleep(5) + else: + x = False + + try: + driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[2]/aside/app-aside/ng-component/app-dashboard-plan/div/div[1]/app-close-aside-button/button').click() + except: + pass + + print(" Zakończono zadanie") + return + except: + return + +def podsumowanie(driver): + try: + driver.find_element(By.XPATH,"//*[contains(text(),'Tasks')]").click() #wybór zadań + driver.find_element(By.XPATH,"//*[contains(text(),'Last 24 hours')]").click() #wybór wykonanych zadań + + ########################################## + statuses = ["OK","warnings","errors"] + for status in statuses: + attribute = driver.find_element(By.XPATH,"//span[text()='%s']" %(status)) + result = driver.find_element(locate_with(By.CLASS_NAME, "count").above(attribute)).text + print(status,":",result) + + # OK = driver.find_element(By.XPATH,"//span[text()='OK']") + # Success = driver.find_element(locate_with(By.CLASS_NAME, "count").above(OK)).text + + # warning = driver.find_element(By.XPATH,"//span[text()='warnings']") + # warnResult = driver.find_element(locate_with(By.CLASS_NAME, "count").above(warning)).text + + # NOK = driver.find_element(By.XPATH,"//span[text()='errors']") + # errors = driver.find_element(locate_with(By.CLASS_NAME, "count").above(NOK)).text + + # print(" Podsumowanie wykonania zadania: Pass") + # print(" Pomyślnie zakończono %s zadań" %(Success)) + # print(" Ostrzeżeniami zakończono %s zadań " %(warnResult)) + # print(" Błędami zakończono %s zadań" %(errors)) + + except: + print("Podsumowanie wykonania zadania: Failed") + return() \ No newline at end of file diff --git a/FileBackUp/systemVariable.py b/FileBackUp/systemVariable.py new file mode 100644 index 0000000..4eb40ef --- /dev/null +++ b/FileBackUp/systemVariable.py @@ -0,0 +1,48 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + +def systemVar(driver,planName,systemVariable): + driver.implicitly_wait(5) + try: + driver.find_element(By.XPATH,"//*[contains(text(),'Plans')]").click() + except: + pass + driver.find_element(By.XPATH,"//*[contains(text(),'Add plan')]").click() + + driver.find_element(By.NAME,"backupPlanName").clear() + driver.find_element(By.NAME,"backupPlanName").send_keys("%s" %(planName)) + + driver.find_element(By.XPATH,"//*[contains(text(),'How to protect')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'File-level')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Which devices?')]").click() + + mainDevice = driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + mainDevice.find_element(By.CLASS_NAME, "mat-checkbox").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'What to protect?')]").click() + + + selectItems = driver.find_element(By.XPATH,"//div[text()='Select items to back up using']/..") + selectItems.find_element(By.CSS_SELECTOR,"div[role='combobox']").click() + selectItems.find_element(By.XPATH,"//*[contains(text(),'Set global rules')]").click() + + driver.find_element(By.CSS_SELECTOR, "ng-select[bindlabel='name']").click() + driver.find_element(By.XPATH,"//h4[text()='System variable']").click() + driver.find_element(By.CSS_SELECTOR,"input[formcontrolname='systemVariable']").send_keys(systemVariable) + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Where to store?')]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'When?')]").click() + startAt = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + startAt.send_keys('1111') + driver.find_element(By.XPATH,"//*[contains(text(),'Next')]").click() + driver.find_element(By.XPATH,"//button[@type='submit']").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Save&Run')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Tasks')]").click() diff --git a/FileBackUp/xoperoVariable.py b/FileBackUp/xoperoVariable.py new file mode 100644 index 0000000..822b70b --- /dev/null +++ b/FileBackUp/xoperoVariable.py @@ -0,0 +1,49 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +import time + +def xoperoVar(driver,planName,xoperoVariable): + driver.implicitly_wait(5) + try: + driver.find_element(By.XPATH,"//*[contains(text(),'Plans')]").click() + except: + pass + driver.find_element(By.XPATH,"//*[contains(text(),'Add plan')]").click() + + driver.find_element(By.NAME,"backupPlanName").clear() + driver.find_element(By.NAME,"backupPlanName").send_keys("%s" %(planName)) + + driver.find_element(By.XPATH,"//*[contains(text(),'How to protect')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'File-level')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Which devices?')]").click() + + mainDevice = driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + mainDevice.find_element(By.CLASS_NAME, "mat-checkbox").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'What to protect?')]").click() + + + selectItems = driver.find_element(By.XPATH,"//div[text()='Select items to back up using']/..") + selectItems.find_element(By.CSS_SELECTOR,"div[role='combobox']").click() + selectItems.find_element(By.XPATH,"//*[contains(text(),'Set global rules')]").click() + + driver.find_element(By.CSS_SELECTOR, "ng-select[bindlabel='name']").click() + driver.find_element(By.XPATH,"//h4[text()='Xopero variable']").click() + driver.find_element(By.CSS_SELECTOR, "ng-select[formcontrolname='xoperoVariable']").click() + driver.find_element(By.XPATH,"//h4[text()='%s']" %(xoperoVariable)).click() + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Where to store?')]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'When?')]").click() + startAt = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + startAt.send_keys('1111') + driver.find_element(By.XPATH,"//*[contains(text(),'Next')]").click() + driver.find_element(By.XPATH,"//button[@type='submit']").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Save&Run')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Tasks')]").click() diff --git a/Tests/__init__.py b/Tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Tests/__pycache__/__init__.cpython-310.pyc b/Tests/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..2f58d94 Binary files /dev/null and b/Tests/__pycache__/__init__.cpython-310.pyc differ diff --git a/Tests/__pycache__/__init__.cpython-39.pyc b/Tests/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..9abbd35 Binary files /dev/null and b/Tests/__pycache__/__init__.cpython-39.pyc differ diff --git a/Tests/__pycache__/conftest.cpython-310-pytest-7.1.2.pyc b/Tests/__pycache__/conftest.cpython-310-pytest-7.1.2.pyc new file mode 100644 index 0000000..abee93b Binary files /dev/null and b/Tests/__pycache__/conftest.cpython-310-pytest-7.1.2.pyc differ diff --git a/Tests/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc b/Tests/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..e58da03 Binary files /dev/null and b/Tests/__pycache__/conftest.cpython-39-pytest-7.1.2.pyc differ diff --git a/Tests/__pycache__/test_e2e.cpython-310-pytest-7.1.2.pyc b/Tests/__pycache__/test_e2e.cpython-310-pytest-7.1.2.pyc new file mode 100644 index 0000000..b91eaae Binary files /dev/null and b/Tests/__pycache__/test_e2e.cpython-310-pytest-7.1.2.pyc differ diff --git a/Tests/__pycache__/test_e2e.cpython-39-pytest-7.1.2.pyc b/Tests/__pycache__/test_e2e.cpython-39-pytest-7.1.2.pyc new file mode 100644 index 0000000..8e5505c Binary files /dev/null and b/Tests/__pycache__/test_e2e.cpython-39-pytest-7.1.2.pyc differ diff --git a/Tests/conftest.py b/Tests/conftest.py new file mode 100644 index 0000000..6e8f443 --- /dev/null +++ b/Tests/conftest.py @@ -0,0 +1,32 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +#endregion + +def pytest_addoption(parser): + parser.addoption( + "--browser_name", action="store", default="chrome", help="help text here" + ) + +@pytest.fixture(scope="class") +def setupBrowser(request): + browser_name = request.config.getoption("browser_name") + if browser_name == "chrome": + driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\chromedriver.exe") + + elif browser_name == "firefox": + pass + #firefox invo + + else: + pass + #IE invo + + driver.get("https://rahulshettyacademy.com/angularpractice/") + driver.maximize_window() + request.cls.driver = driver + yield + driver.close() diff --git a/Tests/pageObjects/CheckoutPage.py b/Tests/pageObjects/CheckoutPage.py new file mode 100644 index 0000000..22f5a08 --- /dev/null +++ b/Tests/pageObjects/CheckoutPage.py @@ -0,0 +1,19 @@ +from selenium.webdriver.common.by import By + +class CheckOutPage: + + cardTitle = (By.CSS_SELECTOR, ".card-title a") + cardFooter = (By.CSS_SELECTOR,".card-footer button") + checkout = (By.CSS_SELECTOR,"a[class*='btn-primary']") + + def __init__(self,driver): + self.driver=driver + + def getCardTitles(self): + return self.driver.find_elements(*CheckOutPage.cardTitle) + + def getCardFooter(self): + return self.driver.find_elements(*CheckOutPage.cardFooter) + + def Checkout(self): + return self.driver.find_element(*CheckOutPage.checkout) \ No newline at end of file diff --git a/Tests/pageObjects/ConfirmPage.py b/Tests/pageObjects/ConfirmPage.py new file mode 100644 index 0000000..e69de29 diff --git a/Tests/pageObjects/HomePage.py b/Tests/pageObjects/HomePage.py new file mode 100644 index 0000000..dd64980 --- /dev/null +++ b/Tests/pageObjects/HomePage.py @@ -0,0 +1,15 @@ +from selenium.webdriver.common.by import By +from pageObjects.CheckoutPage import CheckOutPage + +class HomePage: + + shop = (By.CSS_SELECTOR, "a[href*='shop']") + + def __init__(self,driver): + self.driver = driver + + + def shopItem(self): + self.driver.find_element(*HomePage.shop).click() + checkOutPage = CheckOutPage(self.driver) + return checkOutPage \ No newline at end of file diff --git a/Tests/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc b/Tests/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc new file mode 100644 index 0000000..812fb8c Binary files /dev/null and b/Tests/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc differ diff --git a/Tests/pageObjects/__pycache__/HomePage.cpython-310.pyc b/Tests/pageObjects/__pycache__/HomePage.cpython-310.pyc new file mode 100644 index 0000000..9f123b6 Binary files /dev/null and b/Tests/pageObjects/__pycache__/HomePage.cpython-310.pyc differ diff --git a/Tests/test_e2e.py b/Tests/test_e2e.py new file mode 100644 index 0000000..6337114 --- /dev/null +++ b/Tests/test_e2e.py @@ -0,0 +1,36 @@ +#regionImport +import pytest +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from utilities.BaseClass import BaseClass +from pageObjects.HomePage import HomePage +from pageObjects.CheckoutPage import CheckOutPage +#endregion + +class TestOne(BaseClass): + + def test_e2e(self): + homePage = HomePage(self.driver) + checkoutpage = homePage.shopItem() + cards = checkoutpage.getCardTitles() + i=-1 + for card in cards: + i=i+1 + cardText = card.text + if cardText == "Blackberry": + checkoutpage.getCardFooter()[i].click() + + checkoutpage.Checkout().click() + + self.driver.find_element(By.XPATH,"//button[@class='btn btn-success']").click() + self.driver.find_element(By.ID,"country").send_keys("ind") + self.verifyLinkPresence("India") + self.driver.find_element(By.LINK_TEXT,"India").click() + self.driver.find_element(By.XPATH,"//div[@class='checkbox checkbox-primary']").click() + self.driver.find_element(By.CSS_SELECTOR,"[type='submit']").click() + textMatch = self.driver.find_element(By.CSS_SELECTOR,"[class*='alert-success']").text + + assert ("Success" in textMatch) + diff --git a/Tests/utilities/BaseClass.py b/Tests/utilities/BaseClass.py new file mode 100644 index 0000000..f1d01a5 --- /dev/null +++ b/Tests/utilities/BaseClass.py @@ -0,0 +1,12 @@ +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +@pytest.mark.usefixtures("setupBrowser") + +class BaseClass: + + def verifyLinkPresence(self,text): + element = WebDriverWait(self.driver, 10).until( + EC.presence_of_element_located((By.LINK_TEXT, text))) diff --git a/Tests/utilities/__pycache__/BaseClass.cpython-310.pyc b/Tests/utilities/__pycache__/BaseClass.cpython-310.pyc new file mode 100644 index 0000000..2df4f53 Binary files /dev/null and b/Tests/utilities/__pycache__/BaseClass.cpython-310.pyc differ diff --git a/Tests/utilities/__pycache__/BaseClass.cpython-39.pyc b/Tests/utilities/__pycache__/BaseClass.cpython-39.pyc new file mode 100644 index 0000000..c875105 Binary files /dev/null and b/Tests/utilities/__pycache__/BaseClass.cpython-39.pyc differ diff --git a/Testy Regresji.py b/Testy Regresji.py new file mode 100644 index 0000000..deadf96 --- /dev/null +++ b/Testy Regresji.py @@ -0,0 +1,317 @@ +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +import time + +PATH = "D:\chromedriver.exe" +driver = webdriver.Chrome(PATH) # or ...Chrome(executable_path=sciezka) + +###############TEST 1 - Logowanie #################### +def logowanie(): + try: + driver.get("http://localhost:28555/") + driver.maximize_window() + time.sleep(2) + log = driver.find_element_by_name('login') + log.send_keys('admin@xopero.com') + + pas = driver.find_element_by_id('mat-input-1') + pas.send_keys('Admin_123') + + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/app-auth/div/app-auth-login/div/form/app-save-button/button').click() + time.sleep(1) + title = driver.current_url + if title == 'http://localhost:28555/devices': + print ("Test 1 - Logowanie: Pass") + return + else: + print("Test 1 - Logowanie: Failed") + return + except: + print("Test 1 - Logowanie: Failed") + exit() + + +#################Test 2 - Dodawanie urządzenia############# +def dodanieUrzadzenia(): + try: + if driver.find_element_by_id("mat-badge-content-0").is_displayed(): + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[2]/button[1]').click() + time.sleep(1) + driver.find_element_by_xpath('//*[@id="mat-checkbox-2"]/label/span[1]').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-activate-devices-table/div/div[4]/app-save-button/button/span[1]').click() + time.sleep(1) + driver.find_element_by_xpath('//app-license[2]/p').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-licenses-list/div/div[4]/app-save-button/button/span[1]/span').click() + print('Test 2 - Dodawanie urządzenia: Pass') + return + else: + print('Test 2 - Dodawanie urządzenia: Pass(Brak urządzeń do dodania)') + return + except: + print('Test 2 - Dodawanie urządzenia: Failed') + return + +################Test Kontrola Xopero Storage#################### +def xoperoStorage(): + driver.implicitly_wait(5) + time.sleep(2) + driver.find_element_by_xpath("//*[contains(text(),'Magazyny')]").click() #wybór magazynu + time.sleep(1) + print('Test Kontrola Xopero Storage: ', driver.find_element_by_xpath("//*[contains(text(),'Xopero Storage #1')]").is_displayed()) + return + +#############Test 3 - Dodawanie magazynu lokalnego########## +def dodajLokalny(): + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[1]/ng-component/button/span[1]').click() + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field").click() + elem = driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field/div/div[1]/div[2]/input")# + ID = (elem.get_attribute("id")) + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).clear() + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).send_keys("magazyn lokalny") + matInput=int(ID[-2:]) + if matInput>=0: + pass + else: + matInput=int(ID[-1:]) + matInput+=2 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("D:\storage testowy") + driver.find_element_by_xpath("//*[contains(text(),'Zapisz')]").click() + print ("Test 3 - Dodawanie magazynu lokalnego: Pass") + except: + print ("Test 3 - Dodawanie magazynu lokalnego: Failed") + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[1]/app-close-aside-button/button').click() + driver.find_element_by_xpath('//*[@id="mat-dialog-8"]/app-modal/div/div[3]/button[2]').click() + except: + pass + return + +time.sleep(2) +##############Test 4 - Dodawanie magazynu SMB########## +def dodajSMB(): + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[1]/ng-component/button/span[1]').click() + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field").click() + elem = driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field/div/div[1]/div[2]/input")# + ID = (elem.get_attribute("id")) + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).clear() + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).send_keys("magazyn SMB") + time.sleep(1) + matInput=int(ID[-2:]) + if matInput>=0: + pass + else: + matInput=int(ID[-1:]) + matInput+=4 + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/ng-select/div').click() + driver.find_element_by_xpath("//*[contains(text(),'Lokalizacja sieciowa')]").click() + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("admin") + driver.find_element_by_xpath("//*[contains(text(),'Wybierz lub dodaj')]").click() + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-list-container/app-passwords-list/div/div[3]/button").click() + matInput+=1 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("admin") + matInput+=1 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("Admin_123") + matInput+=1 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("Admin_123") + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-passwords-form-container/app-passwords-form/form/div[3]/app-save-button/button/span[1]").click() + matInput-=4 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("\\\\192.168.0.198\Public\MStasiak") + driver.find_element_by_xpath("//*[contains(text(),'Zapisz')]").click() + print ("Test 3 - Dodawanie magazynu SMB: Pass") + except: + print ("Test 3 - Dodawanie magazynu SMB: Failed") + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[1]/app-close-aside-button/button').click() + driver.find_element_by_xpath('//*[@id="mat-dialog-8"]/app-modal/div/div[3]/button[2]').click() + except: + pass + time.sleep(2) + return + +#############Test 4 - Dodawanie magazynu NFS######### +def dodajNFS(): + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[1]/ng-component/button/span[1]').click() + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field").click() + elem = driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field/div/div[1]/div[2]/input")# + ID = (elem.get_attribute("id")) + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).clear() + driver.find_element_by_xpath('//*[@id="%s"]' %(ID)).send_keys("magazyn NFS") + matInput=int(ID[-2:]) + if matInput>=0: + pass + else: + matInput=int(ID[-1:]) + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[2]/form/ng-select/div').click() + driver.find_element_by_xpath("//*[contains(text(),'Network File Storage')]").click() + matInput+=3 + driver.find_element_by_xpath('//*[@id="mat-input-%d"]' %(matInput)).send_keys("192.168.0.198:/StorageNFS") + driver.find_element_by_xpath("//*[contains(text(),'Zapisz')]").click() + print ("Test 4 - Dodawanie magazynu NFS: Pass") + except: + print ("Test 4 - Dodawanie magazynu NFS: Failed") + try: + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/div[1]/app-close-aside-button/button').click() + driver.find_element_by_xpath('//*[@id="mat-dialog-8"]/app-modal/div/div[3]/button[2]').click() + except: + pass + time.sleep(1) + return + +def kontrolaZadania(): + time.sleep(2) + x = True + while x: + if driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[7]/span[1]/app-icon/span').is_displayed(): + time.sleep(5) + else: + x = False + driver.fin('/html/body/app-root/app-main/div/app-content/div[2]/aside/app-aside/ng-component/app-dashboard-plan/div/div[1]/app-close-aside-button/button').click() + print("Zakończono zadanie") + return + +#############Test 5 - Logowanie organizacji GitHub####### +def zalogujGH(): + try: + driver.get("https://github.com/") + time.sleep(2) + driver.find_element_by_xpath("//*[contains(text(),'Sign in')]").click() + time.sleep(2) + GH = driver.find_element_by_name("login") + GH.send_keys("stasiak.marek93@gmail.com") + PASY = driver.find_element_by_name("password") + PASY.send_keys("Plokijuh1.") + driver.find_element_by_name("commit").click() + print ("Test 5 - Logowanie organizacji GitHub: Pass") + except: + print ("Test 5 - Logowanie organizacji GitHub: Failed") + time.sleep(1) + driver.get("http://localhost:28555/git") + return + +#############Test 6 - Dodawanie organizacji GitHub####### +def dodajGH(): + try: + driver.implicitly_wait(10) + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/ng-component/app-organizations/ng-containter/app-git-no-organizations/div/button[2]').click() #wybór git do utworzenia + driver.find_element_by_xpath("//*[contains(text(),'Kontynuuj')]").click() + time.sleep(5) + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-git-organization/div/div[5]/app-save-button/button").click() #zatwierdzenie tworzenia git + print("Test 6 - Dodawanie organizacji GitHub: Pass") + except: + print('Test 6 - Dodawanie organizacji GitHub: Failed') + time.sleep(1) + return +#############Test 7 - Dodawanie i uruchomienie planu predefiniowanego do organizacji GitHub####### +def predefiniowany(): + try: + driver.find_element_by_xpath('//*[@id="mat-dialog-0"]/app-modal/div/div[3]/button[2]/span[1]').click() + print ("Test 7 - Dodawanie i uruchomienie planu predefiniowanego do organizacji GitHub: Pass") + except: + try: + driver.get("http://localhost:28555/git") + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/main/div/ng-component/app-organizations/ng-containter/app-organization-container/app-organization/section/article/app-simplified-backup-plans/div/div/div/button/span[1]").click() + time.sleep(3) + driver.find_element_by_xpath("//*[contains(text(),'Git Protection')]").click() + print("Test 7 - Dodawanie planu predefiniowanego do organizacji GitHub: Pass") + except: + print("Test 7 - Dodawanie planu predefiniowanego do organizacji GitHub: Failed") + time.sleep(1) + #############Test 8 - Uruchamianie planu predefiniowanego do organizacji GitHub####### + try: + time.sleep(1) + driver.find_element_by_xpath("//*[contains(text(),'Wykonaj teraz')]").click() + print("Test 8 - Uruchamianie planu predefiniowanego do organizacji GitHub: Pass") + except: + print ("Test 8 - Uruchamianie planu predefiniowanego do organizacji GitHub: Failed") + time.sleep(2) + kontrolaZadania() + + +##################Test 10 - Podsumowanie backupu GIT (test 8)################# +def podsumowanie(): + driver.find_element_by_xpath("//*[contains(text(),'Zadania')]").click() #wybór zadań + driver.find_element_by_xpath("//*[contains(text(),'Ostatnie 24 godziny')]").click() #wybór wykonanych zadań + okelem = driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/ng-component/article/mat-tab-group/div/mat-tab-body[2]/div/app-packages/mat-accordion/app-package[1]/mat-expansion-panel/mat-expansion-panel-header/span/div[2]/app-package-tasks-statuses/div[1]/div/span[1]') + OK = (okelem.get_attribute("innerHTML")) + time.sleep(1) + warelem = driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/ng-component/article/mat-tab-group/div/mat-tab-body[2]/div/app-packages/mat-accordion/app-package[1]/mat-expansion-panel/mat-expansion-panel-header/span/div[2]/app-package-tasks-statuses/div[2]/div/span[1]') + Warnings = (warelem.get_attribute("innerHTML")) + time.sleep(1) + nokelem = driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/ng-component/article/mat-tab-group/div/mat-tab-body[2]/div/app-packages/mat-accordion/app-package[1]/mat-expansion-panel/mat-expansion-panel-header/span/div[2]/app-package-tasks-statuses/div[3]/div/span') + NOK = (nokelem.get_attribute("innerHTML")) + time.sleep(1) + print("Pomyślnie zakończono %s repozytoriów" %(OK)) + print("Ostrzeżeniami zakończono %s repozytoriów " %(warelem)) + print("Błędami zakończono %s repozytoriów" %(NOK)) + return + +#################Test 11 - Kontrola przywróconych backupów (test8)######################## +def kontrolaBackupu(): + driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[4]').click() + #time.sleep(30) + plany = 0 + time.sleep(2) + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/main/div/ng-component/app-organizations/ng-containter/app-organization-container/app-organization/section/footer/button[2]").click() + time.sleep(2) + for i in range(1,11): + driver.find_element_by_xpath("/html/body/app-root/app-main/div/app-content/main/div/ng-component/app-repositories/article/app-table/cdk-virtual-scroll-viewport/div[1]/table/tbody/tr[%d]/td[7]/button[2]/span[1]" %(i)).click() + time.sleep(5) + try: + driver.find_element_by_xpath("//*[contains(text(),'Wyświetl dostępne plany, a następnie wybierz backup do przywrócenia')]").is_displayed() + print("Brak planu backup") + except: + print("Plan backup dostępny") + plany+=1 + print("Utworzono ", plany, "na 10 planów") + return + +#################Test 12 - przywracanie backupu (test8)################# +def przywracanieGH(): + driver.implicitly_wait(5) + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-resource-backups/div/div[3]/div/app-browser-container/app-browser/div/div/app-browser-backups/div/div/div[2]/div/button').click() + time.sleep(3) + driver.find_element_by_xpath("//*[contains(text(),'Restore all')]").click() + time.sleep(3) + driver.find_element_by_xpath("//*[contains(text(),'Start now')]").click() + driver.find_element_by_xpath("//*[contains(text(),'Zadania')]").click() #wybór zadań + time.sleep(2) + kontrolaZadania() + driver.find_element_by_xpath("//*[contains(text(),'Last 24 hours')]").click() #wybór wykonanych zadań + print("Wykonano przywracanie repozytorium GH") + return + +for i in range(1,100): + if i==1: + logowanie() + elif i==2: + dodanieUrzadzenia() + elif i==3: + xoperoStorage() + elif i==4: + dodajLokalny() + elif i==5: + dodajSMB() + elif i==6: + dodajNFS() + elif i==7: + zalogujGH() + elif i==8: + dodajGH() + elif i==9: + predefiniowany() + elif i==10: + podsumowanie() + elif i==11: + kontrolaBackupu() + elif i==12: + przywracanieGH() + else: + exit() + +#driver.close() \ No newline at end of file diff --git a/code-Part1/Demo.py b/code-Part1/Demo.py new file mode 100644 index 0000000..015b666 --- /dev/null +++ b/code-Part1/Demo.py @@ -0,0 +1,67 @@ +#Implicit wait - +#Explicit Wait +import time + +from selenium import webdriver +#pause the test for few seconds using Time class +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.webdriver.support.wait import WebDriverWait + +#driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") + +driver = webdriver.Ie(executable_path="C:\\IEDriverServer.exe") +driver.implicitly_wait(5) +list = [] +list2 = [] +# wait until 5 seconds if object is not displayed +#Global wait +#1.5 second to reach next page- execution will resume in 1.5 seconds +#if object do not show up at all, then max time your test waits for 5 seconds +driver.get("https://rahulshettyacademy.com/seleniumPractise/") +driver.find_element_by_css_selector("input.search-keyword").send_keys("ber") +time.sleep(4) +count =len(driver.find_elements_by_xpath("//div[@class='products']/div")) +assert count == 3 +buttons = driver.find_elements_by_xpath("//div[@class='product-action']/button") + +for button in buttons: + list.append(button.find_element_by_xpath("parent::div/parent::div/h4").text) + button.click() + +print(list) + +driver.find_element_by_css_selector("img[alt='Cart']").click() +driver.find_element_by_xpath("//button[text()='PROCEED TO CHECKOUT']").click() +wait = WebDriverWait(driver, 5) +wait.until(expected_conditions.presence_of_element_located((By.CLASS_NAME, "promoCode"))) +veggies =driver.find_elements_by_css_selector("p.product-name") +for l in veggies: + list2.append(l.text) + +print(list2) +assert list == list2 + +amount1= driver.find_element_by_css_selector(".discountAmt").text + +driver.find_element_by_class_name("promoCode").send_keys("rahulshettyacademy") +driver.find_element_by_css_selector(".promoBtn").click() +print(driver.find_element_by_css_selector("span.promoInfo").text) + +amount2= driver.find_element_by_css_selector(".discountAmt").text + +assert int(amount1) > float(amount2) + +veggiesAmount = driver.find_elements_by_xpath("//tr/td[5]/p") +sum = 0 + +for v in veggiesAmount: + sum = sum + int(v.text) + +print(sum) + +assert sum == int(amount2) + + + + diff --git a/code-Part1/childWindow.py b/code-Part1/childWindow.py new file mode 100644 index 0000000..ae34a39 --- /dev/null +++ b/code-Part1/childWindow.py @@ -0,0 +1,13 @@ +from selenium import webdriver +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") + +driver.get("https://the-internet.herokuapp.com/windows") +driver.find_element_by_link_text("Click Here").click() +childwindow = driver.window_handles[1] + +driver.switch_to.window(childwindow) +print(driver.find_element_by_tag_name("h3").text) +driver.close() +driver.switch_to.window(driver.window_handles[0]) + +assert "Opening a new window" == driver.find_element_by_tag_name("h3").text diff --git a/code-Part1/chromeOptionsDemo.py b/code-Part1/chromeOptionsDemo.py new file mode 100644 index 0000000..856d2c1 --- /dev/null +++ b/code-Part1/chromeOptionsDemo.py @@ -0,0 +1,14 @@ +from selenium import webdriver +from selenium.webdriver.support.select import Select + +chrome_options = webdriver.ChromeOptions() +chrome_options.add_argument("--start-maximized") +chrome_options.add_argument("headless") +chrome_options.add_argument("--ignore-certificate-errors") + + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe",options=chrome_options) + +driver.get("https://rahulshettyacademy.com/angularpractice/") + +print(driver.title) \ No newline at end of file diff --git a/code-Part1/demoBrowser.py b/code-Part1/demoBrowser.py new file mode 100644 index 0000000..025d028 --- /dev/null +++ b/code-Part1/demoBrowser.py @@ -0,0 +1,25 @@ +from selenium import webdriver +#browser exposes an executable file +#Through Selenium test we need to invoke the executable file which will then invoke actual browser +#driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +#driver=webdriver.Firefox(executable_path="C:\\geckodriver.exe") +driver = webdriver.Ie(executable_path="C:\\IEDriverServer.exe") +driver.maximize_window() +driver.get("https://rahulshettyacademy.com/") #get method to hit url on browser + +print(driver.title) +print(driver.current_url) +driver.get("https://rahulshettyacademy.com/AutomationPractice/") +driver.minimize_window() +driver.back() +driver.refresh() +driver.close() + + + + + + + + + diff --git a/code-Part1/e2eTest.py b/code-Part1/e2eTest.py new file mode 100644 index 0000000..a391e60 --- /dev/null +++ b/code-Part1/e2eTest.py @@ -0,0 +1,35 @@ + +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.webdriver.support.select import Select +from selenium.webdriver.support.wait import WebDriverWait + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.get("https://rahulshettyacademy.com/angularpractice/") +driver.find_element_by_css_selector("a[href*='shop']").click() +products = driver.find_elements_by_xpath("//div[@class='card h-100']") + +#//div[@class='card h-100']/div/h4/a +#product =//div[@class='card h-100'] +for product in products: + productName = product.find_element_by_xpath("div/h4/a").text + if productName == "Blackberry": + #Add item into cart + product.find_element_by_xpath("div/button").click() + +driver.find_element_by_css_selector("a[class*='btn-primary']").click() +driver.find_element_by_xpath("//button[@class='btn btn-success']").click() +driver.find_element_by_id("country").send_keys("ind") +wait = WebDriverWait(driver, 7) +wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India"))) +driver.find_element_by_link_text("India").click() +driver.find_element_by_xpath("//div[@class='checkbox checkbox-primary']").click() +driver.find_element_by_css_selector("[type='submit']").click() +successText = driver.find_element_by_class_name("alert-success").text + +assert "Success! Thank you!" in successText + +driver.get_screenshot_as_file("screen.png") + + diff --git a/code-Part1/explicitwaitDemo.py b/code-Part1/explicitwaitDemo.py new file mode 100644 index 0000000..76cdcbb --- /dev/null +++ b/code-Part1/explicitwaitDemo.py @@ -0,0 +1,63 @@ +#Implicit wait - +#Explicit Wait +import time + +from selenium import webdriver +#pause the test for few seconds using Time class +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.webdriver.support.wait import WebDriverWait + +list = [] +list2 = [] +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") + +driver.get("https://rahulshettyacademy.com/seleniumPractise/") +driver.find_element_by_css_selector("input.search-keyword").send_keys("ber") +time.sleep(4) +count =len(driver.find_elements_by_xpath("//div[@class='products']/div")) +assert count == 3 +buttons = driver.find_elements_by_xpath("//div[@class='product-action']/button") +#//div[@class='product-action']/button/parent::div/parent::div/h4 +for button in buttons: + list.append(button.find_element_by_xpath("parent::div/parent::div/h4").text) + button.click() +print(list) + +driver.find_element_by_css_selector("img[alt='Cart']").click() +driver.find_element_by_xpath("//button[text()='PROCEED TO CHECKOUT']").click() +wait = WebDriverWait(driver, 8) +wait.until(expected_conditions.presence_of_element_located((By.CLASS_NAME, "promoCode"))) + +veggies =driver.find_elements_by_css_selector("p.product-name") +for veg in veggies: + list2.append(veg.text) + +print(list2) +assert list == list2 +originalAmount = driver.find_element_by_css_selector(".discountAmt").text +driver.find_element_by_class_name("promoCode").send_keys("rahulshettyacademy") +driver.find_element_by_css_selector(".promoBtn").click() + +wait.until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR,"span.promoInfo"))) +discountAmount = driver.find_element_by_css_selector(".discountAmt").text + +assert float(discountAmount) < int(originalAmount) + +print(driver.find_element_by_css_selector("span.promoInfo").text) + +amounts = driver.find_elements_by_xpath("//tr/td[5]/p") +sum = 0 +for amount in amounts: + sum = sum + int(amount.text) #32+48+60 + +print(sum) + +totalAmount = int(driver.find_element_by_class_name("totAmt").text) + +assert sum == totalAmount + + + + + diff --git a/code-Part1/findElementsTest.py b/code-Part1/findElementsTest.py new file mode 100644 index 0000000..932f154 --- /dev/null +++ b/code-Part1/findElementsTest.py @@ -0,0 +1,21 @@ +import time + +from selenium import webdriver + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.get("https://www.makemytrip.com/") +driver.find_element_by_id("fromCity").click() +driver.find_element_by_css_selector("input[placeholder='From']").send_keys("del") +time.sleep(2) +cities =driver.find_elements_by_css_selector("p[class*='blackText']") +print (len(cities)) +for city in cities: + if city.text =="Del Rio, United States": + city.click() + break + + +driver.find_element_by_xpath("//p[text()='Delhi, India']").click() + + + diff --git a/code-Part1/framesDemo.py b/code-Part1/framesDemo.py new file mode 100644 index 0000000..628a313 --- /dev/null +++ b/code-Part1/framesDemo.py @@ -0,0 +1,13 @@ + +from selenium import webdriver + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +#iframe, frameset, frame +driver.get("https://the-internet.herokuapp.com/iframe") +#frame id or frame name or index value +driver.switch_to.frame("mce_0_ifr") +driver.find_element_by_css_selector("#tinymce").clear() +driver.find_element_by_css_selector("#tinymce").send_keys("I am able to automate") +driver.switch_to.default_content() + +print(driver.find_element_by_tag_name("h3").text) \ No newline at end of file diff --git a/code-Part1/geckodriver.log b/code-Part1/geckodriver.log new file mode 100644 index 0000000..ba635a8 --- /dev/null +++ b/code-Part1/geckodriver.log @@ -0,0 +1,38 @@ +1572992575661 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\Owner\\AppData\\Local\\Temp\\rust_mozprofilejNz7no" +1572992577423 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons +1572992577423 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry +1572992577423 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/ +1572992577424 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader* +JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +1572992580400 Marionette INFO Listening on port 58063 +1572992580756 Marionette WARN TLS certificate errors will be ignored for this session +JavaScript error: , line 0: uncaught exception: Object +[Parent 12276, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Child 12124, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Child 12124, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Parent 12276, Gecko_IOThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Child 18904, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Child 189041573511128567 Marionette INFO Stopped listening on port 58063 + +###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost + + +###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv + +RN TLS certificate errors will be ignored for this session +1573510525471 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\Owner\\AppData\\Local\\Temp\\rust_mozprofileLR4Aro" +1573510526869 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons +1573510526869 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry +1573510526869 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/ +1573510526869 addons.webextension.screenshots@mozilla.org WARN Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader* +JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +1573510529795 Marionette INFO Listening on port 57932 +1573510529831 Marionette WARN TLS certificate errors will be ignored for this session +1573510542218 Marionette INFO Stopped listening on port 57932 +[Child 7836, Chrome_ChildThread] WARNING: pipe error: 109: file z:/task_1566864336/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 341 +[Child 7836, Chrome_ChildThread][GPU 3056, +###!!! [Child][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost + + +###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv + diff --git a/code-Part1/jseDemo.py b/code-Part1/jseDemo.py new file mode 100644 index 0000000..f23f70b --- /dev/null +++ b/code-Part1/jseDemo.py @@ -0,0 +1,25 @@ +#Js DOM can access any elements on web page just like how selenium does +# selenium have a method to execute javascript code in it + +from selenium import webdriver + + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.get("https://rahulshettyacademy.com/angularpractice/") +driver.find_element_by_name("name").send_keys("hello") +print(driver.find_element_by_name("name").text) +print(driver.find_element_by_name("name").get_attribute("value")) +print(driver.execute_script('return document.getElementsByName("name")[0].value')) + +shopButton = driver.find_element_by_css_selector("a[href*='shop']") +driver.execute_script("arguments[0].click();",shopButton) + +driver.execute_script("window.scrollTo(0,document.body.scrollHeight);") + + + + + + + + diff --git a/code-Part1/locators.py b/code-Part1/locators.py new file mode 100644 index 0000000..82054c2 --- /dev/null +++ b/code-Part1/locators.py @@ -0,0 +1,23 @@ +from selenium import webdriver +from selenium.webdriver.support.select import Select + +#driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe") +driver.get("https://rahulshettyacademy.com/angularpractice/") + +#driver.find_element_by_name("name").send_keys("Rahul") +driver.find_element_by_css_selector("input[name='name']").send_keys("Rahul") +driver.find_element_by_name("email").send_keys("Shetty") + +driver.find_element_by_id("exampleCheck1").click() + +#select class provide the methods to handle the options in dropdown +dropdown = Select(driver.find_element_by_id("exampleFormControlSelect1")) +dropdown.select_by_visible_text("Female") +dropdown.select_by_index(0) + +driver.find_element_by_xpath("//input[@type='submit']").click() + +message = driver.find_element_by_class_name("alert-success").text + +assert "success" in message \ No newline at end of file diff --git a/code-Part1/locatorsExtension.py b/code-Part1/locatorsExtension.py new file mode 100644 index 0000000..cd35793 --- /dev/null +++ b/code-Part1/locatorsExtension.py @@ -0,0 +1,17 @@ +from selenium import webdriver + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.get("https://login.salesforce.com/") +driver.find_element_by_css_selector("#username").send_keys("Rahul") +driver.find_element_by_css_selector(".password").send_keys("shetty") +driver.find_element_by_css_selector(".password").clear() +driver.find_element_by_link_text("Forgot Your Password?").click() +#//tagname[text()=’xxx’] +driver.find_element_by_xpath("//a[text()='Cancel']").click() +print(driver.find_element_by_xpath("//form[@name='login']/div[1]/label").text) +print(driver.find_element_by_css_selector("form[name='login'] label:nth-child(3)").text) + + + + + diff --git a/code-Part1/pytestsDemo.zip b/code-Part1/pytestsDemo.zip new file mode 100644 index 0000000..a5727af Binary files /dev/null and b/code-Part1/pytestsDemo.zip differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/BaseClass.py b/code-Part1/pytestsDemo/pytestsDemo/BaseClass.py new file mode 100644 index 0000000..4d2031e --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/BaseClass.py @@ -0,0 +1,18 @@ +import inspect +import logging + + +class BaseClass: + def getLogger(self): + loggerName = inspect.stack()[1][3] + logger = logging.getLogger(loggerName) + fileHandler = logging.FileHandler('logfile.log') + formatter = logging.Formatter("%(asctime)s :%(levelname)s : %(name)s :%(message)s") + fileHandler.setFormatter(formatter) + + logger.addHandler(fileHandler) # filehandler object + + logger.setLevel(logging.DEBUG) + return logger + + diff --git a/code-Part1/pytestsDemo/pytestsDemo/__init__.py b/code-Part1/pytestsDemo/pytestsDemo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/BaseClass.cpython-37.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/BaseClass.cpython-37.pyc new file mode 100644 index 0000000..e03a5d0 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/BaseClass.cpython-37.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/__init__.cpython-37.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..49a1bc4 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/__init__.cpython-37.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/conftest.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/conftest.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..797c141 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/conftest.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo1.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo1.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..e184f32 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo1.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo2.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo2.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..a316bcf Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_demo2.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixtureDemo.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixtureDemo.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..21378a8 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixtureDemo.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesData.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesData.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..3bbc089 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesData.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesDemo.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesDemo.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..e39299b Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_fixturesDemo.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_logging.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_logging.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..0dc814b Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_logging.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_reportdemo.cpython-37-pytest-5.2.1.pyc b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_reportdemo.cpython-37-pytest-5.2.1.pyc new file mode 100644 index 0000000..28aaca7 Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/__pycache__/test_reportdemo.cpython-37-pytest-5.2.1.pyc differ diff --git a/code-Part1/pytestsDemo/pytestsDemo/assets/style.css b/code-Part1/pytestsDemo/pytestsDemo/assets/style.css new file mode 100644 index 0000000..f926197 --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/assets/style.css @@ -0,0 +1,163 @@ +body { + font-family: Helvetica, Arial, sans-serif; + font-size: 12px; + min-width: 1200px; + color: #999; +} + +h1 { + font-size: 24px; + color: black; +} + +h2 { + font-size: 16px; + color: black; +} + +p { + color: black; +} + +a { + color: #999; +} + +table { + border-collapse: collapse; +} + +/****************************** + * SUMMARY INFORMATION + ******************************/ + +#environment td { + padding: 5px; + border: 1px solid #E6E6E6; +} + +#environment tr:nth-child(odd) { + background-color: #f6f6f6; +} + +/****************************** + * TEST RESULT COLORS + ******************************/ +span.passed, .passed .col-result { + color: green; +} +span.skipped, span.xfailed, span.rerun, .skipped .col-result, .xfailed .col-result, .rerun .col-result { + color: orange; +} +span.error, span.failed, span.xpassed, .error .col-result, .failed .col-result, .xpassed .col-result { + color: red; +} + + +/****************************** + * RESULTS TABLE + * + * 1. Table Layout + * 2. Extra + * 3. Sorting items + * + ******************************/ + +/*------------------ + * 1. Table Layout + *------------------*/ + +#results-table { + border: 1px solid #e6e6e6; + color: #999; + font-size: 12px; + width: 100% +} + +#results-table th, #results-table td { + padding: 5px; + border: 1px solid #E6E6E6; + text-align: left +} +#results-table th { + font-weight: bold +} + +/*------------------ + * 2. Extra + *------------------*/ + +.log:only-child { + height: inherit +} +.log { + background-color: #e6e6e6; + border: 1px solid #e6e6e6; + color: black; + display: block; + font-family: "Courier New", Courier, monospace; + height: 230px; + overflow-y: scroll; + padding: 5px; + white-space: pre-wrap +} +div.image { + border: 1px solid #e6e6e6; + float: right; + height: 240px; + margin-left: 5px; + overflow: hidden; + width: 320px +} +div.image img { + width: 320px +} +.collapsed { + display: none; +} +.expander::after { + content: " (show details)"; + color: #BBB; + font-style: italic; + cursor: pointer; +} +.collapser::after { + content: " (hide details)"; + color: #BBB; + font-style: italic; + cursor: pointer; +} + +/*------------------ + * 3. Sorting items + *------------------*/ +.sortable { + cursor: pointer; +} + +.sort-icon { + font-size: 0px; + float: left; + margin-right: 5px; + margin-top: 5px; + /*triangle*/ + width: 0; + height: 0; + border-left: 8px solid transparent; + border-right: 8px solid transparent; +} + +.inactive .sort-icon { + /*finish triangle*/ + border-top: 8px solid #E6E6E6; +} + +.asc.active .sort-icon { + /*finish triangle*/ + border-bottom: 8px solid #999; +} + +.desc.active .sort-icon { + /*finish triangle*/ + border-top: 8px solid #999; +} diff --git a/code-Part1/pytestsDemo/pytestsDemo/conftest.py b/code-Part1/pytestsDemo/pytestsDemo/conftest.py new file mode 100644 index 0000000..f5ac30d --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/conftest.py @@ -0,0 +1,19 @@ +import pytest + + +@pytest.fixture(scope="class") +def setup(): + print("I will be executing first") + yield + print(" I will execute last") + + +@pytest.fixture() +def dataLoad(): + print("user profile data is being created") + return ["Rahul","Shetty","rahulshettyacademy.com"] + + +@pytest.fixture(params=[("chrome","Rahul","shetty"), ("Firefox","shetty"), ("IE","SS")]) +def crossBrowser(request): + return request.param diff --git a/code-Part1/pytestsDemo/pytestsDemo/logfile.log b/code-Part1/pytestsDemo/pytestsDemo/logfile.log new file mode 100644 index 0000000..b5be87e --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/logfile.log @@ -0,0 +1,7 @@ +2019-10-27 17:01:54,259 :INFO : pytestsDemo.BaseClass :Rahul +2019-10-27 17:01:54,264 :INFO : pytestsDemo.BaseClass :rahulshettyacademy.com +2019-10-27 17:09:20,863 :INFO : test_editProfile :Rahul +2019-10-27 17:09:20,863 :INFO : test_editProfile :rahulshettyacademy.com +2019-10-27 17:11:11,713 :INFO : test_editProfile :Rahul +2019-10-27 17:11:11,713 :INFO : test_editProfile :rahulshettyacademy.com +2019-10-27 17:11:11,737 :CRITICAL : pytestsDemo.test_logging :Critical issue diff --git a/code-Part1/pytestsDemo/pytestsDemo/report.html b/code-Part1/pytestsDemo/pytestsDemo/report.html new file mode 100644 index 0000000..fab54b0 --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/report.html @@ -0,0 +1,284 @@ + + + + + Test Report + + + +

report.html

+

Report generated on 31-Oct-2019 at 18:17:52 by pytest-html v2.0.0

+

Environment

+ + + + + + + + + + + + + + + +
JAVA_HOMEC:\Program Files\Java\jdk1.8.0_211
Packages{'pytest': '5.2.1', 'py': '1.8.0', 'pluggy': '0.13.0'}
PlatformWindows-10-10.0.17763-SP0
Plugins{'html': '2.0.0', 'metadata': '1.8.0'}
Python3.7.4
+

Summary

+

1 tests ran in 4.27 seconds.

+ 0 passed, 0 skipped, 1 failed, 0 errors, 0 expected failures, 0 unexpected passes +

Results

+ + + + + + + + + + + + + + + + +
ResultTestDurationLinks
Failedtest_reportdemo.py::test_screenshot_on_test_failure1.54
+
screenshot
+
browser = <selenium.webdriver.chrome.webdriver.WebDriver (session="b6c20dc6275c03e764605d5e0e03700c")>

def test_screenshot_on_test_failure(browser):
# driver = webdriver.Firefox()
browser.get("https://google.com")
> assert 2 ==3
E assert 2 == 3

test_reportdemo.py:4: AssertionError
\ No newline at end of file diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_demo1.py b/code-Part1/pytestsDemo/pytestsDemo/test_demo1.py new file mode 100644 index 0000000..8bcbfec --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_demo1.py @@ -0,0 +1,26 @@ +# Any pytest file should start with test_ or end with _test +#pytest method names should start with test +#Any code should be wrapped in method only +import pytest + + + +@pytest.mark.smoke +def test_firstProgram(setup): + print("Hello") + + +@pytest.mark.xfail +def test_SecondGreetCreditCard(): + print("Good Morning") + + +def test_crossBrowser(crossBrowser): + print(crossBrowser[1]) + + + + + + + diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_demo2.py b/code-Part1/pytestsDemo/pytestsDemo/test_demo2.py new file mode 100644 index 0000000..9bfd84c --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_demo2.py @@ -0,0 +1,40 @@ +# Any pytest file should start with test_ or end with _test +#pytest method names should start with test +#Any code should be wrapped in method only +#Method name should have sense +# -k stands for method names execution, -s logs in out put -v stands for more info metadata +#you can run specific file with py.test +# you can mark (tag) tests @pytest.mark.smoke and then run with -m +#you can skip tests with @pytest.mark.skip +#@pytest.mark.xfail +#fixtures are used as setup and tear down methods for test cases- conftest file to generalize fixt +#fixture and make it available to all test cases (fixture name into parameters of method) +# datadriven and parameterization can be done with return statements in tuple format +#when you define fixture scope to class only, it will run once before class is initiated and at the end + + +import pytest + + +@pytest.mark.smoke +#@pytest.mark.skip +def test_firstProgram(): + msg = "Hello" #operations + assert msg == "Hi", "Test failed because strings do not match" + + + +def test_SecondCreditCard(): + a = 4 + b = 6 + assert a+2 == 6, "Addition do not match" + + + + + + + + + + diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_fixturesData.py b/code-Part1/pytestsDemo/pytestsDemo/test_fixturesData.py new file mode 100644 index 0000000..a8343b4 --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_fixturesData.py @@ -0,0 +1,17 @@ +import pytest + +from pytestsDemo.BaseClass import BaseClass + + +@pytest.mark.usefixtures("dataLoad") +class TestExample2(BaseClass): + + def test_editProfile(self, dataLoad): + log = self.getLogger() + log.info(dataLoad[0]) + log.info(dataLoad[2]) + print(dataLoad[2]) + + + + diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_fixturesDemo.py b/code-Part1/pytestsDemo/pytestsDemo/test_fixturesDemo.py new file mode 100644 index 0000000..e057314 --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_fixturesDemo.py @@ -0,0 +1,17 @@ +import pytest + + +@pytest.mark.usefixtures("setup") +class TestExample: + + def test_fixtureDemo(self): + print("i will execute steps in fixtureDemo method") + + def test_fixtureDemo1(self): + print("i will execute steps in fixtureDemo1 method") + + def test_fixtureDemo2(self): + print("i will execute steps in fixtureDemo2 method") + + def test_fixtureDemo3(self): + print("i will execute steps in fixtureDemo3 method") \ No newline at end of file diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_logging.py b/code-Part1/pytestsDemo/pytestsDemo/test_logging.py new file mode 100644 index 0000000..7131cf5 --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_logging.py @@ -0,0 +1,22 @@ +import logging + + +def test_loggingDemo(): + logger = logging.getLogger(__name__) + + fileHandler = logging.FileHandler('logfile.log') + formatter = logging.Formatter("%(asctime)s :%(levelname)s : %(name)s :%(message)s") + fileHandler.setFormatter(formatter) + + logger.addHandler(fileHandler) #filehandler object + + logger.setLevel(logging.CRITICAL) + logger.debug("A debug statement is executed") + logger.info("Information statement") + logger.debug("A debug statement is executed") + logger.warning("Something is in warning mode") + logger.error("A Major error has happend") + logger.critical("Critical issue") + + + diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py b/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py new file mode 100644 index 0000000..e41d0fa --- /dev/null +++ b/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py @@ -0,0 +1,4 @@ +def test_screenshot_on_test_failure(browser): + # driver = webdriver.Firefox() + browser.get("https://google.com") + assert 2 ==3 \ No newline at end of file diff --git a/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py_test_screenshot_on_test_failure.png b/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py_test_screenshot_on_test_failure.png new file mode 100644 index 0000000..ac1b83f Binary files /dev/null and b/code-Part1/pytestsDemo/pytestsDemo/test_reportdemo.py_test_screenshot_on_test_failure.png differ diff --git a/code-Part1/uiControls.py b/code-Part1/uiControls.py new file mode 100644 index 0000000..5a50765 --- /dev/null +++ b/code-Part1/uiControls.py @@ -0,0 +1,28 @@ +from selenium import webdriver + +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.get("https://rahulshettyacademy.com/AutomationPractice/") + +checkboxes = driver.find_elements_by_xpath("//input[@type='checkbox']") + +print(len(checkboxes)) + +for checkbox in checkboxes: + if checkbox.get_attribute("value") == "option2": + checkbox.click() + assert checkbox.is_selected() + +radiobuttons = driver.find_elements_by_name("radioButton") +radiobuttons[2].click() +assert radiobuttons[2].is_selected() + + +assert driver.find_element_by_id("displayed-text").is_displayed() + +driver.find_element_by_id("hide-textbox").click() + +assert not driver.find_element_by_id("displayed-text").is_displayed() + + + + diff --git a/code-Part1/waitDemo.py b/code-Part1/waitDemo.py new file mode 100644 index 0000000..a8e16d7 --- /dev/null +++ b/code-Part1/waitDemo.py @@ -0,0 +1,30 @@ +#Implicit wait - +#Explicit Wait +import time + +from selenium import webdriver +#pause the test for few seconds using Time class +driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe") +driver.implicitly_wait(5) +# wait until 5 seconds if object is not displayed +#Global wait +#1.5 second to reach next page- execution will resume in 1.5 seconds +#if object do not show up at all, then max time your test waits for 5 seconds +driver.get("https://rahulshettyacademy.com/seleniumPractise/") +driver.find_element_by_css_selector("input.search-keyword").send_keys("ber") +time.sleep(4) +count =len(driver.find_elements_by_xpath("//div[@class='products']/div")) +assert count == 3 +buttons = driver.find_elements_by_xpath("//div[@class='product-action']/button") + +for button in buttons: + button.click() + +driver.find_element_by_css_selector("img[alt='Cart']").click() +driver.find_element_by_xpath("//button[text()='PROCEED TO CHECKOUT']").click() +driver.find_element_by_class_name("promoCode").send_keys("rahulshettyacademy") +driver.find_element_by_css_selector(".promoBtn").click() +print(driver.find_element_by_css_selector("span.promoInfo").text) + + + diff --git a/locators b/locators new file mode 100644 index 0000000..ca409db --- /dev/null +++ b/locators @@ -0,0 +1,34 @@ +from selenium import webdriver +import time +from selenium.webdriver.common.keys import Keys +from soupsieve import select +from selenium.webdriver.support.select import Select +from selenium.webdriver.common.by import By + +PATH = 'C:\Program Files (x86)\chromedriver.exe' +driver = webdriver.Chrome(PATH) +#driver.get("https://www.animezone.pl/anime/filmy") +driver.get("https://login.salesforce.com/") +driver.get("https://rahulshettyacademy.com/angularpractice/") +time.sleep(2) +#driver.find_element_by_xpath("//i[@class='fa fa-home']").click() #xpath samemu napisany +#driver.find_element_by_css_selector("i[class='fa fa-home']").click() #css selector +#print (driver.find_element_by_css_selector("i[class='fa fa-home']").text) # wyświetli text jaki posiada element +#driver.find_element_by_css_selector(".form-control").send_keys('xd') # szukanie po classname poprzedamy kropka, a po id hasem +#print(driver.find_element_by_css_selector(".alert-danger").text) +#driver.find_element_by_xpath("//a[text()='Zapomniałem hasła']").click() +#driver.find_element_by_xpath("//div[@id='usernamegroup']/label").send_keys("x") +#driver.find_element_by_css_selector("div[id='usernamegroup'] label").send_keys("x")) + +#print(driver.find_element_by_xpath("//form[@name='login']/div[1]/label").text) + +dropdown = Select(driver.find_element(By.ID,"exampleFormControlSelect1")) +dropdown.select_by_visible_text("Female") +dropdown.select_by_index(0) + +pomoc w wyszukiwaniu elementów w konsoli: +document.querySelectorAll('.nazwa-klasy') - daje mi wszystkie elementy które to spełniają +document.querySelector('.nazwa-klasy') - daje mi 1 element na stronie jaki znajdzie + + +VISIBLE TEXT!!! diff --git a/lunchin bat file b/lunchin bat file new file mode 100644 index 0000000..96b4723 --- /dev/null +++ b/lunchin bat file @@ -0,0 +1,20 @@ +import os +os.system(r"D:\Pyt\regresja\FileBackUp\FileGen\GenerateProject 0") <--- 0 to argument + + +/////////////////////////////////////// + +import subprocess + +filepath=r"D:\test\hello" +p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE) + +stdout, stderr = p.communicate() +print (p.returncode) # is 0 if success + + +///////////////////////////////////////// + +from subprocess import Popen +p = Popen("batchfile.bat", cwd=r"D:\test\hello") +stdout, stderr = p.communicate() diff --git a/main.py b/main.py new file mode 100644 index 0000000..bf8b9e5 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +# This is a sample Python script. + +# Press Shift+F10 to execute it or replace it with your code. +# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. + + +def print_hi(name): + # Use a breakpoint in the code line below to debug your script. + print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print_hi('PyCharm') + +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ diff --git a/pageObjects/CheckoutPage.py b/pageObjects/CheckoutPage.py new file mode 100644 index 0000000..22f5a08 --- /dev/null +++ b/pageObjects/CheckoutPage.py @@ -0,0 +1,19 @@ +from selenium.webdriver.common.by import By + +class CheckOutPage: + + cardTitle = (By.CSS_SELECTOR, ".card-title a") + cardFooter = (By.CSS_SELECTOR,".card-footer button") + checkout = (By.CSS_SELECTOR,"a[class*='btn-primary']") + + def __init__(self,driver): + self.driver=driver + + def getCardTitles(self): + return self.driver.find_elements(*CheckOutPage.cardTitle) + + def getCardFooter(self): + return self.driver.find_elements(*CheckOutPage.cardFooter) + + def Checkout(self): + return self.driver.find_element(*CheckOutPage.checkout) \ No newline at end of file diff --git a/pageObjects/ConfirmPage.py b/pageObjects/ConfirmPage.py new file mode 100644 index 0000000..e69de29 diff --git a/pageObjects/HomePage.py b/pageObjects/HomePage.py new file mode 100644 index 0000000..dd64980 --- /dev/null +++ b/pageObjects/HomePage.py @@ -0,0 +1,15 @@ +from selenium.webdriver.common.by import By +from pageObjects.CheckoutPage import CheckOutPage + +class HomePage: + + shop = (By.CSS_SELECTOR, "a[href*='shop']") + + def __init__(self,driver): + self.driver = driver + + + def shopItem(self): + self.driver.find_element(*HomePage.shop).click() + checkOutPage = CheckOutPage(self.driver) + return checkOutPage \ No newline at end of file diff --git a/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc b/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc new file mode 100644 index 0000000..812fb8c Binary files /dev/null and b/pageObjects/__pycache__/CheckoutPage.cpython-310.pyc differ diff --git a/pageObjects/__pycache__/HomePage.cpython-310.pyc b/pageObjects/__pycache__/HomePage.cpython-310.pyc new file mode 100644 index 0000000..9f123b6 Binary files /dev/null and b/pageObjects/__pycache__/HomePage.cpython-310.pyc differ diff --git a/regresja/from selenium import webdriver.py b/regresja/from selenium import webdriver.py new file mode 100644 index 0000000..a26d415 --- /dev/null +++ b/regresja/from selenium import webdriver.py @@ -0,0 +1,57 @@ +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +import time + +###############TEST 1 - Logowanie #################### +try: + PATH = "D:\chromedriver.exe" + driver = webdriver.Chrome(PATH) # or ...Chrome(executable_path=sciezka) + driver.get("http://localhost:28558/") + driver.maximize_window() + time.sleep(2) + log = driver.find_element_by_name('login') + log.send_keys('m.stasiak@xopero.com') + + pas = driver.find_element_by_id('mat-input-1') + pas.send_keys('Admin_123') + + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/main/div/app-auth/div/app-auth-login/div/form/app-save-button/button').click() + time.sleep(1) + title = driver.current_url + if title == 'http://localhost:28558/devices': + print ("Test 1 - Logowanie: Pass") + else: + print("Test 1 - Logowanie: Failed") +except: + print("Test 1 - Logowanie: Failed") + +#################Test 2 - Dodawanie urządzenia############# +try: + if driver.find_element_by_id("mat-badge-content-0").is_displayed(): + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[2]/button[1]').click() + time.sleep(1) + driver.find_element_by_xpath('//*[@id="mat-checkbox-2"]/label/span[1]').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-activate-devices-table/div/div[4]/app-save-button/button/span[1]').click() + time.sleep(1) + driver.find_element_by_xpath('//app-license[2]/p').click() + driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-licenses-list/div/div[4]/app-save-button/button/span[1]/span').click() + print('Test 2 - Dodawanie urządzenia: Pass') + else: + print('Test 2 - Dodawanie urządzenia: Pass(Brak urządzeń do dodania)') +except: + print('Test 2 - Dodawanie urządzenia: Failed') + + +##############Test 3 - Dodawanie magazynu lokalnego########## + +driver.find_element_by_xpath('/html/body/app-root/app-main/app-menu/section/nav[1]/a[6]').click() +driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-toolbar-container/app-toolbar/mat-toolbar/mat-toolbar-row/div[1]/ng-component/button/span[1]').click() +driver.find_element_by_xpath('/html/body/app-root/app-main/div/app-content/div[1]/aside/app-aside/ng-component/app-storage/div/mat-form-field').find_element_by_xpath('//*[@id="mat-input-3"]').click() +# pwd_ele = driver.find_element_by_xpath('//*[@id="mat-input-3"]') +# print(pwd_ele.is_displayed()) #return true/false based on element status +# print(pwd_ele.is_enabled()) +# pwd_ele.click() + + +time.sleep(2) +#driver.close() \ No newline at end of file diff --git a/sciezka restora.py b/sciezka restora.py new file mode 100644 index 0000000..14a0002 --- /dev/null +++ b/sciezka restora.py @@ -0,0 +1,146 @@ +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.by import By +from selenium.webdriver.support.relative_locator import locate_with +from selenium.webdriver.common.action_chains import ActionChains +import time + +PATH = "D:\chromedriver.exe" +driver = webdriver.Chrome(PATH) # or ...Chrome(executable_path=sciezka) + +###############TEST 1 - Logowanie #################### +def logowanie(): + try: + driver.get("http://localhost:28555") # <-- url usługi + driver.maximize_window() + time.sleep(2) + + + log = driver.find_element(By.NAME,'login') + log.send_keys('admin@xopero.com') # <-- login + time.sleep(1) + + pas = driver.find_element(By.ID,'mat-input-1') + pas.send_keys("Admin_123") #<-- hasło + + driver.find_element(By.XPATH,"//button[@type='submit']").click() + time.sleep(1) + title = driver.current_url + + if title == 'http://localhost:28555/devices': + print ("Test 1 - Logowanie: Pass") + return + + else: + print("Test 1 - Logowanie: Failed") + return + + except: + print("Test 1 - Logowanie: Failed") + exit() + + +def kontrolaZadania(): + try: + time.sleep(1) + print(" Zadanie w trakcie wykonywania") + x = True + + while x: + if driver.find_element(By.XPATH,'//*[@id="mat-badge-content-7"]').is_displayed(): + time.sleep(5) + else: + x = False + + try: + driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[2]/aside/app-aside/ng-component/app-dashboard-plan/div/div[1]/app-close-aside-button/button').click() + except: + pass + + print(" Zakończono zadanie") + return + except: + return + + +def podsumowanie(): + try: + driver.find_element(By.XPATH,"//*[contains(text(),'Tasks')]").click() #wybór zadań + driver.find_element(By.XPATH,"//*[contains(text(),'Last 24 hours')]").click() #wybór wykonanych zadań + + ########################################## + OK = driver.find_element(By.XPATH,"//span[text()='OK']") + Success = driver.find_element(locate_with(By.CLASS_NAME, "count").above(OK)).text + + warning = driver.find_element(By.XPATH,"//span[text()='warnings']") + warnResult = driver.find_element(locate_with(By.CLASS_NAME, "count").above(warning)).text + + NOK = driver.find_element(By.XPATH,"//span[text()='errors']") + errors = driver.find_element(locate_with(By.CLASS_NAME, "count").above(NOK)).text + + print(" Podsumowanie wykonania zadania: Pass") + print(" Pomyślnie zakończono %s zadań" %(Success)) + print(" Ostrzeżeniami zakończono %s zadań " %(warnResult)) + print(" Błędami zakończono %s zadań" %(errors)) + + except: + print("Podsumowanie wykonania zadania: Failed") + return + +def fileBackupCLD(): + driver.implicitly_wait(5) + driver.find_element(By.XPATH,"//*[contains(text(),'Plans')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Add plan')]").click() + + driver.find_element(By.NAME,"backupPlanName").clear() + driver.find_element(By.NAME,"backupPlanName").send_keys("File backup on Cloud") + + driver.find_element(By.XPATH,"//*[contains(text(),'How to protect')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'File-level')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Which devices?')]").click() + + mainDevice = driver.find_element(By.XPATH,"//span[text()='Main']/../../..") + mainDevice.find_element(By.CLASS_NAME, "mat-checkbox").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'What to protect?')]").click() + + driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-rule/div/div[3]/div[2]/div[2]/div/h3').click() + + + folderTree = driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-add-device-rule/div/div[2]/app-files-browser/app-files/ul") + y = R"D:\pliki\jsony jira" ##<--- wstaw ścieżkę backupu + y=y.replace(":","") + backupPath = y.split("\\") + fileName = backupPath.pop(-1) + + for folder in backupPath: + folderName = folderTree.find_element(By.XPATH,"//span[text()='%s']/../.." %(folder)) + folderName.find_element(By.CSS_SELECTOR,"svg[data-icon='plus']").click() + + fileNameElem = folderTree.find_element(By.XPATH,"//*[contains(text(),'%s')]" %(fileName)) + driver.find_element(locate_with(By.CLASS_NAME, "mat-checkbox-layout").to_left_of(fileNameElem)).click() + + driver.find_element(By.XPATH,"/html/body/app-root/app-main/div/app-content/div[1]/aside[3]/app-aside/ng-component/app-add-device-rule/div/div[3]/button/span[1]").click() + driver.find_element(By.XPATH,"//*[contains(text(),'Apply')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Where to store?')]").click() + time.sleep(1) + driver.find_element(By.XPATH,"//*[contains(text(),'Xopero Storage')]").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'When?')]").click() + startAt = driver.find_element(By.XPATH,'/html/body/app-root/app-main/div/app-content/div[1]/aside[2]/app-aside/ng-component/app-add-schedule/form/div[3]/div/mat-accordion/mat-expansion-panel[1]/div/div/app-monthly/div/mat-radio-group/div/div[2]/app-time/mat-form-field/div/div[1]/div/input') + startAt.send_keys('1111') + driver.find_element(By.XPATH,"//*[contains(text(),'Next')]").click() + driver.find_element(By.XPATH,"//button[@type='submit']").click() + + driver.find_element(By.XPATH,"//*[contains(text(),'Save&Run')]").click() + + # kontrolaZadania() + # podsumowanie() + + return() + +logowanie() +fileBackupCLD() + diff --git a/utilities/BaseClass.py b/utilities/BaseClass.py new file mode 100644 index 0000000..f1d01a5 --- /dev/null +++ b/utilities/BaseClass.py @@ -0,0 +1,12 @@ +import pytest +from selenium.webdriver.common.by import By +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +@pytest.mark.usefixtures("setupBrowser") + +class BaseClass: + + def verifyLinkPresence(self,text): + element = WebDriverWait(self.driver, 10).until( + EC.presence_of_element_located((By.LINK_TEXT, text))) diff --git a/utilities/__pycache__/BaseClass.cpython-310.pyc b/utilities/__pycache__/BaseClass.cpython-310.pyc new file mode 100644 index 0000000..2df4f53 Binary files /dev/null and b/utilities/__pycache__/BaseClass.cpython-310.pyc differ diff --git a/utilities/__pycache__/BaseClass.cpython-39.pyc b/utilities/__pycache__/BaseClass.cpython-39.pyc new file mode 100644 index 0000000..c875105 Binary files /dev/null and b/utilities/__pycache__/BaseClass.cpython-39.pyc differ