Selenium + python + shell + crontab + firefox, seleniumcrontab

Source: Internet
Author: User
Tags selenium python

Selenium + python + shell + crontab + firefox, seleniumcrontab

I have recently tried an automatic punching script and found several problems. I would like to record them here.

Environment:

Ubuntu 12.04.4 LTS

Selenium 2.43.0

Firefox 32.0.3

 

1 selenium and firefox are installed on the machine, but firefox is updated from time to time, So selenium may not support the current firefox version.

The selenium update command:

Sudo pip install-U selenium

 

2. Python script used:

 1 #!/usr/bin/env python 2  3 import sys 4 from selenium import webdriver 5  6 url = "http://XXX.com/" 7 driver = webdriver.Firefox() 8  9 driver.get(url+ "/")10 driver.find_element_by_xpath("//div[2]/input").send_keys("XXX")11 driver.find_element_by_xpath("//div[3]/input").send_keys("XXX")12 driver.find_element_by_id("loginButton").click()13 driver.find_element_by_css_selector("a > img").click()14 15 driver.quit()

 

3 crontab:

Crontab-l: displays the scheduled tasks of the current user.

Crontab-e: edit the scheduled task of the current user

Actually used commands:

0 18 ** 1-5 export DISPLAY =: 0.0 & python/home/yzzw006/Wifi/yzzw_doc/kq. py

Note the following two points:

1 because the task must open a browser at the front end, you must add "export DISPLAY =: 0.0 ";

2. Use the absolute path whenever possible for the script address executed in crontab.

 


Selenium python cannot start firefox (selenium 2421 firefox30)

Hello! I'm glad to answer your questions.
According to your information, the configuration file cannot be loaded. We recommend that you store your browser configuration file in the location indicated by the error message and try again. In addition, selenium does not explicitly state that it supports firefox30. Therefore, we recommend that you use a lower version for testing.
If you have any questions about our answers, please continue.

Python selenium error when using this module to open Firefox browser

Dear user! I'm glad to answer your questions.
According to your description, when you use a script to start the Firefox browser, the default configuration file of the browser is not loaded, but the configuration is created. We recommend that you go to the configuration file to check whether the problem exists.
I hope my answers will be helpful to you. If you have any questions, please continue to consult us.
Firefox enterprise Platform [Official Certification]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.