Skip to content

DSP Macros

EarthchemAuthWindow

Bases: WebPage

Authentication window to use Earthchem as Backend

Source code in dsp/dsp_macros.py
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
class EarthchemAuthWindow(WebPage):
    """Authentication window to use Earthchem as Backend"""

    github_button = SiteElement(By.CSS_SELECTOR, '.social-signup .btn[href*="github"]')
    orcid_button = SiteElement(By.ID, "social-orcid")
    username = SiteElement(By.ID, "username")
    password = SiteElement(By.ID, "password")
    login_button = SiteElement(By.ID, "kc-login")
    authorize_czhub_button = SiteElement(By.CSS_SELECTOR, 'form button[value="yes"]')

    @classmethod
    def authorize_via_orcid(self, driver):
        self.orcid_button.click(driver)

    @classmethod
    def authorize_username_password(self, driver, username, password):
        self.username.inject_text(driver, username)
        self.password.inject_text(driver, password)
        self.login_button.click(driver)

EarthchemResourcePage

Bases: WebPage

Landing page for an ECL resource

Source code in dsp/dsp_macros.py
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
class EarthchemResourcePage(WebPage):
    """Landing page for an ECL resource"""

    logo = By.CSS_SELECTOR, "#navbarBrand"
    page_title = SiteElement(By.CSS_SELECTOR, "#page-title h1")
    resource_title = SiteElement(By.CSS_SELECTOR, "#title_display")
    login_orcid = SiteElement(
        By.XPATH, "//*[@id='connect-button' and contains(.,'ORCID')]/.."
    )

    @classmethod
    def get_title(self, driver):
        return self.resource_title.get_text(driver)

    @classmethod
    def authenticate_if_needed(self, driver):
        if "Login" in self.page_title.get_text(driver):
            self.login_orcid.click(driver)
            self.resource_title.wait_on_visibility(driver, REPO_LOAD)

EditEarthchemSubmission

Bases: SubmitHydroshare, GeneralEditSubmission

Page containing forms for editing existing submission with Earthchem backend

Source code in dsp/dsp_macros.py
1100
1101
1102
1103
class EditEarthchemSubmission(SubmitHydroshare, GeneralEditSubmission):
    """Page containing forms for editing existing submission with Earthchem backend"""

    pass

EditExternalSubmission

Bases: SubmitHydroshare, GeneralEditSubmission

Page containing forms for editing existing submission with Zenodo backend

Source code in dsp/dsp_macros.py
1057
1058
1059
1060
class EditExternalSubmission(SubmitHydroshare, GeneralEditSubmission):
    """Page containing forms for editing existing submission with Zenodo backend"""

    pass

EditHSSubmission

Bases: SubmitHydroshare, GeneralEditSubmission

Page containing forms for editing existing submission with Hydroshare backend

Source code in dsp/dsp_macros.py
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
class EditHSSubmission(SubmitHydroshare, GeneralEditSubmission):
    """Page containing forms for editing existing submission with Hydroshare backend"""

    @classmethod
    def get_keywords(self, driver):
        return self.get_v_multi_select_vals(
            driver, "BasicInformation", "Subjectkeywords"
        )

    @classmethod
    def check_keywords(self, driver, keywords=None):
        saved_keywords = self.get_keywords(driver)
        if isinstance(keywords, str):
            if keywords not in saved_keywords:
                return False
        else:
            if not all(elem in saved_keywords for elem in keywords):
                return False
        return True

EditZenodoSubmission

Bases: SubmitHydroshare, GeneralEditSubmission

Page containing forms for editing existing submission with Zenodo backend

Source code in dsp/dsp_macros.py
1063
1064
1065
1066
class EditZenodoSubmission(SubmitHydroshare, GeneralEditSubmission):
    """Page containing forms for editing existing submission with Zenodo backend"""

    pass

GeneralEditSubmission

Bases: Dsp

