def main():
    driver = driver_setup("https://www.alexa.com/siteinfo", headless=False)
    try:
        f1 = open(os.path.join(sys.path[0], "sites.txt"), "r")
    except OSError:
        print("Could not open/read file: sites.txt")
        sys.exit()
    d = {}
    for url in f1:
        d[url.rstrip()] = get_statistics(driver, url)
        driver.back()
    f1.close()

    try:
        f2 = open(os.path.join(sys.path[0], "output.json"), "w")
    except OSError:
        print("Could not open file: output.json")
        sys.exit()

    try:
        f2.write(json.dumps(d))
    except OSError:
        print("Could not write file: output.json")
        sys.exit()

    f2.close()
    driver.close()
def main():

	load_dotenv()
	password = os.environ.get('GMAIL_PASSWORD')
	email = os.environ.get('GMAIL_EMAIL')

	driver = driver_setup("https://www.google.com/intl/en/gmail/about/")
	gmail_sign_in(driver, email, password)
	gmail_get_emails(driver)
	gmail_new_email(driver, email)
def main():
    driver = driver_setup("https://www.youtube.com/")

    google_cookies_fullscreen(driver)

    load_dotenv()
    password = os.environ.get('PASSWORD')
    email = os.environ.get('EMAIL')
    youtube_sign_in(driver, email, password)
    driver.get('https://www.youtube.com/feed/trending')

    pick_a_random_video(driver)
    time.sleep(200)
def main():

    l = open_file()
    while (True):
        try:
            rand_url = choice(l)
            driver = driver_setup(rand_url)
            break
        except Exception as e:
            print(f"{rand_url} timed out.")
            continue

    click_on_stuff(driver)
    driver.close()
def main():
    load_dotenv()
    password = os.environ.get('FACEBOOK_PASSWORD2')
    email = os.environ.get('FACEBOOK_EMAIL2')

    driver = driver_setup("https://el-gr.facebook.com/")
    accept_cookies(driver)
    facebook_sign_in(driver, email, password)
    accept_cookies(driver)
    if random.random() < 0.5:
        click_messenger_button(driver)
        send_message_to_a_random_contact(driver)
    else:
        search_element("ECE NTUA 2020", driver)
        click_random_link(driver)
        time.sleep(100)
def main():
    load_dotenv()
    password = os.environ.get('OUTLOOK_PASSWORD')
    email = os.environ.get('OUTLOOK_EMAIL')
    driver = driver_setup("https://outlook.live.com/owa/")
    outlook_sign_in(driver, email, password)

    #50-50 to read received emails or type new email
    if random.random() < 0.5:
        click_inbox(driver)
        emails = get_emails(driver)
        random.choice(emails).click()
        time.sleep(10)
    else:
        new_email(driver, email)
        time.sleep(10)
def outlook(visit_duration, pages_per_visit, bounce_rate):

    # Get the visit duration and the duration per page list
    deci, integ = math.modf(visit_duration)
    visit_duration = integ * 60 + deci
    logging.info(f"  --visit duration(secs): {visit_duration:.2f}")
    logging.info(f"  --pages per visit: {pages_per_visit}")
    duration_per_page_list = sequence_that_sums(visit_duration,
                                                pages_per_visit)
    logging.info(
        f"  --duration per page list(secs): {duration_per_page_list.round(decimals=2)}"
    )

    # Check if the pages_per_visit == 1 (bounce)
    bounce = False
    if bounce_rate / 100 > random.random():
        bounce = True
        logging.info("  --bounce")

    # Sign in to outlook
    load_dotenv()
    password = os.environ.get('OUTLOOK_PASSWORD')
    email = os.environ.get('OUTLOOK_EMAIL')
    driver = driver_setup("https://outlook.live.com/owa/")
    outlook_sign_in(driver, email, password)

    #50-50 to read received emails or type new email
    if random.random() < 0.5:
        logging.info("(outlook)Mode: Browsing on random emails")
        click_inbox(driver)
        emails = get_emails(driver)
        for duration in duration_per_page_list:
            random.choice(emails).click()
            time.sleep(1)  #insert 1 second here for testing
            if bounce:
                break
    else:
        logging.info("(outlook)Mode: Creating new email")
        new_email(driver, email)
        time.sleep(duration_per_page_list[0])
    driver.close()
