|
| 1 | +# locators/provider/create_collaborative_locators.py |
| 2 | + |
| 3 | +from selenium.webdriver.common.by import By |
| 4 | + |
| 5 | +class CreateCollaborativeLocators: |
| 6 | + """ |
| 7 | + All locators for the CreateCollaborativePage. |
| 8 | + Keep things as simple constants so that the POM methods can refer to them by name. |
| 9 | + """ |
| 10 | + |
| 11 | + # ─── "Collaborative Details" Tab and Fields ───────────────────────────────────── |
| 12 | + DETAILS_TAB = (By.XPATH, "//button[normalize-space()='Collaborative Details']") |
| 13 | + |
| 14 | + # Collaborative Name - Edit button and save functionality |
| 15 | + COLLABORATIVE_NAME_EDIT_BUTTON = (By.XPATH, "//div[@class=' pl-2']//button[@type='button']") |
| 16 | + # Try multiple strategies to find the name input |
| 17 | + COLLABORATIVE_NAME_INPUT = (By.XPATH, "//label[contains(text(),'COLLABORATIVE NAME')]/following::input[1]") |
| 18 | + COLLABORATIVE_NAME_INPUT_ALT = (By.CSS_SELECTOR, "input[type='text']") |
| 19 | + COLLABORATIVE_NAME_INPUT_ALT2 = (By.ID, "collaborativeName") |
| 20 | + COLLABORATIVE_NAME_SAVE_BUTTON = (By.XPATH, "//button[normalize-space()='Save']") |
| 21 | + # Locator for the displayed collaborative name (after save) |
| 22 | + COLLABORATIVE_NAME_DISPLAY = (By.XPATH, "//span[contains(text(),'COLLABORATIVE NAME')]/following-sibling::*[1]") |
| 23 | + COLLABORATIVE_NAME_DISPLAY_ALT = (By.XPATH, "//div[contains(@class,'flex')]//div[@class=' pl-2']") |
| 24 | + COLLABORATIVE_NAME_DISPLAY_ALT2 = (By.XPATH, "//label[contains(text(),'COLLABORATIVE NAME')]/following::div[1]") |
| 25 | + |
| 26 | + # Summary field (rich text editor) |
| 27 | + COLLABORATIVE_SUMMARY_LABEL = (By.XPATH, "//label[normalize-space()='Summary *']") |
| 28 | + COLLABORATIVE_SUMMARY_INPUT = (By.XPATH, "//div[contains(@class, 'ql-editor') and @contenteditable='true']") |
| 29 | + |
| 30 | + # Platform URL |
| 31 | + PLATFORM_URL_INPUT = (By.XPATH, "//input[@name='platformUrl']") |
| 32 | + |
| 33 | + # SDG Goals (try both singular and plural) |
| 34 | + SDG_GOALS_CONTAINER = (By.XPATH, "//label[normalize-space()='SDG Goals *']/following::input[1]") |
| 35 | + SDG_GOALS_CONTAINER_ALT = (By.XPATH, "//label[normalize-space()='SDG Goal *']/following::input[1]") |
| 36 | + SDG_GOALS_CONTAINER_ALT2 = (By.XPATH, "//label[contains(text(),'SDG')]/following::input[1]") |
| 37 | + SDG_GOALS_OPTION = "//div[@role='option' and normalize-space(.)='{value}']" |
| 38 | + |
| 39 | + # Tags |
| 40 | + TAGS_INPUT = (By.XPATH, "//label[normalize-space()='Tags']/following::input[@role='combobox'][1]") |
| 41 | + TAG_DROPDOWN_ITEM = "//div[@role='option' and normalize-space(.)='{value}']" |
| 42 | + |
| 43 | + # Sectors |
| 44 | + SECTOR_INPUT = (By.XPATH, "//label[normalize-space()='Sectors *']/following::input[@role='combobox'][1]") |
| 45 | + SECTOR_DROPDOWN_ITEM = "//div[@role='option' and normalize-space(.)='{value}']" |
| 46 | + |
| 47 | + # Geography |
| 48 | + GEOGRAPHY_CONTAINER = (By.XPATH, "//label[normalize-space()='Geographies']/following::input[1]") |
| 49 | + GEO_OPTION = "//div[@role='option' and normalize-space(.)='{value}']" |
| 50 | + |
| 51 | + # Dates |
| 52 | + STARTED_ON_INPUT = (By.XPATH, "//input[@type='date' and @name='startedOn']") |
| 53 | + COMPLETED_ON_INPUT = (By.XPATH, "//input[@type='date' and @name='completedOn']") |
| 54 | + |
| 55 | + # Logo Upload |
| 56 | + LOGO_UPLOAD_INPUT = (By.XPATH, "//label[normalize-space()='Logo *']//following::div[@class='FileUpload-module_Action__Hg0nE'][1]") |
| 57 | + |
| 58 | + # Cover Image Upload |
| 59 | + COVER_IMAGE_UPLOAD_INPUT = (By.XPATH, "//label[normalize-space()='Cover Image']//following::div[@class='FileUpload-module_Action__Hg0nE'][1]") |
| 60 | + |
| 61 | + # ─── Fields Used for Value Retrieval / Assertions ────────────────────────── |
| 62 | + SUMMARY_INPUT = (By.XPATH, "//div[contains(@class, 'ql-editor') and @contenteditable='true']") |
| 63 | + STARTED_ON_VALUE_INPUT = (By.XPATH, "//input[@type='date' and @name='startedOn']") |
| 64 | + COMPLETED_ON_VALUE_INPUT = (By.XPATH, "//input[@type='date' and @name='completedOn']") |
| 65 | + |
| 66 | + # ─── Tags / Sectors / SDG Goals / Geography Chips (Assertions) ───────────────────────── |
| 67 | + SELECTED_TAGS = "//div[contains(@class,'Input-module_tags')]//span[contains(@class,'Tag-module_TagText')]" |
| 68 | + SELECTED_SECTORS = "//div[contains(@class,'Input-module_tags')]//span[contains(@class,'Tag-module_TagText')]" |
| 69 | + SELECTED_GEOGRAPHY = "//label[normalize-space(text())='Geographies']/following::div[contains(@class,'Input-module_tags')][1]//span[contains(@class,'Tag-module_TagText')]" |
| 70 | + SELECTED_SDG_GOALS = "//div[contains(@class,'Input-module_tags')]//span[contains(@class,'Tag-module_TagText')]" |
| 71 | + |
| 72 | + # ─── Logo & Cover Image Preview (Post-upload Check) ────────────────────────────────────── |
| 73 | + LOGO_PREVIEW = (By.CSS_SELECTOR, ".uploaded-logo-preview") |
| 74 | + COVER_IMAGE_PREVIEW = (By.CSS_SELECTOR, ".uploaded-cover-preview") |
| 75 | + |
| 76 | + # ─── Navigation Buttons ───────────────────────────────────────────────────────────── |
| 77 | + NEXT_BUTTON = (By.XPATH, "//button[contains(text(),'Next')]") |
| 78 | + PREVIOUS_BUTTON = (By.XPATH, "//button[contains(text(),'Previous')]") |
| 79 | + |
| 80 | + # ─── "Datasets" Tab (if applicable) ──────────────────────────────────────────────────────── |
| 81 | + DATASETS_TAB = (By.XPATH, "//button[normalize-space()='Datasets']") |
| 82 | + FIRST_DATASET_CHECKBOX = (By.XPATH, "//tbody/tr[1]//button[@role='checkbox']") |
| 83 | + SELECTED_DATASET_CHECKBOX = (By.XPATH, "//tbody/tr[1]//button[@data-state='checked' and @aria-checked='true']") |
| 84 | + SUBMIT_DATASETS_BUTTON = (By.XPATH, "//button[normalize-space()='Submit']") |
| 85 | + |
| 86 | + # ─── "Use Cases" Tab (if applicable) ──────────────────────────────────────────────────────── |
| 87 | + USECASES_TAB = (By.XPATH, "//button[normalize-space()='Use Cases']") |
| 88 | + FIRST_USECASE_CHECKBOX = (By.XPATH, "//tbody/tr[1]//button[@role='checkbox']") |
| 89 | + SELECTED_USECASE_CHECKBOX = (By.XPATH, "//tbody/tr[1]//button[@data-state='checked' and @aria-checked='true']") |
| 90 | + SUBMIT_USECASES_BUTTON = (By.XPATH, "//button[normalize-space()='Submit']") |
| 91 | + |
| 92 | + # ─── "Contributors" Tab ──────────────────────────────────────────────────── |
| 93 | + CONTRIBUTORS_TAB = (By.XPATH, "//button[normalize-space()='Contributors']") |
| 94 | + CONTRIBUTORS_INPUT = (By.XPATH, "//input[@placeholder='Add Contributors']") |
| 95 | + SUPPORTERS_INPUT = (By.XPATH, "//input[@placeholder='Add Supporters']") |
| 96 | + PARTNERS_INPUT = (By.XPATH, "//input[@placeholder='Add Partners']") |
| 97 | + |
| 98 | + # ─── Contributors/Sponsors List Items ────────────────────────────────────── |
| 99 | + CONTRIBUTORS_LIST_ITEMS = ( |
| 100 | + By.XPATH, |
| 101 | + "//div[contains(@class,'flex') and contains(@class,'gap-2')]/span[contains(@class, 'Text-module_bodyMd')]" |
| 102 | + ) |
| 103 | + SUPPORTERS_LIST_ITEMS = (By.CSS_SELECTOR, ".supporters-list-item") |
| 104 | + PARTNERS_LIST_ITEMS = (By.CSS_SELECTOR, ".partners-list-item") |
| 105 | + |
| 106 | + # ─── "Publish" Tab ───────────────────────────────────────────────────────── |
| 107 | + PUBLISH_TAB = (By.XPATH, "//button[normalize-space()='Publish']") |
| 108 | + PUBLISH_BUTTON = ( |
| 109 | + By.XPATH, |
| 110 | + "//button[normalize-space()='Publish' and contains(@class,'Button-module_Button')]" |
| 111 | + ) |
| 112 | + |
| 113 | + PUBLISHED_MARKER = (By.XPATH, "//div[contains(text(),'Collaborative Published Successfully')]") |
| 114 | + |
| 115 | + # ─── Generic Dropdown Option Pattern ─────────────────────────────────────── |
| 116 | + OPTION_BY_VISIBLE_TEXT = "//div[@role='option' and normalize-space(text())='{text}']" |
0 commit comments