<jupyter_start><jupyter_text>login Tests<jupyter_code>def get_keys(path):
    with open(path) as f:
        return json.load(f)
def login():   
    keys = get_keys("/Users/jason/Documents/github/.secret/shift_getter.json")
    user_id = keys['id']
    key = keys['key']
    
    # open instance of safari
    #driver = webdriver.Safari()
    
    #opens atoz site
    webpage = 'https://idp.amazon.work/idp/profile/SAML2/Unsolicited/SSO?providerId=idp.federate.amazon.com&target=AYABeDXV3hDUSSY25pC9f8bGHVUAIwABAAN0eG4AGkVSTDhLUjRDVUdBRFAwSzBSQlBOQlFETTMwAAEAB2F3cy1rbXMAS2Fybjphd3M6a21zOnVzLWVhc3QtMTo2NDIzOTcxNzAzNTA6a2V5LzMxYTMwMTRhLTJmZjYtNDNjYi05YTc2LTYyMzIwYzdjN2NjMwC4AQIBAHhfEd4mF0OXYA9y9TmTDqNwOjTJBgpE6Kp4%2FIYxLfav9gFsTwPCEAxqHl2ktZFPwpsjAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMAYSBv%2Bne2vqIhDDxAgEQgDsknIw0QzgVzxA9a2gvZRKLuuurtP7HPBrAb4x5EyBoSbE6IyB3a3HlEp9IAuE9JaFAz9yeL7HBsfXWDwIAAAAADAAAEAAAAAAAAAAAAAAAAAA6U9cectPQRX1wVjjx2IYe%2F%2F%2F%2F%2FwAAAAEAAAAAAAAAAAAAAAEAAAOI%2Br90HcjVH5AvxtooT1eiVEGSHAZJEXL7bc4g5sLj5BfL5Sic%2FLmqTPot45PD%2F2%2BpWOB9Bb0%2B7njGXnCUwWwQ%2BiEC2mhUqEgkpmiAQV9YvFKtfjffi8mHyhVnUED8j5G4oIyWNVd2ZONYZUbXfU90KzZAYxAZPk3k0TbOTsthzOvepTZ11HZiKaA1LXV2IaPfDyTzN5uhlNQjEPPiUQRPw1WAdwGqb3mBYzUIRC44pRYgFmR%2FoLeUwvmKCyheAP7I5jhtnHlKSv79jBBTMeCrJ3oZgZTWyQgzRurDm%2Fs5GqyrLxgN%2BePoPmf4zuj8pupyeWYfDqgyVKGYsmbkQzi2ZOmj%2FLHlH%2F7GQ7sZKgn4u%2B6YgecgaM%2BLVzKKT42IKPf%2BiQABIgkUf1Q9eMAOP75%2B6IAlpVRnDWtShQ7FhZgVVLlVOtkk7OjBTKPW72M3lM7bILeCpDdVoNqmu6tbDw2z1NVq7L3ckAMab0oKLzptANKPE0aJkjcfPYYI1NNjuBZIy3OkiyOXKKieHoFNNcgMH6xKoSgH%2BZat472fnifEItXmNcycW64w4WKSbG5zlxNeIGcvDZ9MOHLp1sfbPjxdgayxX3dra6Mk1HfxaMOQjSvAdx92vgHhFadIUCb3j0GOkZQwgjlGZHb2wIOc0lSXht0CBsq12fFVI789PY0qtrouC3Z8hJaehBH12lspoCXwu2P9SUJGrZHvB6b5cvKNkyu0R%2FAHGyjns7stqawloIhZoDLEnHKXA3yF1F8C8qkyaK%2FocmvDYMs9OUu3lG2r%2BJp2bNLH5GVu2q%2B2FktSOq5avK6aJ4CE0WNNh%2B37L6pmKu29pLI2Ft%2BtqtYQCVBy5GGj%2BW33GDs%2BrfwNW0sl9%2B%2BEQqNJYOrdY29PE8NOc19ilFJOwUEEhfKL483elhe02iNUd8r6p4kXpg1vr4NXHC7rUC1%2Bra%2BKHGNNH%2BV5qHWH2xvoDEGweMmh5jYlXOyVZ6X1LHcrHdAzoGZHwHyUoot3RO4N%2FJeVJjXosMGixEaPC8ANo0qYgAGT8Xg3cjPHijAWnO8h3wA%2FuJVhtp7%2FK7JvkhjUsN19RgeMcwkCr4eVYt6sgCTj8f%2BMMlJMcVxx1VGf2sl%2BIjwS9n%2BVPBp9Sulwsk3AKWvbp9MtQ2r4Oyl2QdNzqOzK7MZmaGA%2BmDAXIILPBQhb1%2BDN9P47xyQD%2B8LU7OCvvcXf0ax0S06J43PHp6FWjE0lkg4%3D'
    driver.get(webpage)
    
    try:
        #enter username
        search = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.ID, 'login'))
        )
        search.send_keys(user_id)
        search.send_keys(Keys.RETURN)
        time.sleep(2)
        
        #enter password
        search = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.ID, 'password'))
        )
        search.send_keys(key)
        search.send_keys(Keys.RETURN)
        
        #click to send verification code
        search = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.XPATH, '//*[@id="selectPhone_form"]/div[2]/button'))
        )
        search.click()
        
    except:
        driver.quit()
        
        
    #get verification code from messages
    time.sleep(5)
    verification = get_code()
    
    #enter verification code
    search = driver.find_element_by_id('code')
    search.send_keys(verification)
    search.send_keys(Keys.RETURN)
    time.sleep(15)
    
    #opens page to select shifts
    webpage = 'https://atoz.amazon.work/shifts/schedule/find?ref=nv_schd'
    driver.get(webpage)
    time.sleep(10)<jupyter_output><empty_output><jupyter_text>get latest verification code<jupyter_code>def get_code():    
    # give path to db
    conn = sqlite3.connect("/Users/jason/Library/Messages/chat.db")
    
    # connect to the database
    cur = conn.cursor()
    
    # command to get last 10 messages
    command1 = 'SELECT * FROM message \
                ORDER BY 1 \
                DESC LIMIT 10 '
    
    # executes command
    cur.execute(command1)
    
    # created df from command
    df_msg = pd.DataFrame(cur.fetchall())
    
    # isolate message with code
    code = df_msg[df_msg[5]==138].iloc[0,2]
    
    # isolate code from text
    verification = ''.join(i for i in code if i.isdigit())
    
    return verification<jupyter_output><empty_output><jupyter_text>entering start/end times<jupyter_code>driver = webdriver.Safari()
