简体   繁体   中英

Schedule Library for Python Not working as intended

I am creating an application that basically just joins my zoom meetings at their specific times but the problem is that I am using the schedule 1.0 library and it isn't properly working like the function doesn't run at the given time. I tried looking online for anything an I couldn't find a single helpful post thus I am here to ask you guys this question.

My Code

from selenium import webdriver
import time
import schedule
import datetime
from selenium.webdriver.common.keys import Keys
from apscheduler.schedulers.background import BackgroundScheduler


x = input("Is it A day or B day? ")

Advisory = "google.com"
ELA = "google.com"
Economics = "google.com"
French = "google.com"
Math = "google.com"
Social_Studies = "google.com"
Science = "google.com"

browser = webdriver.Safari()



if x.lower() == "a":
    print("Ok great!")
    print("The program will start shortly")
    def AdvisoryLogin():
        browser.get(Advisory)
        obj = browser.switch_to.alert

        msg=obj.text
        print ("Alert shows following message: "+ msg )

        obj.accept()

        browser.close()

    schedule.every().day.at("03:19").do(AdvisoryLogin)
    while True:
        schedule.run_pending()
        time.sleep(1)

I would start with ensuring you have the selenium package installed.

pip install -U selenium

Then I would adjust the code at the input level to reformat to.lower()

import selenium
import time
import schedule
import datetime
from selenium.webdriver.common.keys import Keys
from apscheduler.schedulers.background import BackgroundScheduler


x = input("Is it A day or B day? ")
#x = x.lower()

Advisory = "google.com"
ELA = "google.com"
Economics = "google.com"
French = "google.com"
Math = "google.com"
Social_Studies = "google.com"
Science = "google.com"

browser = webdriver.Safari()



if x.lower() == "a":
    print("Ok great!")
    print("The program will start shortly")
    def AdvisoryLogin():
        browser.get(Advisory)
        obj = browser.switch_to.alert

        msg=obj.text
        print ("Alert shows following message: "+ msg )

        obj.accept()

        browser.close()

    schedule.every().day.at("03:19").do(AdvisoryLogin)
    while True:
        schedule.run_pending()
        time.sleep(1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM