def AddBasicInformation(driver, eventObj): # Add Basic Information helper.ClickElementFromTagAndText(driver, "button", "Create a Sign Up") helper.PauseForEffect(SIGN_UP_GENIUS_TIMEOUT) titleID = "signuptitle" selectGroupID = "selectgroup" selectTypeID = "selecttype" categoriesID = "searchCategories" if not helper.HasPageLoadedIDCheck(driver, SIGN_UP_GENIUS_TIMEOUT, titleID): print("Page has not loaded in time") return eventURL driver.find_element_by_id(titleID).click() pyautogui.write(eventObj["title"]) select = Select(driver.find_element_by_id(selectGroupID)) select.select_by_visible_text(eventObj["group"]) select = Select(driver.find_element_by_id(selectTypeID)) select.select_by_visible_text(eventObj["type"]) select = Select(driver.find_element_by_id(categoriesID)) select.select_by_visible_text(eventObj["categories"]) Scroll(100, 5) saveAndContiueText = "Save and Continue" helper.ClickElementFromTagAndText(driver, "span", saveAndContiueText) helper.PauseForEffect(SIGN_UP_GENIUS_TIMEOUT) return driver.current_url
def CreateTickets(driver, eventObj): helper.PauseForEffect(EVENTBRITE_TIMEOUT) if eventObj["type"] == "Free": helper.ClickElementFromTagAndText(driver, "div", "Free") quantityID = "ticket-quantity" driver.find_element_by_id(quantityID).send_keys(eventObj["amount"]) else: print("Other Types not supported") helper.ClickElementFromTagAndText(driver, "button", "Save") helper.PauseForEffect(EVENTBRITE_TIMEOUT)
def CreateDetails(driver, eventObj, signUpGeniusLink): eventURL = None summaryID = "event-design-summary" if not helper.HasPageLoadedIDCheck(driver, EVENTBRITE_TIMEOUT, summaryID): print("Page has not loaded in time") return eventURL # Upload Banner uploadImageClass = "eds-uploader-dropzone__cover" allImages = driver.find_elements_by_class_name(uploadImageClass) allImages[0].click() helper.PauseForEffect(SMALL_PAUSE) pyautogui.write(eventObj["banner"], interval = 0.1) pyautogui.press(["enter"]) helper.PauseForEffect(SMALL_PAUSE) # Will Always ask for CROP, User has to ensure it is up to size pyautogui.press(["tab"]) pyautogui.press(["enter"]) # Add text richTextBoxClass = "eds-richtexteditor__input" driver.find_element_by_id(summaryID).send_keys(eventObj["summary"]) description = eventObj["description"] description = description.replace("$LINK$", signUpGeniusLink) driver.find_element_by_class_name(richTextBoxClass).send_keys(description) # Add Chef Image if "add" in eventObj: allAdds = eventObj["add"] for add in allAdds: assert "type" in add Scroll(-100, 5) if add["type"] == "image": helper.ClickElementFromTagAndText(driver, "button", "Add Image") helper.PauseForEffect(SMALL_PAUSE) Scroll(-100, 5) allImages = driver.find_elements_by_class_name(uploadImageClass) print(len(allImages)) allImages[0].click() helper.PauseForEffect(SMALL_PAUSE) pyautogui.write(add["content"], interval = 0.1) pyautogui.press(["enter"]) helper.PauseForEffect(SMALL_PAUSE) else: print("Other types not yet supported") helper.PauseForEffect(SMALL_PAUSE) helper.ClickElementFromTagAndText(driver, "button", "Save") helper.PauseForEffect(EVENTBRITE_TIMEOUT)
def CreateOnlinePage(driver, eventObj): helper.PauseForEffect(EVENTBRITE_TIMEOUT) if "video" in eventObj: Scroll(-100, 5) helper.ClickElementFromTagAndText(driver, "span", "Add video") Scroll(100, 5) videoLinkID = "video-url-0" driver.find_element_by_id(videoLinkID).send_keys(eventObj["video"]) if "link" in eventObj: Scroll(-100, 5) helper.ClickElementFromTagAndText(driver, "span", "Add link") Scroll(100, 5) linkTitleID = "file-name-0" linkLinkID = "file-url-0" driver.find_element_by_id(linkTitleID).send_keys(eventObj["link"]["title"]) driver.find_element_by_id(linkLinkID).send_keys(eventObj["link"]["link"]) helper.ClickElementFromTagAndText(driver, "button", "Save") helper.PauseForEffect(EVENTBRITE_TIMEOUT)
def AddSlots(driver, eventObj): helper.PauseForEffect(MEDIUM_PAUSE) helper.ClickElementFromTagAndText(driver, "strong", eventObj["type_schedule"]) tabQuantity = 0 if eventObj["type_schedule"] == "Slots Only": tabQuantity = 3 for i in range(0, tabQuantity): pyautogui.press(["tab"]) helper.PauseForEffect(SMALL_PAUSE) pyautogui.write(eventObj["date"], interval=0.1) print(eventObj["date"]) helper.PauseForEffect(SMALL_PAUSE) pyautogui.press(["enter"]) helper.PauseForEffect(SMALL_PAUSE) all_slots = eventObj["all_slots"] lenSlots = len(all_slots) pyautogui.press(["tab"]) pyautogui.press(["space"]) for i in range(0, lenSlots): slot = all_slots[i] helper.PauseForEffect(SMALL_PAUSE) driver.find_element_by_name("slotname").click() pyautogui.write(slot["title"], interval=0.1) pyautogui.press(["tab"]) pyautogui.write(slot["comment"], interval=0.1) pyautogui.press(["tab"]) pyautogui.write(slot["quantity"], interval=0.1) pyautogui.press(["tab"]) helper.PauseForEffect(SMALL_PAUSE) if i < (lenSlots - 1): pyautogui.press(["tab"]) pyautogui.press(["tab"]) pyautogui.press(["enter"]) helper.PauseForEffect(SMALL_PAUSE) helper.PauseForEffect(MEDIUM_PAUSE) saveAndContiueText = "Save and Continue" helper.ClickElementFromTagAndText(driver, "span", saveAndContiueText) helper.PauseForEffect(SIGN_UP_GENIUS_TIMEOUT)
def basicPage(driver, eventObj): neighborText = "Choose neighbors" helper.ClickElementFromTagAndText(driver, "span", neighborText) helper.PauseForEffect(1) #Summer Lake + Nearby if eventObj["neighborType"] == "Summer Lake": helper.ClickElementFromTagAndText(driver, "label", eventObj["neighborType"], True) else: helper.ClickElementFromTagAndText(driver, "label", eventObj["neighborType"], True) helper.ClickElementFromTagAndText(driver, "button", "Next") neighborText = "Choose category" helper.ClickElementFromTagAndText(driver, "span", neighborText) helper.PauseForEffect(1) #Classes helper.ClickElementFromTagAndText(driver, "label", eventObj["categoryType"]) driver.find_element_by_xpath( '//input[@data-testid="event-form-subject"]').send_keys( eventObj["title"]) driver.find_element_by_xpath( '//textarea[@data-testid="event-form-body"]').send_keys( eventObj["description"]) driver.find_element_by_xpath( '//button[@data-testid="event-form-next-button"]').click()
def addEvent(eventObj, credentials, signUpGeniusLink): eventURL = None driver = webdriver.Chrome() driver.maximize_window() driver.get("https://www.eventbrite.com/signin/") # Username emailFieldID = "email" if not helper.HasPageLoadedIDCheck(driver, EVENTBRITE_TIMEOUT, emailFieldID): print("Page has not loaded in time") return eventURL driver.find_element_by_id(emailFieldID).send_keys(credentials["username"]) pyautogui.press(["enter"]) # Password passwordFieldID = "password" if not helper.HasPageLoadedIDCheck(driver, EVENTBRITE_TIMEOUT, passwordFieldID): print("Page has not loaded in time") return eventURL driver.find_element_by_id(passwordFieldID).send_keys(credentials["password"]) pyautogui.press(["enter"]) helper.PauseForEffect(EVENTBRITE_TIMEOUT) # Create a new Event helper.ClickElementFromTagAndText(driver, "a", "Create Event") currentURL = CreateBasicInfo(driver, eventObj["basic_info"]) eventID = GetEventID(currentURL) print("Event ID is {}".format(eventID)) driver.get(currentURL) CreateDetails(driver, eventObj["details"], signUpGeniusLink) driver.get("https://www.eventbrite.com/manage/events/{}/online-event".format(eventID)) CreateOnlinePage(driver, eventObj["online_page"]) driver.get("https://www.eventbrite.com/manage/events/{}/tickets/create".format(eventID)) CreateTickets(driver, eventObj["tickets"]) driver.get("https://www.eventbrite.com/myevent/{}/order-confirmation/".format(eventID)) CreateOrderConfirmation(driver, eventObj["order_confirmation"], signUpGeniusLink) driver.get("https://www.eventbrite.com/manage/events/{}/preview_publish".format(eventID)) CreatePublish(driver, eventObj["publish"]) driver.get("https://www.eventbrite.com/invites?eid={}".format(eventID)) CreateEmailInvitations(driver, eventObj["invitations"]) driver.get("https://www.eventbrite.com/myevent?eid={}".format(eventID)) url = GetEventURL(driver) print(url) driver.close() return url
def CreateEmailInvitations(driver, eventObj): helper.PauseForEffect(EVENTBRITE_TIMEOUT) helper.ClickElementFromTagAndText(driver, "button", "Create Classic Invite") helper.PauseForEffect(EVENTBRITE_TIMEOUT) # Add Guests driver.find_element_by_partial_link_text("+ Add Guests").click() guestsType = eventObj["add_guests"] helper.PauseForEffect(SMALL_PAUSE) if guestsType["type"] == "previous": driver.find_element_by_id("c").click() helper.PauseForEffect(SMALL_PAUSE) driver.set_window_size(1000, 1000) driver.maximize_window() element = driver.find_element_by_id(guestsType["eventID"]) driver.execute_script('return arguments[0].scrollIntoView();', element) element.click() else: print("Other Guetst Add type not supported") helper.PauseForEffect(SMALL_PAUSE) addID = "lightbox_a_save_button" driver.find_element_by_id(addID).click() # Add Schedule email_time = eventObj["email_time"] if email_time["type"] == "schedule": whenName = "schedule_mode_x" driver.find_element_by_name(whenName).click() dateID = "schedule_date" helper.ClearAndAddElement_Input(driver, dateID, email_time["date"]) hourID = "endhr" minutesID = "endmin" ampmID = "endampm" select = Select(driver.find_element_by_id(hourID)) select.select_by_visible_text(email_time["hour"]) select = Select(driver.find_element_by_id(minutesID)) select.select_by_visible_text(email_time["min"]) select = Select(driver.find_element_by_id(ampmID)) select.select_by_visible_text(email_time["ampm"]) else: print("Other Schedule types not supported") helper.PauseForEffect(SMALL_PAUSE) driver.find_element_by_partial_link_text("Save & Schedule").click() helper.PauseForEffect(EVENTBRITE_TIMEOUT)
def CreatePublish(driver, eventObj): helper.PauseForEffect(EVENTBRITE_TIMEOUT) helper.ClickElementFromTagAndText(driver, "button", "Publish") helper.PauseForEffect(EVENTBRITE_TIMEOUT)
def CreateBasicInfo(driver, eventObj): titleID = "event-basicInfo-title" if not helper.HasPageLoadedIDCheck(driver, EVENTBRITE_TIMEOUT, titleID): print("Page has not loaded in time") return eventURL driver.find_element_by_id(titleID).send_keys(eventObj["title"]) selectID = "event-basicinfo-organizer-profile" eventTypeName = "eventType" eventTopicName = "eventTopic" eventSubTopicName = "eventSubTopic" tagFieldName = "tagInputField" select = Select(driver.find_element_by_id(selectID)) select.select_by_visible_text(eventObj["organizer"]) select = Select(driver.find_element_by_name(eventTypeName)) select.select_by_visible_text(eventObj["type"]) select = Select(driver.find_element_by_name(eventTopicName)) select.select_by_visible_text(eventObj["topic"]) helper.PauseForEffect(SMALL_PAUSE) select = Select(driver.find_element_by_name(eventSubTopicName)) select.select_by_visible_text(eventObj["subTopic"]) fieldValue = driver.find_element_by_name(tagFieldName) allTags = eventObj["tags"] allTags = (allTags, allTags[0:MAX_TAGS])[len(allTags) > MAX_TAGS] for tag in allTags: fieldValue.send_keys(tag) pyautogui.press("enter") helper.PauseForEffect(SMALL_PAUSE) Scroll(-100, 5) print("Scroll Completed") locationDetails = eventObj["location"] helper.ClickElementFromTagAndText(driver, "div", "Online event") print("Completd DIV try") # if locationDetails["type"] == "Venue": # driver.find_element_by_id("segmented-venueType-0").click() # if locationDetails["type"] == "Online event": # driver.find_element_by_id("segmented-venueType-1").click() # if locationDetails["type"] == "To be announced": # driver.find_element_by_id("segmented-venueType-2").click() # print("Completd Radio Try") Scroll(-100, 5) dateAndTime = eventObj["dateAndTime"] helper.MoveToElement(driver, "div", "Single Event") helper.ClickElementFromTagAndText(driver, "div", "Single Event") if dateAndTime["type"] == "Single Event": startDateID = "event-startDate" startTimeID = "event-startTime" endDateID = "event-endDate" endTimeID = "event-endTime" helper.ClearAndAddElement_Input(driver, startDateID, dateAndTime["start_date"]) helper.ClearAndAddElement_Input(driver, startTimeID, dateAndTime["start_time"]) helper.ClearAndAddElement_Input(driver, endDateID, dateAndTime["end_date"]) helper.ClearAndAddElement_Input(driver, endTimeID, dateAndTime["end_time"]) selectZoneName = "venueTimeZone" select = Select(driver.find_element_by_name(selectZoneName)) select.select_by_visible_text(dateAndTime["zone"]) helper.ClickElementFromTagAndText(driver, "button", "Save & Continue") # helper.PauseForEffect(EVENTBRITE_TIMEOUT) helper.PauseForEffect(EVENTBRITE_TIMEOUT) return driver.current_url
def AddSettings(driver, eventObj): # No Changes in this region hence small pause sufficient helper.PauseForEffect(SMALL_PAUSE) saveAndContiueText = "Save and Continue" helper.ClickElementFromTagAndText(driver, "span", saveAndContiueText) helper.PauseForEffect(SMALL_PAUSE)
def addEvent(eventObj, credentials, eventBriteLink): options = webdriver.ChromeOptions() options.add_argument("--profile-directory=Default") options.add_argument("--whitelisted-ips") options.add_argument("--start-maximized") options.add_argument("--disable-extensions") options.add_argument("--disable-plugins-discovery") driver = webdriver.Chrome(chrome_options=options) driver.maximize_window() driver.get("https://nextdoor.com/") helper.PauseForEffect(NEXTDOOR_TIMEOUT) # Create an Event loginText = "Log in" helper.ClickElementFromTagAndText(driver, "button", loginText) signInButtonID = "signin_button" if not helper.HasPageLoadedIDCheck(driver, NEXTDOOR_TIMEOUT, signInButtonID): print("Page has not loaded in time") return emailFieldID = "id_email" passwordFieldID = "id_password" driver.find_element_by_id(emailFieldID).send_keys(credentials["username"]) driver.find_element_by_id(passwordFieldID).send_keys( credentials["password"]) pyautogui.press(["enter"]) helper.PauseForEffect(NEXTDOOR_TIMEOUT) # Create an Event eventsLinkText = "Events" helper.ClickElementFromTagAndText(driver, "span", eventsLinkText) helper.PauseForEffect(1) addEventID = "main_content" if not helper.HasPageLoadedIDCheck(driver, NEXTDOOR_TIMEOUT, addEventID): print("Page has not loaded in time") return driver.find_element_by_id(addEventID).click() helper.PauseForEffect(NEXTDOOR_TIMEOUT) basicPage(driver, eventObj) helper.PauseForEffect(NEXTDOOR_TIMEOUT) detailsPage(driver, eventObj, eventBriteLink) helper.PauseForEffect(NEXTDOOR_TIMEOUT) # add Image if "image" in eventObj: print(eventObj["image"]) action = ActionChains(driver) imageButton = driver.find_element_by_xpath( '//input[@class="uploader-fileinput"]') action.click(on_element=imageButton) action.perform() helper.PauseForEffect(1) pyautogui.write(eventObj["image"], interval=0.1) pyautogui.press(["enter"]) helper.PauseForEffect(NEXTDOOR_TIMEOUT) # # Post the Image # driver.find_element_by_xpath('//button[@data-testid="button-photo"]').click() driver.close()