Source code in dsp/dsp_macros.py
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
class GeneralEditSubmission(Dsp):
    header_title = SiteElement(By.CSS_SELECTOR, ".text-h4")

    @classmethod
    def get_nth_relation_type(self, driver, n):
        sel = (
            ':is(fieldset, div)[data-id*="Relatedresources"]'
            f' .array-list-item:nth-of-type({n+1}) input[data-id*="RelationType"]'
        )
        relation_type_input = SiteElement(By.CSS_SELECTOR, sel)
        return relation_type_input.get_texts_from_xpath(driver, "./preceding::div[1]")

    @classmethod
    def get_header_title(self, driver):
        return self.header_title.get_text(driver)

    @classmethod
    def check_fields_by_dict(self, driver, dict):
        for k, v in dict.items():
            element = SiteElement(By.ID, "#/properties/" + k)
            element.scroll_to(driver)
            value = element.get_value(driver)
            if value != v:
                print(f"\nMismatch when checking field: {k}. Expected {v} got {value}")
                return False
        return True

    @classmethod
    def expand_section_by_did(self, driver, data_id):
        element = SiteElement(
            By.CSS_SELECTOR, f':is(fieldset, div)[data-id*="{data_id}"] legend'
        )
        if not element.exists_in_dom(driver):
            # print(f"\n Ignoring attempt to expand static section: {data_id}")
            return False
        element.scroll_to(driver)
        element.javascript_click(driver)

    @classmethod
    def check_inputs_by_data_ids(self, driver, dict, section=None, nth=0, array=False):
        self.expand_section_by_did(driver, data_id=section)
        for k, v in dict.items():
            if isinstance(v, list):
                # assume this is a v-multi-select
                check = self.check_v_multi_select(
                    driver, container_id=section, input_id=k, values=v
                )
                if not check:
                    print(f"\nMismatch when checking field: |{k}|. Expected |{v}|.")
                    return False
            else:
                # not a v-multi-select
                if section and nth is not None:
                    if array:
                        selector = (
                            f':is(fieldset, div)[data-id*="{section}"] .array-list-item:nth-of-type({nth+1}) [data-id="{k}"],'
                            f' :is(fieldset, div)[data-id*="{section}"] .array-list-item:nth-of-type({nth+1}) [data-id="{k}*"]'
                        )
                        elem = SiteElement(By.CSS_SELECTOR, selector)
                    else:
                        selector = (
                            f':is(fieldset, div)[data-id*="{section}"] [data-id="{k}"]:nth-of-type({nth+1}),'
                            f' :is(fieldset, div)[data-id*="{section}"] [data-id="{k}*"]:nth-of-type({nth+1})'
                        )
                        elem = SiteElement(By.CSS_SELECTOR, selector)
                else:
                    selector = f'[data-id="{k}"]:nth-of-type(1), [data-id="{k}*"]:nth-of-type(1)'
                    elem = SiteElement(By.CSS_SELECTOR, selector)
                elem.scroll_to(driver)
                value = elem.get_value(driver)
                if value != v:
                    if value.strip() == v:
                        # Allow additional whitespace padding
                        # print(
                        #     f"\nWARNING: while checking field: |{k}|.\nExpected:"
                        #     f" |{v}|\nBut got : |{value}|                        "
                        #     " \nWhitespace will be ignored and this field considered"
                        #     " valid"
                        # )
                        pass
                    else:
                        print(
                            f"\nMismatch when checking field: |{k}|.\nExpected |{v}|"
                            f" got |{value}|"
                        )
                        print(f"\nSelector used: {selector}")
                        return False
        return True

    @classmethod
    def check_first_input_in_section(self, driver, dict, section=None, array=False):
        self.expand_section_by_did(driver, data_id=section)
        for k, v in dict.items():
            if isinstance(v, list):
                # assume this is a v-multi-select
                check = self.check_v_multi_select(
                    driver, container_id=section, input_id=k, values=v
                )
                if not check:
                    print(f"\nMismatch when checking field: |{k}|. Expected |{v}|.")
                    return False
            else:
                # not a v-multi-select
                if section:
                    if array:
                        selector = (
                            f':is(fieldset, div)[data-id*="{section}"] .array-list-item:first-of-type input'
                        )
                        elem = SiteElement(By.CSS_SELECTOR, selector)
                    else:
                        selector = (
                            f':is(fieldset, div)[data-id*="{section}"] input:first-of-type'
                        )
                        elem = SiteElement(By.CSS_SELECTOR, selector)
                else:
                    selector = f'[data-id="{k}"]:first-of-type, [data-id="{k}*"]:first-of-type'
                    elem = SiteElement(By.CSS_SELECTOR, selector)
                elem.scroll_to(driver)
                value = elem.get_value(driver)
                if value != v:
                    if value.strip() == v:
                        # Allow additional whitespace padding
                        # print(
                        #     f"\nWARNING: while checking field: |{k}|.\nExpected:"
                        #     f" |{v}|\nBut got : |{value}|                        "
                        #     " \nWhitespace will be ignored and this field considered"
                        #     " valid"
                        # )
                        pass
                    else:
                        print(
                            f"\nMismatch when checking first input in section. Field: |{k}|.\nExpected |{v}|"
                            f" got |{value}|"
                        )
                        print(f"\nSelector used: {selector}")
                        return False
        return True

    @classmethod
    def check_required_elements(self, driver, required_elements):
        """Unless otherwise defined, Editsubmission pages should check required fields
        by dict"""
        for section, dict_to_check in required_elements.items():
            try:
                return self.check_inputs_by_data_ids(
                    driver, dict=dict_to_check, section=section, nth=0
                )
            except TimeoutException:
                print("Unable to check required element. Defaulting to first in section")
                return self.check_first_input_in_section(
                    driver, dict=dict_to_check, section=section
                )

    @classmethod
    def get_v_multi_select_vals(self, driver, container_id, input_id):
        input = SiteElement(
            By.CSS_SELECTOR,
            f'fieldset[data-id*="{container_id}"] input[data-id*="{input_id}"]',
        )
        values = input.get_texts_from_xpath(
            driver, './preceding-sibling::*/span[contains(@class, "v-chip__content")]'
        )
        return values

    @classmethod
    def check_v_multi_select(self, driver, container_id, input_id, values=None):
        saved_values = self.get_v_multi_select_vals(driver, container_id, input_id)
        if isinstance(values, str):
            if values not in saved_values:
                return False
        else:
            if not all(elem in saved_values for elem in values):
                return False
        return True

    @classmethod
    def get_nth_v_multi_select(self, driver, container_id, input_id, n):
        saved_values = self.get_v_multi_select_vals(driver, container_id, input_id)
        return saved_values[n]

