示例#1
0
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
示例#2
0
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
示例#3
0
def addAssist(driver, eventObj):
    assistEventLink = "Assist"
    action = ActionChains(driver)
    attendEventLink = driver.find_element_by_partial_link_text(assistEventLink)
    action.click(on_element=attendEventLink)
    action.perform()

    driver.switch_to.window(driver.window_handles[-1])
    addLeadershipButtonID = "reviews_item_form_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       addLeadershipButtonID):
        print("Page has not loaded in time")
        return
    eventDateID = "date_191"
    eventAttendanceID = "number_224"
    textAreaID = "textarea_195"
    driver.find_element_by_id(eventDateID).send_keys(eventObj["date"])
    driver.find_element_by_id(eventAttendanceID).send_keys(
        eventObj["attendance"])
    driver.find_element_by_id(textAreaID).send_keys(eventObj["description"])

    if "photo" in eventObj:
        addPhotoAssist(driver, eventObj["photo"])
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.find_element_by_id(addLeadershipButtonID).click()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)

    # Only Close the TAB
    driver.close()
示例#4
0
def addBlog(driver, eventObj):
    blogEventLink = "Blog"
    action = ActionChains(driver)
    attendEventLink = driver.find_element_by_partial_link_text(blogEventLink)
    action.click(on_element=attendEventLink)
    action.perform()

    driver.switch_to.window(driver.window_handles[-1])
    addLeadershipButtonID = "reviews_item_form_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       addLeadershipButtonID):
        print("Page has not loaded in time")
        return
    blogDateID = "date_381"
    blogNameID = "textField_382"
    blogTitleID = "textField_383"
    linkID = "link_385"
    textAreaID = "textarea_386"
    driver.find_element_by_id(blogDateID).send_keys(eventObj["date"])
    driver.find_element_by_id(blogNameID).send_keys(eventObj["name"])
    driver.find_element_by_id(blogTitleID).send_keys(eventObj["title"])
    helper.ClearAndAddElement(driver, linkID, eventObj["link"])
    driver.find_element_by_id(textAreaID).send_keys(eventObj["description"])

    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.find_element_by_id(addLeadershipButtonID).click()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)

    # Only Close the TAB
    driver.close()
示例#5
0
def addEvent(eventObj, credentials):
    eventURL = None
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://www.signupgenius.com/register")
    # Login
    emailFieldID = "email"
    passwordFieldID = "pword"
    loginButtonID = "loginBtnId"
    if not helper.HasPageLoadedIDCheck(driver, SIGN_UP_GENIUS_TIMEOUT,
                                       loginButtonID):
        print("Page has not loaded in time")
        return eventURL
    driver.find_element_by_partial_link_text("Got it!").click()
    driver.find_element_by_id(emailFieldID).send_keys(credentials["username"])
    driver.find_element_by_id(passwordFieldID).send_keys(
        credentials["password"])
    driver.find_element_by_id(loginButtonID).send_keys(Keys.ENTER)
    createSignUpClass = "btn btn-green black-shadow-active"
    helper.PauseForEffect(SIGN_UP_GENIUS_TIMEOUT)
    signUpListItemID = "member-sidebar--menu-signupsid"
    if not helper.HasPageLoadedIDCheck(driver, SIGN_UP_GENIUS_TIMEOUT,
                                       signUpListItemID):
        print("Page has not loaded in time")
        return eventURL
    # Start with Base
    url = AddBasicInformation(driver, eventObj)
    eventID = GetEventID(url)
    # driver.get("https://www.signupgenius.com/index.cfm?go=w.manageSignUp#/{}/slots/".format(eventID))

    # Other Details
    AddSlots(driver, eventObj)
    AddSettings(driver, eventObj)

    # Publish
    driver.get(
        "https://www.signupgenius.com/index.cfm?go=w.manageSignUp#/{}/publish/"
        .format(eventID))
    signUpLink = AddPublish(driver, eventObj)
    driver.close()
    print(signUpLink)
    return signUpLink
示例#6
0
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)
示例#7
0
def addResource(driver, eventObj):
    blogEventLink = "Resource"
    action = ActionChains(driver)
    attendEventLink = driver.find_element_by_partial_link_text(blogEventLink)
    action.click(on_element=attendEventLink)
    action.perform()

    driver.switch_to.window(driver.window_handles[-1])
    addLeadershipButtonID = "reviews_item_form_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       addLeadershipButtonID):
        print("Page has not loaded in time")
        return
    resourceDateID = "date_406"
    resourceNameID = "textField_407"
    linkID = "link_410"
    textAreaID = "textarea_409"
    driver.find_element_by_id(resourceDateID).send_keys(eventObj["date"])
    driver.find_element_by_id(resourceNameID).send_keys(eventObj["name"])
    helper.ClearAndAddElement(driver, linkID, eventObj["link"])
    driver.find_element_by_id(textAreaID).send_keys(eventObj["description"])

    # Radio Button
    elements = driver.find_elements_by_tag_name("label")
    for elem in elements:
        if elem.text == eventObj["type"]:
            elem.click()

    # Climate Justice Question
    justiceID = ""
    if eventObj["justice"] == "yes":
        justiceID = "checkboxes_450_0"
    if eventObj["justice"] == "no":
        justiceID = "checkboxes_450_1"
    driver.find_element_by_id(justiceID).click()

    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.find_element_by_id(addLeadershipButtonID).click()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)

    # Only Close the TAB
    driver.close()
