updated to work again with instructions

This commit is contained in:
Roxie Gibson 2021-10-20 13:57:23 +01:00
parent 90e1d6e119
commit b393d818c9
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D
8 changed files with 47 additions and 9 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ geckodriver.log
*.lock *.lock
.vscode .vscode
*.pyc *.pyc
*__pycache__ *__pycache__
C:\selenum\ChromeProfileh

View File

@ -8,6 +8,7 @@ selenium = "*"
requests = "*" requests = "*"
rich = "*" rich = "*"
"pdfminer.six" = "*" "pdfminer.six" = "*"
webdrivermanager = "*"
[dev-packages] [dev-packages]
pylint = "*" pylint = "*"

30
README.md Normal file
View File

@ -0,0 +1,30 @@
# civicrm-update-tester
## install
Requires pipenv, venv, pip, and python 3.
```
python3 -m venv .venv
source .venv/bin/activate
pipenv install
webdrivermanager chrome # installs chrome driver
```
## running
### args
```
- -u --user <user>: username to login with
- -p --pass <pass>: password of account
- -D --dev: doesn't work anymore, both URLS point to staging server
- -s --show-browser: runs in non-headless mode to show whats happening
```
```sh
$ python3 main.py -u roxie -p "hunter2" -s
```
## what is the layout of this
the civicrm_tester folder has files which contain classes. One for each test. The tests inherit the BaseTester class which has basic commands (login, logout, creating the browser, logging helpers, etc.) and access to the selenium browser. This will hopefully allow for the choosing of what tests to run. Atm, main.py just runs all three current tests synchronously.

View File

@ -59,6 +59,7 @@ class ActivitiesTab(BaseTester):
Using MP's as MP's are public knowledge and often have activities within the crm system Using MP's as MP's are public knowledge and often have activities within the crm system
names provided in comments here for debugging purposes names provided in comments here for debugging purposes
""" """
# There where originally MP's but this seems to have changes to just random people. Still works fine but it is weird
cid_da = "42219" # Debbie Abrahams cid_da = "42219" # Debbie Abrahams
cid_kh = "82163" # Kate Hollern cid_kh = "82163" # Kate Hollern
cid_na = "42269" # Nigel Addams cid_na = "42269" # Nigel Addams

View File

@ -35,13 +35,13 @@ class BaseTester:
self.user = user self.user = user
self.passwd = passwd self.passwd = passwd
if dev: if dev:
self.base_url = "https://crm-dev.caat.org.uk" self.base_url = "https://crm.staging.caat.org.uk"
else: else:
self.base_url = "https://crm.caat.org.uk" self.base_url = "https://crm.staging.caat.org.uk"
firefox_options = webdriver.FirefoxOptions() firefox_options = webdriver.ChromeOptions()
firefox_options.headless = not show_browser firefox_options.headless = not show_browser
self.browser = webdriver.Firefox(options=firefox_options) self.browser = webdriver.Chrome(options=firefox_options)
self.wait = WebDriverWait(self.browser, 20) self.wait = WebDriverWait(self.browser, 20)
def debug(self, msg: str): def debug(self, msg: str):

View File

@ -14,7 +14,9 @@ class ContactExport(SearchExportTester):
self.desc( self.desc(
"Testing if exporting contacts from a search returns a CSV file with all expected contacts." "Testing if exporting contacts from a search returns a CSV file with all expected contacts."
) )
self.contact_exportoption_id = "select2-result-label-15" # FIXME: THIS FUCKING CHANGES!!!!!!
# If you are having issues with the tests, go back and try and find the id for the item in the drop down. its all stupid js so we have to hack it like this and press it instead of post request
self.contact_exportoption_id = "select2-result-label-13"
def download_csv(self): def download_csv(self):
# Data of the request that is specific for this export and not generic like qr_key # Data of the request that is specific for this export and not generic like qr_key
@ -78,5 +80,5 @@ class ContactExport(SearchExportTester):
def test_hardcoded_search_terms(self): def test_hardcoded_search_terms(self):
"""Loops over the test with three hardcoded search terms""" """Loops over the test with three hardcoded search terms"""
search_terms = ("John", "e", "Smith") search_terms = ("John", "Jane", "Smith")
self._test_all(search_terms) self._test_all(search_terms)

View File

@ -16,7 +16,10 @@ class SteeringCommitteePrintLabels(SearchExportTester):
) )
self.group_dropdown = "s2id_autogen2" self.group_dropdown = "s2id_autogen2"
self.search_button = "_qf_Basic_refresh" self.search_button = "_qf_Basic_refresh"
self.mail_label_option = "select2-result-label-19" # FIXME: THIS FUCKING CHANGES!!!!!!
# If you are having issues with the tests, go back and try and find the id for the item in the drop down. its all stupid js so we have to hack it like this and press it instead of post request
# Even in the post requests, actions are given IDs instead. Which change apparently!!!!! WTFFF!!!
self.mail_label_option = "select2-result-label-17"
# Using this to count amount of people in the exported pdf # Using this to count amount of people in the exported pdf
# This will fail if someone is added that doesn't have a UK adddress # This will fail if someone is added that doesn't have a UK adddress
self.pdf_search_string = "UNITED KINGDOM" self.pdf_search_string = "UNITED KINGDOM"

View File

@ -21,7 +21,7 @@ if __name__ == "__main__":
help="Test dev site instead of production" help="Test dev site instead of production"
) )
parser.add_argument( parser.add_argument(
"--show_browser", "--show-browser",
"-s", "-s",
dest="show_browser", dest="show_browser",
action="store_true", action="store_true",