check_required_elements(driver, required_elements) classmethod

Unless otherwise defined, Editsubmission pages should check required fields by dict

Source code in dsp/dsp_macros.py
952
953
954
955
956
957
958
959
960
961
962
963
964
965
@classmethod
def check_required_elements(self, driver, required_elements):
    """Unless otherwise defined, Editsubmission pages should check required fields
    by dict"""
    for section, dict_to_check in required_elements.items():
        try:
            return self.check_inputs_by_data_ids(
                driver, dict=dict_to_check, section=section, nth=0
            )
        except TimeoutException:
            print("Unable to check required element. Defaulting to first in section")
            return self.check_first_input_in_section(
                driver, dict=dict_to_check, section=section
            )

HSResourcePage

Bases: WebPage

Landing page for a HS resource

Source code in dsp/dsp_macros.py
1127
1128
1129
1130
1131
1132
1133
1134
1135
class HSResourcePage(WebPage):
    """Landing page for a HS resource"""

    logo = By.CSS_SELECTOR, "#img-brand-logo"
    title = SiteElement(By.CSS_SELECTOR, "#resource-title")

    @classmethod
    def get_title(self, driver):
        return self.title.get_text(driver)

HydroshareAuthWindow

Bases: WebPage

Authentication window to use Hydroshare as Backend

Source code in dsp/dsp_macros.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
class HydroshareAuthWindow(WebPage):
    """Authentication window to use Hydroshare as Backend"""

    username = SiteElement(By.ID, "id_username")
    password = SiteElement(By.ID, "id_password")
    submit = SiteElement(By.CSS_SELECTOR, ".account-form .btn-primary")
    authorize = SiteElement(By.CSS_SELECTOR, '#authorizationForm input[name="allow"]')

    @classmethod
    def authorize_repo(self, driver, username, password):
        self.username.inject_text(driver, username)
        self.password.inject_text(driver, password)
        self.submit.click(driver)
        self.authorize.click(driver)