示例#8
0
def addOrganize(driver, eventObj):
    organizeEventLink = "Organize"
    action = ActionChains(driver)
    attendEventLink = driver.find_element_by_partial_link_text(
        organizeEventLink)
    action.click(on_element=attendEventLink)
    action.perform()

    driver.switch_to.window(driver.window_handles[-1])
    addLeadershipButtonID = "reviews_item_form_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       addLeadershipButtonID):
        print("Page has not loaded in time")
        return
    eventDateID = "date_412"
    eventNameID = "textField_413"
    eventAttendanceID = "textField_415"
    textAreaID = "textarea_418"
    driver.find_element_by_id(eventDateID).send_keys(eventObj["date"])
    driver.find_element_by_id(eventNameID).send_keys(eventObj["name"])
    driver.find_element_by_id(eventAttendanceID).send_keys(
        eventObj["attendance"])
    driver.find_element_by_id(textAreaID).send_keys(eventObj["description"])

    # Radio Button
    elements = driver.find_elements_by_tag_name("label")
    for elem in elements:
        if elem.text == eventObj["type"]:
            elem.click()
    if "photo" in eventObj:
        addPhotoOrganize(driver, eventObj["photo"])
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.find_element_by_id(addLeadershipButtonID).click()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)

    # Only Close the TAB
    driver.close()
示例#9
0
def addEvent(eventObj, credentials, eventBriteLink):    
    eventURL = None
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://realityhub.climaterealityproject.org/home")
    # Page Load
    loginButtonID = "headerLogLink"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, loginButtonID):
        print("Page has not loaded in time")
        return eventURL
    driver.find_element_by_id(loginButtonID).send_keys(Keys.ENTER)
    # Login
    emailFieldID = "email"
    passwordFieldID = "password"
    loginButtonID = "main_login_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, emailFieldID):
        print("Page has not loaded in time")
        return eventURL
    driver.find_element_by_id(emailFieldID).send_keys(credentials["username"])
    driver.find_element_by_id(passwordFieldID).send_keys(credentials["password"])
    driver.find_element_by_id(loginButtonID).send_keys(Keys.ENTER)
    # Go to Events
    actBarID = "navbarDropdown_1"
    attendEventText = "Attend an Event"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, actBarID):
        print("Page has not loaded in time")
        return eventURL
    action = ActionChains(driver)
    actBar = driver.find_element_by_id(actBarID)
    action.click(on_element = actBar)
    action.perform()
    # Need to see it on the screen before you click
    helper.PauseForEffect(1)
    
    # Need to create a new chain every time
    action = ActionChains(driver)    
    attendEventLink = driver.find_element_by_partial_link_text(attendEventText)
    action.click(on_element = attendEventLink)
    action.perform()

    postAnEventID = "html_custom_block_0_0_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, postAnEventID):
        print("Page has not loaded in time")
        return eventURL
    driver.find_element_by_id(postAnEventID).send_keys(Keys.ENTER)
    # Fill Event details
    eventNameID = "textField_event_name"
    startDateID = "dateTime_event_start"
    startTimeID = "dateTime_event_start_time"
    endDateID = "dateTime_event_end"
    endTimeID = "dateTime_event_end_time"
    timeZoneClass = "time-zone-link btn btn-primary"
    timeZoneCountryID = "time_zone_country_select"
    timeZoneCityID = "time_zone_city_select"
    eventVenueID = "textField_event_venue"
    addrLine1ID = "Address_event_address_address_1_input"
    addrLine2ID = "Address_event_address_address_2_input"
    cityID = "Address_event_address_address_city_input"
    stateID = "Address_event_address_state_text"
    postCodeID = "Address_event_address_address_postal_code_input"
    countryID = "Address_event_address_country_select"
    eventTypeID = "dropDown_3031"
    hostNameID = "textField_2818"
    hostEmailID = "textField_2820"
    hostGroupID = "textField_3335"
    eventWebsiteID = "link_3336"
    submitEventID = "events_item_form_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, eventNameID):
        print("Page has not loaded in time")
        return eventURL
    
    # Basic 
    driver.find_element_by_id(eventNameID).send_keys(eventObj["name"])
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.switch_to_frame(0)
    driver.find_element_by_xpath('html/body').send_keys(eventObj["description"])
    driver.switch_to_default_content()
    print("Basic Data Added")

    # Time
    helper.ClearAndAddElement(driver, startDateID, eventObj["start_date"])
    helper.ClearAndAddElement(driver, startTimeID, eventObj["start_time"])
    helper.ClearAndAddElement(driver, endDateID, eventObj["end_date"])
    helper.ClearAndAddElement(driver, endTimeID, eventObj["end_time"])
    
    attendEventLink = driver.find_element_by_partial_link_text("NEW YORK").click()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    select = Select(driver.find_element_by_id(timeZoneCountryID))
    select.select_by_visible_text(eventObj["timeZone_Country"])
    select = Select(driver.find_element_by_id(timeZoneCityID))
    select.select_by_visible_text(eventObj["timeZone_Time"])
    
    print("Time Data Added")
    
    
    # Address 
    driver.find_element_by_id(eventVenueID).send_keys(eventObj["venue"])
    driver.find_element_by_id(addrLine1ID).send_keys(eventObj["addr_line_1"])
    driver.find_element_by_id(addrLine2ID).send_keys(eventObj["addr_line_2"])
    driver.find_element_by_id(cityID).send_keys(eventObj["addr_city"])
    driver.find_element_by_id(stateID).send_keys(eventObj["addr_state"])
    driver.find_element_by_id(postCodeID).send_keys(eventObj["addr_pincode"])
    select = Select(driver.find_element_by_id(countryID))
    select.select_by_visible_text(eventObj["addr_country"])
    print("Address Data Added")

    # Event Type
    select = Select(driver.find_element_by_id(eventTypeID))
    select.select_by_visible_text(eventObj["type"])
    driver.find_element_by_id(hostNameID).send_keys(eventObj["hostName"])
    driver.find_element_by_id(hostEmailID).send_keys(eventObj["hostEmail"])
    driver.find_element_by_id(hostGroupID).send_keys(eventObj["hostOrg"])
    if eventBriteLink:
        eventObj["website"] = eventBriteLink
    element = driver.find_element_by_id(eventWebsiteID)
    element.clear()
    element.send_keys(eventObj["website"])
    

    # Submit
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)
    driver.find_element_by_id(submitEventID).click()
    
    #Ensure event has been completed
    completeButtonID = "send_event_message_button_events_event_message_0_9"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT + 30, completeButtonID):
        print("Page has not loaded in time")
        eventURL = "Event not Created"
    else:
        eventURL = driver.current_url
    driver.close()
    return eventURL
