macos - Mac下crontab 无法执行selenium
本文介绍了macos - Mac下crontab 无法执行selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
#-*- coding: UTF-8 -*-
#!/usr/bin/env python
print("test - 1")
import sys
from selenium import webdriver
print("test - 2")
url = "http://XXX.com/"
driver = webdriver.Firefox()
driver.get(url+ "/")
driver.find_element_by_xpath("//div[2]/input").send_keys("XXX")
driver.find_element_by_xpath("//div[3]/input").send_keys("XXX")
driver.find_element_by_id("loginButton").click()
driver.find_element_by_css_selector("a > img").click()
driver.quit()
代码如上图
crontab 配置:
export DISPLAY=:0.0 && python /Users/l/Downloads/phantomjs-2.1.1-macosx/bin/release-day/test.py >> /Users/l/Downloads/log
输出结果为:
test - 1
请教是什么问题?解决方案是什么?
解决方案
还是自己解决了:
python记得要给全路径,而且该python是带有selenium环境的python,定时调度之前,记得先执行一下哦!
这篇关于macos - Mac下crontab 无法执行selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文