MySubmissions

Bases: Dsp

Page displaying users submissions

Source code in dsp/dsp_macros.py
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
class MySubmissions(Dsp):
    """Page displaying users submissions"""

    title = SiteElement(By.CSS_SELECTOR, ".text-h4:nth-of-type(1)")
    total_submissions = SiteElement(By.ID, "total_submissions")
    top_submission = SiteElement(By.ID, "submission-0")
    top_submission_name = SiteElement(By.ID, "sub-0-title")
    top_submission_date = SiteElement(By.ID, "sub-0-date")
    sort_order_select = SiteElement(By.ID, "sort-order")
    my_submissions_search = SiteElement(By.ID, "my_submissions_search")
    top_submission_edit = SiteElement(By.ID, "sub-0-edit")
    top_submission_view_repo = SiteElement(By.ID, "sub-0-view")
    check_in_dialog = SiteElement(By.CSS_SELECTOR, '.v-dialog input[type="checkbox"]')
    confirm_in_dialog = SiteElement(By.CSS_SELECTOR, ".v-dialog button.dialog-confirm")

    @classmethod
    def delete_submissions(self, driver, silent=False):
        total_submissions = self.get_total_submissions(driver)
        current_active = 0
        while total_submissions > current_active:
            delete_button = SiteElement(
                By.ID, f"sub-{total_submissions - current_active -1}-delete"
            )
            delete_button.scroll_to_hidden(driver)
            claz = delete_button.get_class(driver)
            is_disabled = False
            for cl in claz.split(" "):
                if cl == "v-btn--disabled":
                    is_disabled = True
                    break
            if not is_disabled:
                delete_button.javascript_click_hidden(driver, silent)
                try:
                    self.check_in_dialog.javascript_click_hidden(driver, silent)
                    self.confirm_in_dialog.javascript_click_hidden(driver, silent)
                except TimeoutException:
                    # sometimes the "checkbox to delete in repo is not present"
                    pass
            else:
                current_active = current_active + 1
            total_submissions = self.get_total_submissions(driver)

    @classmethod
    def get_title(self, driver):
        return self.title.get_text(driver)

    @classmethod
    def get_total_submissions(self, driver):
        text = self.total_submissions.get_text(driver)
        return int(text.split(" ", 1)[0])

    @classmethod
    def get_top_submission_name(self, driver):
        return self.top_submission_name.get_text(driver)

    @classmethod
    def get_top_submission_date(self, driver):
        return self.top_submission_date.get_text(driver)

    @classmethod
    def enter_text_in_search(self, driver, field_text):
        self.my_submissions_search.inject_text(driver, field_text)

    @classmethod
    def edit_top_submission(self, driver):
        self.top_submission_edit.click(driver)

    @classmethod
    def view_top_submission(self, driver):
        self.top_submission_view_repo.click(driver)

OrcidWindow

Bases: WebPage

Orcid window

Source code in dsp/dsp_macros.py
229
230
231
232
233
234
235
236
237
238
239
240
class OrcidWindow(WebPage):
    """Orcid window"""

    username = SiteElement(By.ID, "username")
    password = SiteElement(By.ID, "password")
    submit = SiteElement(By.ID, "signin-button")

    @classmethod
    def fill_credentials(self, driver, username, password):
        self.username.inject_text(driver, username)
        self.password.inject_text(driver, password)
        self.submit.click(driver)

SubmitEarthchem

Bases: GeneralSubmitToRepo

Page containing forms for submitting data with Earthchem backend

