diff options
author | Swoichha Adhikari <swoichhaa@gmail.com> | 2021-05-11 14:12:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 14:12:06 +0300 |
commit | ea1f0d73e128182472bc2f42e926aa74d841e7da (patch) | |
tree | 167b1c312e2b37a9e9d6c5794f43f501765b6eed /test | |
parent | c6ea44894d05bc6b9466d2ed0983a7c206d7beb4 (diff) |
[tests-only]implement pageObject model (#8606)
Diffstat (limited to 'test')
-rw-r--r-- | test/gui/shared/scripts/helpers/SetupClientHelper.py | 26 | ||||
-rw-r--r-- | test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py | 35 | ||||
-rw-r--r-- | test/gui/shared/steps/steps.py | 46 |
3 files changed, 68 insertions, 39 deletions
diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py new file mode 100644 index 000000000..d9fb5a95d --- /dev/null +++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py @@ -0,0 +1,26 @@ +from urllib.parse import urlparse + +def substituteInLineCodes(context, value): + value = value.replace('%local_server%', context.userData['localBackendUrl']) + value = value.replace('%client_sync_path%', context.userData['clientSyncPath']) + value = value.replace('%local_server_hostname%', urlparse(context.userData['localBackendUrl']).netloc) + + return value + + +def getClientDetails(context): + for row in context.table[0:]: + row[1] = substituteInLineCodes(context, row[1]) + if row[0] == 'server': + server = row[1] + elif row[0] == 'user': + user = row[1] + elif row[0] == 'password': + password = row[1] + elif row[0] == 'localfolder': + localfolder = row[1] + try: + os.makedirs(localfolder, 0o0755) + except: + pass + return server, user, password, localfolder
\ No newline at end of file diff --git a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py new file mode 100644 index 000000000..41a2905ba --- /dev/null +++ b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py @@ -0,0 +1,35 @@ +import names +import squish +from helpers.SetupClientHelper import getClientDetails + + +class AccountConnectionWizard(): + SERVER_ADDRESS_BOX = names.leUrl_OCC_PostfixLineEdit + NEXT_BUTTON = names.owncloudWizard_qt_passive_wizardbutton1_QPushButton + USERNAME_BOX = names.leUsername_QLineEdit + PASSWORD_BOX = names.lePassword_QLineEdit + SELECT_LOCAL_FOLDER = names.pbSelectLocalFolder_QPushButton + DIRECTORY_NAME_BOX = names.fileNameEdit_QLineEdit + CHOOSE_BUTTON = names.qFileDialog_Choose_QPushButton + CONNECT_BUTTON = names.owncloudWizard_qt_passive_wizardbutton1_QPushButton + + + def __init__(self): + pass + + def addAccount(self, context): + server, user, password, localfolder = getClientDetails(context) + + squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) + squish.type(squish.waitForObject(self.SERVER_ADDRESS_BOX), server) + squish.clickButton(squish.waitForObject(self.NEXT_BUTTON)) + squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) + squish.type(squish.waitForObject(self.USERNAME_BOX), user) + squish.type(squish.waitForObject(self.USERNAME_BOX), "<Tab>") + squish.type(squish.waitForObject(self.PASSWORD_BOX), password) + squish.clickButton(squish.waitForObject(self.NEXT_BUTTON)) + squish.clickButton(squish.waitForObject(self.SELECT_LOCAL_FOLDER)) + squish.mouseClick(squish.waitForObject(self.DIRECTORY_NAME_BOX)) + squish.type(squish.waitForObject(self.DIRECTORY_NAME_BOX), localfolder) + squish.clickButton(squish.waitForObject(self.CHOOSE_BUTTON)) + squish.clickButton(squish.waitForObject(self.CONNECT_BUTTON)) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index c813f8904..a1de3a97c 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -10,6 +10,9 @@ import json import datetime from objectmaphelper import RegularExpression +from pageObjects.AccountConnectionWizard import AccountConnectionWizard +from helpers.SetupClientHelper import substituteInLineCodes + # the script needs to use the system wide python # to switch from the built-in interpreter see https://kb.froglogic.com/squish/howto/using-external-python-interpreter-squish-6-6/ @@ -58,7 +61,8 @@ def hook(context): @When('the user adds the first account with') def step(context): - addAccount(context) + newAccount = AccountConnectionWizard() + newAccount.addAccount(context) @Then('an account should be displayed with the displayname |any| and host |any|') def step(context, displayname, host): @@ -149,37 +153,9 @@ def step(context): def step(context): clickButton(waitForObject(names.settings_settingsdialog_toolbutton_Add_account_QToolButton)) - addAccount(context) - -def addAccount(context): - for row in context.table[0:]: - row[1] = substituteInLineCodes(context, row[1]) - if row[0] == 'server': - server = row[1] - elif row[0] == 'user': - user = row[1] - elif row[0] == 'password': - password = row[1] - elif row[0] == 'localfolder': - localfolder = row[1] - try: - os.makedirs(localfolder, 0o0755) - except: - pass + newAccount = AccountConnectionWizard() + newAccount.addAccount(context) - mouseClick(waitForObject(names.leUrl_OCC_PostfixLineEdit), 0, 0, Qt.NoModifier, Qt.LeftButton) - type(waitForObject(names.leUrl_OCC_PostfixLineEdit), server) - clickButton(waitForObject(names.owncloudWizard_qt_passive_wizardbutton1_QPushButton)) - mouseClick(waitForObject(names.leUrl_OCC_PostfixLineEdit), 0, 0, Qt.NoModifier, Qt.LeftButton) - type(waitForObject(names.leUsername_QLineEdit), user) - type(waitForObject(names.leUsername_QLineEdit), "<Tab>") - type(waitForObject(names.lePassword_QLineEdit), password) - clickButton(waitForObject(names.owncloudWizard_qt_passive_wizardbutton1_QPushButton)) - clickButton(waitForObject(names.pbSelectLocalFolder_QPushButton)) - mouseClick(waitForObject(names.fileNameEdit_QLineEdit), 0, 0, Qt.NoModifier, Qt.LeftButton) - type(waitForObject(names.fileNameEdit_QLineEdit), localfolder) - clickButton(waitForObject(names.qFileDialog_Choose_QPushButton)) - clickButton(waitForObject(names.owncloudWizard_qt_passive_wizardbutton1_QPushButton)) def isItemSynced(type, itemName): if type != 'FILE' and type != 'FOLDER': @@ -207,14 +183,6 @@ def waitForFileToBeSynced(context, fileName): context.userData['clientSyncTimeout'] * 1000 ) -def substituteInLineCodes(context, value): - from urllib.parse import urlparse - value = value.replace('%local_server%', context.userData['localBackendUrl']) - value = value.replace('%client_sync_path%', context.userData['clientSyncPath']) - value = value.replace('%local_server_hostname%', urlparse(context.userData['localBackendUrl']).netloc) - - return value - def sanitizePath(path): return path.replace('//','/') |