login()
def start():
    #paths to time inputs
    start_time = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[1]/div[2]/div/form/div/span[1]/input'
    end_time = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[1]/div[2]/div/form/div/span[3]/input'
    
    def enter_start():
        #enter a start time
        search = driver.find_element_by_xpath(start_time)
        search.click()
        search.clear()
        time.sleep(1)
        search.send_keys('01:30 pm')
        search.send_keys(Keys.RETURN)
        time.sleep(5)
        return search.get_attribute('value')
    
    time = enter_start()
    if time == '':
        enter_start()
    
#paths to time inputs
start_time = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[1]/div[2]/div/form/div/span[1]/input'
end_time = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[1]/div[2]/div/form/div/span[3]/input'
#enter a start time
search = driver.find_element_by_xpath(start_time)
search.click()
search.clear()
time.sleep(1)
search.send_keys('01:30 pm')
search.send_keys(Keys.RETURN)
time.sleep(5)
search.get_attribute('value')
#enter an end time
search = driver.find_element_by_xpath(end_time)
#search.click()
search.clear()
time.sleep(1)
search.send_keys('08:30 a')
search.send_keys(Keys.RETURN)
time.sleep(2)<jupyter_output><empty_output><jupyter_text>selecting tic boxes<jupyter_code>all_tic = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[1]/label'
cmk_tic = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[2]/label'
lgv_tic = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[3]/label'
wbu_tic = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[4]/label'
tic_box = driver.find_element_by_xpath(wbu_tic)
tic_box.click()<jupyter_output><empty_output><jupyter_text>check to see if boxes are checked/unchecked<jupyter_code>all_check = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[1]/input'
cmk_check = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[2]/input'
lgv_check = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[3]/input'
wbu_check = '//*[@id="schedule-app"]/div/div[2]/div/div[2]/div/div[2]/div/fieldset[3]/div[2]/div/form/div[4]/input'
tic_check = driver.find_element_by_xpath(cmk_check)
print(tic_check.is_selected())
def select_site():
    tic_check = driver.find_element_by_xpath(all_check)
    if tic_check.is_selected():
        # uncheck all sites
        tic_box = driver.find_element_by_xpath(all_tic)
        tic_box.click()
        
        # check cmk site
        tic_box = driver.find_element_by_xpath(cmk_tic)
        tic_box.click()
    else:
        # check all sites
        tic_box = driver.find_element_by_xpath(all_tic)
        tic_box.click()
        
        # uncheck all sites
        tic_box = driver.find_element_by_xpath(all_tic)
        tic_box.click()
        
        # check cmk site
        tic_box = driver.find_element_by_xpath(cmk_tic)
        tic_box.click()        