示例#10
0
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
示例#11
0
def addAllLeadership(eventObj, credentials):
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://realityhub.climaterealityproject.org/home")
    # Page Load
    loginButtonID = "headerLogLink"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       loginButtonID):
        print("Page has not loaded in time")
        return
    driver.find_element_by_id(loginButtonID).send_keys(Keys.ENTER)
    # Login
    emailFieldID = "email"
    passwordFieldID = "password"
    loginButtonID = "main_login_button"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT,
                                       emailFieldID):
        print("Page has not loaded in time")
        return

    driver.find_element_by_id(emailFieldID).send_keys(credentials["username"])
    driver.find_element_by_id(passwordFieldID).send_keys(
        credentials["password"])
    driver.find_element_by_id(loginButtonID).send_keys(Keys.ENTER)
    # Go to Events
    actBarID = "navbarDropdown_1"
    recordLeadershipText = "Record an"
    if not helper.HasPageLoadedIDCheck(driver, REALITY_HUB_TIMEOUT, actBarID):
        print("Page has not loaded in time")
        return
    action = ActionChains(driver)
    actBar = driver.find_element_by_id(actBarID)
    action.click(on_element=actBar)
    action.perform()
    # Need to see it on the screen before you click
    helper.PauseForEffect(1)

    # Need to create a new chain every time
    action = ActionChains(driver)
    attendEventLink = driver.find_element_by_partial_link_text(
        recordLeadershipText)
    action.click(on_element=attendEventLink)
    action.perform()
    helper.PauseForEffect(REALITY_HUB_TIMEOUT)

    if "organize" in eventObj:
        allOrganizations = eventObj["organize"]
        for organizeObj in allOrganizations:
            driver.switch_to.window(driver.window_handles[-1])
            addOrganize(driver, organizeObj)

    if "assist" in eventObj:
        allAssists = eventObj["assist"]
        for assistObj in allAssists:
            driver.switch_to.window(driver.window_handles[-1])
            addAssist(driver, assistObj)

    if "participate" in eventObj:
        allParticipates = eventObj["participate"]
        for participateObj in allParticipates:
            driver.switch_to.window(driver.window_handles[-1])
            addParticipate(driver, participateObj)

    if "blog" in eventObj:
        allBlogs = eventObj["blog"]
        for blogObj in allBlogs:
            driver.switch_to.window(driver.window_handles[-1])
            addBlog(driver, blogObj)

    if "resource" in eventObj:
        allResources = eventObj["resource"]
        for resourceObj in allResources:
            driver.switch_to.window(driver.window_handles[-1])
            addResource(driver, resourceObj)

    # All Acts have been added
    # Now Close the window
    driver.quit()
示例#12
0
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()