Python Selenium Development environment configuration

Source: Internet
Author: User

Selenium is a Web test application framework that can also be used as a crawler.

1. Installing the Selenium module

Pip Install-u Selenium

2. After installing the Selenium module, the corresponding browser driver is required.

A. Using PHANTOMJS

PHANTOMJS is a test browser with no interface

I'm using phantomjs-2.1.0-linux-x86_64 as long as I use the PHANTONJS in the Phantomjs-2.1.0-linux-x86_64 folder directly.

1  from Import Webdriver 2 3 Driver = Webdriver. Phantomjs ('/home/xx/xx/phantomjs-2.1.0-linux-x86_64/bin/phantomjs')## Inside is the address of Phantomjs 4 driver.get ("http://www.baidu.com")   

This allows you to use driver to operate a browser with no interface.

PHANTOMJS:

B. Have a meeting with the Chrome browser installation configuration

First you need to install the Chrome browser and configure the relevant environment

  sudo apt-get install libxss1 libappindicator1 libindicator7  wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb  sudo dpkg -i google-chrome*.deb  sudo apt-get install -f
  sudo apt-get install xvfb
  sudo apt-get install unzip
  wget -N http://chromedriver.storage.googleapis.com/2.26/chromedriver_linux64.zip  unzip chromedriver_linux64.zip  chmod +x chromedriver
  sudo mv -f chromedriver /usr/local/share/chromedriver  sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver  sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
  安装相关selenimu
  sudo apt-get install python-pip
  pip install pyvirtualdisplay selenium

Test code

1  from Import Display 2  from Import Webdriver 3 Driver = webdriver. Chrome ()4 driver.get (' https://www.baidu.com/')5 Print Driver.title

RELATED Links: https://christopher.su/2015/selenium-chromedriver-ubuntu/

Python Selenium Development environment configuration

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.