select_site()<jupyter_output><empty_output><jupyter_text>click on day buttons<jupyter_code>day1 = '//*[@id="daySelector"]/div[1]/button[1]'
day2 = '//*[@id="daySelector"]/div[1]/button[2]'
day3 = '//*[@id="daySelector"]/div[1]/button[3]'
day4 = '//*[@id="daySelector"]/div[1]/button[4]'
day5 = '//*[@id="daySelector"]/div[1]/button[5]'
day6 = '//*[@id="daySelector"]/div[1]/button[6]'
day7 = '//*[@id="daySelector"]/div[1]/button[7]'
now = datetime.now()
# get day of the week
now.weekday()
pick_day = driver.find_element_by_xpath(day3)
pick_day.click()
driver.refresh()
#location where shift list will be (if none present will not be there)
//*[@id="schedule-app"]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]/ul
#location of first shift button
//*[@id="schedule-app"]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]/ul/li[1]/div/div/div[3]/div[2]/button<jupyter_output><empty_output><jupyter_text>select shift<jupyter_code>#location of first shift button
first_shift = '//*[@id="schedule-app"]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]/ul/li[1]/div/div/div[3]/div[2]/button'
//*[@id="schedule-app"]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]/ul/li[1]/div/div/div[3]/div[2]/button
pick_shift = driver.find_element_by_xpath(first_shift)
pick_shift.click()
#refresh page at specific time

# datetime object containing current date and time
now = datetime.now()

t1 = timedelta(hours=now.hour, minutes=now.minute, seconds=now.second, microseconds= now.microsecond)
t2 = timedelta(hours=18, minutes=15, seconds=0)

duration = t2 - t1

print(t1)
print(t2)
print(duration)

sleep = duration.total_seconds()

time.sleep(sleep)

driver.refresh()

#click to pick shift
pick_shift = WebDriverWait(driver, 20).until(
    EC.presence_of_element_located((By.XPATH, first_shift))
)
pick_shift.click()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14596306068601583, 'fraction_numerical': 0.05044854881266491, 'mean_word_length': 4.687875150060024, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '648600', 'license': 'MIT', 'n_tokens_mistral': 4439, 'n_tokens_neox': 4235, 'n_words': 388, 'path': 'Selenium_tests.ipynb', 'repo_name': 'venusian2/shift_getter', 'size': '9475'}