Source code in dsp/dsp_macros.py
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
class SubmitEarthchem(GeneralSubmitToRepo):
    """Page containing forms for submitting data with Earthchem backend"""

    finish_later = SiteElement(
        By.XPATH, "//*[@class='v-btn__content' and contains(text(),'later')]/.."
    )
    submit_review = SiteElement(
        By.XPATH,
        "//*[@class='v-btn__content' and contains(text(),'Submit for review')]/..",
    )
    license = SiteElement(By.CSS_SELECTOR, '[data-id*="License"] .v-select__selection')

    @classmethod
    def finish_submission_later(self, driver):
        self.bottom_finish.scroll_to(driver)
        self.bottom_finish.click(driver)
        self.finish_later.click(driver)
        self.wait_until_element_not_exist(driver, self.is_saving, NEW_SUBMISSION_SAVE)

    @classmethod
    def submit_for_review(self, driver):
        self.bottom_finish.scroll_to(driver)
        self.bottom_finish.click(driver)
        self.submit_review.click(driver)
        self.wait_until_element_not_exist(driver, self.is_saving, NEW_SUBMISSION_SAVE)

    @classmethod
    def get_license(self, driver):
        return self.license.get_text(driver)

SubmitExternal

Bases: GeneralSubmitToRepo

Page containing forms for submitting data with EXTERNAL backend

Source code in dsp/dsp_macros.py
1027
1028
1029
1030
class SubmitExternal(GeneralSubmitToRepo):
    """Page containing forms for submitting data with EXTERNAL backend"""

    pass

SubmitHydroshare

Bases: GeneralSubmitToRepo

Page containing forms for submitting data with HS backend

Source code in dsp/dsp_macros.py
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
class SubmitHydroshare(GeneralSubmitToRepo):
    """Page containing forms for submitting data with HS backend"""

    # Basic info
    title = SiteElement(
        By.CSS_SELECTOR, '[data-id*="BasicInformation"] input[data-id*="Title"]'
    )
    abstract = SiteElement(By.ID, "#/properties/abstract-input")
    subject_keyword_container = SiteElement(
        By.CSS_SELECTOR, '[data-id="group-BasicInformation"] .v-select__selections'
    )

    # Temporal
    temporal_name_input = SiteElement(
        By.CSS_SELECTOR,
        ':is(fieldset, div)[data-id*="Temporalcoverage"] input[data-id*="Name"]',
    )
    start_input = SiteElement(
        By.CSS_SELECTOR, '[data-id*="Temporalcoverage"] input[data-id*="Start"]'
    )
    end_input = SiteElement(
        By.CSS_SELECTOR, '[data-id*="Temporalcoverage"] input[data-id*="End"]'
    )

    # Funding agency
    agency_name = SiteElement(By.ID, "#/properties/funding_agency_name-input")

    # Rights
    rights_statement = SiteElement(By.ID, "#/properties/statement-input")
    rights_url = SiteElement(By.ID, "#/properties/url-input")

SubmitLandingPage

Bases: Dsp, RepoAuthWindow

Page containing options for submitting data

Source code in dsp/dsp_macros.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
class SubmitLandingPage(Dsp, RepoAuthWindow):
    """Page containing options for submitting data"""

    repositories_header = SiteElement(
        By.XPATH, "//*[@id='app']/child::*[contains(., 'Repositories')]"
    )

    register_dataset_other = SiteElement(
        By.XPATH,
        "//*[contains(text(),'Register a dataset from a different repository')]/..",
    )

    @classmethod
    def select_external_dataset(self, driver):
        self.register_dataset_other.click(driver)

    @classmethod
    def select_nth_dialog_choice(self, driver, n):
        dialog_item = SiteElement(
            By.CSS_SELECTOR,
            f".v-dialog--active .choice-container .v-card:nth-of-type({n+1})",
        )
        dialog_item.scroll_to(driver)
        dialog_item.click(driver)

    @classmethod
    def select_repo_by_id(self, driver, id):
        repo_card = SiteElement(By.CSS_SELECTOR, f'div[id*="{id}"]')
        repo_card.scroll_to(driver)
        repo_card.click(driver)

    @classmethod
    def select_nth_repo(self, driver, n):
        repo_card = SiteElement(
            By.CSS_SELECTOR, f"div.repositories div.v-card:nth-of-type({n+1})"
        )
        repo_card.scroll_to(driver)
        repo_card.click(driver)

    @classmethod
    def to_repo_form(self, driver, id):
        Dsp.show_mobile_nav(driver)
        Dsp.drawer_to_submit(driver)
        self.select_repo_by_id(driver, id)