def youtube(visit_duration, pages_per_visit, bounce_rate):

    # Get the visit duration and the duration per page list
    deci, integ = math.modf(visit_duration)
    visit_duration = integ * 60 + deci
    logging.info(f"  --visit duration(secs): {visit_duration:.2f}")
    logging.info(f"  --pages per visit: {pages_per_visit}")
    duration_per_page_list = sequence_that_sums(visit_duration,
                                                pages_per_visit)
    logging.info(
        f"  --duration per page list(secs): {duration_per_page_list.round(decimals=2)}"
    )

    # Check if the pages_per_visit == 1 (bounce)
    bounce = False
    if bounce_rate / 100 > random.random():
        bounce = True
        logging.info("  --bounce")

    # Log in to youtube
    load_dotenv()
    password = os.environ.get('YOUTUBE_PASSWORD')
    email = os.environ.get('YOUTUBE_EMAIL')
    driver = driver_setup("https://www.youtube.com/")
    google_cookies_fullscreen(driver)
    youtube_sign_in(driver, email, password)

    # Start watching videos.
    logging.info("(youtube)Mode: Browsing on random trending videos")
    for duration in duration_per_page_list:
        driver.get('https://www.youtube.com/feed/trending')
        pick_a_random_video(driver)
        time.sleep(1)  #insert 1 second here for testing
        if bounce:
            break

    driver.close()
def facebook(visit_duration, pages_per_visit, bounce_rate):

    # Get the visit duration and the duration per page list
    deci, integ = math.modf(visit_duration)
    visit_duration = integ * 60 + deci
    logging.info(f"  --visit duration(secs): {visit_duration:.2f}")
    logging.info(f"  --pages per visit: {pages_per_visit}")
    duration_per_page_list = sequence_that_sums(visit_duration,
                                                pages_per_visit)
    logging.info(
        f"  --duration per page list(secs): {duration_per_page_list.round(decimals=2)}"
    )

    # Check if the pages_per_visit == 1 (bounce)
    bounce = False
    if bounce_rate / 100 > random.random():
        bounce = True
        logging.info("  --bounce")

    # Sign in to facebook
    load_dotenv()
    password = os.environ.get('FACEBOOK_PASSWORD1')
    email = os.environ.get('FACEBOOK_EMAIL1')
    driver = driver_setup("https://el-gr.facebook.com/")
    accept_cookies(driver)
    facebook_sign_in(driver, email, password)
    accept_cookies(driver)

    # Open the facebook_search_queries.txt that contains possible search queries
    try:
        logging.info("(facebook)Opening file: facebook_search_queries.txt")
        file = open(os.path.join(sys.path[0], "facebook_search_queries.txt"),
                    "r")

    except OSError:
        logging.info(
            "(facebook)Could not open/read file: facebook_search_queries.txt")
        return -1

    # Create a list with the search queries and close the file
    logging.info("(facebook)Creating search queries list")
    l = []
    for search_query in file:
        l.append(search_query.rstrip())
    file.close()

    #50-50 to browse or send a message
    if random.random() < 0.5:
        logging.info("(facebook)Mode: Browsing on facebook")
        for duration in duration_per_page_list:
            driver.get("https://el-gr.facebook.com/")

            search_query = random.choice(l)
            search_element(search_query, driver)
            click_random_link(driver)
            time.sleep(10)  #insert 5 seconds here for testing
            if bounce:
                break
    else:
        logging.info("(facebook)Mode: Going on messenger")
        click_messenger_button(driver)
        send_message_to_a_random_contact(driver)
        time.sleep(duration_per_page_list[0])
    driver.close()