Ubuntu under Selenium + Chrome installation using

Source: Internet
Author: User

Why use Selenium + Chrome/firefox? Not everyone uses PHANTOMJS. My test found that I do not know what is the reason, Phantomjs always avoid innocent bug. Maybe it's a version incompatibility issue. I chose Selenium + Chrome/firefox. Sometimes when using chrome, some of the click buttons simulate a click Error, saying that element is not clickable. (excluding the case with a mask above), this is possible with Firefox. So use the use to see the situation

First: We have Chrome installed in Ubuntu or Firefox

Install Chrome in Ubuntu

The first step:
Download the Deb file to go to Google's website to download https://www.google.cn/chrome/
Pull to the bottom ' other versions download '

Step Two:
Installation Instructions:

sudo dpkg -i google-chrome-stable_current_amd64.deb

The installation process may have dependency errors. such as:
DPKG: Error processing package google-chrome-stable (–install):
Dependency issues-Still not configured

Step three: Update the dependency package

(If there is an error in the second step, then the instruction to perform this step)

 sudo apt-get -f install

Fourth step: See if the installation is successful

Find the installation path by Whereis Google-chrome

[email protected]:~/桌面$ whereis google-chromegoogle-chrome: /usr/bin/google-chrome      /usr/share/man/man1/google-chrome.1.gz

Indicates that the installation was successful.

Fifth Step:

[email protected]:~/桌面$  /usr/bin/google-chrome 即可打开

Second: Install Selenium

Direct use of Pip install Selenium. Don't repeat it.

Again: Download Chromedriver (Firefox uses geckodriver) driver

http://npm.taobao.org/mirrors/chromedriver/Download driver here

After downloading, place the Chromedriver file under/usr/bin

sudo mv chromedriver路径 /usr/bin

Run.

from selenium import webdriverfirefox = webdriver.Chrome()firefox.get(‘https://www.douban.com/‘)login_xpath = ‘//input[@class="bn-submit"]‘firefox.find_element_by_xpath(login_xpath).click()

Note: If Chrome is turned on, an error occurs

–ignore-certificate-errors. The reasons are:

Google-chrom version and Chromedriver version are incompatible

Solve:
chrome://version/View Google version
65.0.3325.162 (official version) (64-bit)

Chromedriver–version
Chromedriver 2.37.543619 (A237ACD3116CAC3B3F0DA42A000502CE3FAFCB23)

These two versions are compatible

Ubuntu under Selenium + Chrome installation using

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.