SubmitZenodo

Bases: GeneralSubmitToRepo

Page containing forms for submitting data with Zenodo backend

Source code in dsp/dsp_macros.py
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
class SubmitZenodo(GeneralSubmitToRepo):
    """Page containing forms for submitting data with Zenodo backend"""

    @classmethod
    def finish_submission(self, driver, uname, pw):
        """Override general finish submission to account for extra Zenodo auth window"""
        self.bottom_finish.scroll_to(driver)
        self.bottom_finish.click(driver)

        try:
            SubmitLandingPage.to_repo_auth_window(driver)
            ZenodoAuthWindow.authorize_email_password(driver, email=uname, password=pw)
            ZenodoAuthWindow.to_origin_window(driver, wait=True)
        except TimeoutException as e:
            print(f"\n{e}... \nThis exception is ignored")
        try:
            self.wait_until_element_visible(
                driver, self.is_saving, PAUSE_AFTER_FILL_BEFORE_SUBMIT
            )
        except NoSuchElementException as e:
            print(f"\n{e}... \nThis exception is ignored")
        self.wait_until_element_not_exist(driver, self.is_saving, NEW_SUBMISSION_SAVE)

finish_submission(driver, uname, pw) classmethod

Override general finish submission to account for extra Zenodo auth window

Source code in dsp/dsp_macros.py
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
@classmethod
def finish_submission(self, driver, uname, pw):
    """Override general finish submission to account for extra Zenodo auth window"""
    self.bottom_finish.scroll_to(driver)
    self.bottom_finish.click(driver)

    try:
        SubmitLandingPage.to_repo_auth_window(driver)
        ZenodoAuthWindow.authorize_email_password(driver, email=uname, password=pw)
        ZenodoAuthWindow.to_origin_window(driver, wait=True)
    except TimeoutException as e:
        print(f"\n{e}... \nThis exception is ignored")
    try:
        self.wait_until_element_visible(
            driver, self.is_saving, PAUSE_AFTER_FILL_BEFORE_SUBMIT
        )
    except NoSuchElementException as e:
        print(f"\n{e}... \nThis exception is ignored")
    self.wait_until_element_not_exist(driver, self.is_saving, NEW_SUBMISSION_SAVE)

ZenodoAuthWindow

Bases: WebPage

Authentication window to use Zenodo as Backend

Source code in dsp/dsp_macros.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
class ZenodoAuthWindow(WebPage):
    """Authentication window to use Zenodo as Backend"""

    github_button = SiteElement(By.CSS_SELECTOR, '.social-signup .btn[href*="github"]')
    orcid_button = SiteElement(By.CSS_SELECTOR, '.social-signup .btn[href*="orcid"]')
    email = SiteElement(By.ID, "email")
    password = SiteElement(By.ID, "password")
    login_button = SiteElement(By.CSS_SELECTOR, 'button[type="submit"]')
    authorize_czhub_button = SiteElement(By.CSS_SELECTOR, 'form button[value="yes"]')

    @classmethod
    def authorize_via_orcid(self, driver):
        self.orcid_button.click(driver)

    @classmethod
    def authorize_via_github(self, driver):
        self.github_button.click(driver)

    @classmethod
    def authorize_email_password(self, driver, email, password):
        self.email.inject_text(driver, email)
        self.password.inject_text(driver, password)
        self.login_button.click(driver)
        self.authorize_czhub_button.click(driver)

ZenodoResourcePage

Bases: WebPage

Landing page for a Zenodo resource

Source code in dsp/dsp_macros.py
1138
1139
1140
1141
1142
1143
1144
1145
1146
class ZenodoResourcePage(WebPage):
    """Landing page for a Zenodo resource"""

    logo = By.CSS_SELECTOR, "img.navbar-brand"
    title = SiteElement(By.CSS_SELECTOR, "#title")

    @classmethod
    def get_title(self, driver):
        return self.title.get_value(driver)