Last night, I'm trying to use selenium with python to make a script fill the body temperature in the website which given by my college
But when I want to use crontab to automatically execute the script, it's always report an error like this
File "/Users/clay_codes1024/PythonProject/FillTemperature.py", line 20, in <module> driver = webdriver.Safari() File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/safari/webdriver.py", line 57, in __init__ self.service.start() File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 98, in start self.assert_process_still_running() File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running raise WebDriverException(selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/safaridriver unexpectedly exited. Status code was: 1
here is my Python code
from selenium import webdriverimport timeaccount = ''password = ''temperature = ''driver = webdriver.Safari()driver.get('')driver.find_element_by_id("username").send_keys(account)time.sleep(2)driver.find_element_by_id("password").click()driver.find_element_by_id("password").send_keys(password)driver.find_element_by_id("passbutton").click()driver.find_element_by_xpath('/html/body/div/div/div/div/div[1]/div[2]/div/form/div[18]/div[1]/div/div[2]/div/div/input').clear()time.sleep(2)driver.find_element_by_xpath('/html/body/div/div/div/div/div[1]/div[2]/div/form/div[18]/div[1]/div/div[2]/div/div/input').send_keys(temperature)time.sleep(2)# use javascript to click the log in buttonjs = 'document.getElementById("post").click();'driver.execute_script(js)time.sleep(5)driver.quit()
what I have done:
1. Give the full disk access to Python3, crontab, terminal2. Use shell script to execute the python script like thisecho 'password' | sudo -S /usr/local/bin/python3 /Users/clay_codes1024/PythonProject/FillTemperature.py3. Turn on the 'Allow remote automation' in safari
All above didn't work!
So pls help me
Huge thanks!!!!!!