Python Selenium automation-environment building

Source: Internet
Author: User

Installing Python and Pip are described in the above article, not here. Install Seleinum directly

PIP3 Install Selenium

After the installation is complete,

PIP3 Show Selenium

Show

Name:selenium
version:3.4.3
Summary:python Bindings for Selenium
home-page:https://github.com/seleniumhq/selenium/
Author:unknown
Author-email:unknown
License:apache 2.0
Location:c:\program files\python35\lib\site-packages
Requires:

Proof of Successful Installation:

Now to test one, write a file baidu.py

#coding =utf-8

From selenium import Webdriver

Driver = Webdriver. Firefox ()
Driver.get ("http://www.baidu.com")

driver.find_element_by_id ("kw"). Sed_keys ("Selenium2")
driver.find_element_by_id ("su"). Click ()
Driver.quit ()

Once saved, execute Python baidu.py

Error:

File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriver/firefox/webdriver.py ", line +, in __init__self.service.start () File"/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/ selenium/webdriver/common/service.py ", Line, Startos.path.basename (Self.path), self.start_error_message)  Selenium.common.exceptions.WebDriverException:Message: ' geckodriver ' executable needs to is in PATH. This time, need to download geckodriver.exe:https://github.com/mozilla/geckodriver/releases Please select the download according to the system version, (such as Windows 64-bit system) After downloading the extract, copy the Getckodriver.exe to the Firefox installation directory, such as (C:\Program Files\Mozilla Firefox) and add the path in the environment variable path: C:\Program files\ Mozilla Firefox; If run, also reported error selenium.common.exceptions.WebDriverException:Message:Unable to find a Matchin g set of capabilitiesThis note, Geckodriver.exe and Firefox version inconsistency caused by the need to find the corresponding version. OK, it's not too early, good night!

Python Selenium automation-environment building

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.