Recently in a script to try an automatic punch, found a few questions, hereby recorded.
Environment:
Ubuntu 12.04.4 LTS
Selenium 2.43.0
Firefox 32.0.3
1 Originally the machine Selenium,firefox are installed, but Firefox updates from time to time, so selenium may not support the current version of Firefox.
Update Selenium command:
sudo pip install-u Selenium
2 python script used:
1 #!/usr/bin/env python2 3 ImportSYS4 fromSeleniumImportWebdriver5 6URL ="http://XXX.com/"7Driver =Webdriver. Firefox ()8 9Driver.get (url+"/")TenDriver.find_element_by_xpath ("//div[2]/input"). Send_keys ("XXX") OneDriver.find_element_by_xpath ("//div[3]/input"). Send_keys ("XXX") ADRIVER.FIND_ELEMENT_BY_ID ("Loginbutton"). Click () -Driver.find_element_by_css_selector ("a > IMG"). Click () - theDriver.quit ()
3 Crontab Automatic task-related commands:
Crontab-l: Displays the current user's scheduled tasks
CRONTAB-E: Editing the current user's scheduled tasks
The actual command used:
0 * * 1-5 export display=:0.0 && python/home/yzzw006/wifi/yzzw_doc/kq.py
Here are two points to note:
1 because the task must be opened in the foreground browser, it must be added "export display=:0.0";
2 script address executed in crontab use absolute path as far as possible
Selenium+python+shell+crontab+firefox