Python3.7, Eclipse 4.5, Java 8, PyDev 5.2.0, selenium-3.14.0 Environment Building

Source: Internet
Author: User
Tags tag name



The Python environment builds Eclipse 4.5, Java 8, PyDev 5.2.0, Python3.7, selenium-3.14.0



1 installation Python



: http://www.python.org/



Python has 32 versions of Python 2 and Python. There are some differences in grammar.



I install Python 3.7.0



To configure environment variables after installation



2 installation JAVA JDK



: http://www.oracle.com/technetwork/java/javase/downloads/index.html



Eclipse requires this to install the Java JDK before it can run.



Python3.7 to install jdk8.0 or later



3 Development Environment Download Eclipse



http://www.eclipse.org/downloads/to this download.



Once downloaded, the decompression can be used directly, and eclipse does not need to be installed.



4 Editor : Eclipse + pydev Plugins



(1) Eclipse is the IDE that writes Java, so it can be generalized and the learning cost is small. Learn eclipse and write Python or Java later.



(2) Eclipse, a powerful feature.



(3) Eclipse cross-platform, can run on Mac and Windows



5 Eclipse installed in Pydev Plugins



Pydev Plugin's official website: http://www.pydev.org/






(1) Download down PyDev PyDev 5.2.0 after decompression will






Put it in the appropriate directory for Eclipse






(2) Online installation



Launch Eclipse, click Help->install New software ...  In the popup dialog box, click the Add button. Name fill in: Pydev, location fill http://pydev.org/updates



Then, step by step, put it down. If the process of loading, error. Re-install it.


















6 Eclipse Configuration Pydev Interpreter



After installing Pydev, you need to configure the Python interpreter.



In the Eclipse menu bar, click Windows->preferences.



In the dialog box, click Pydev->interpreter-python. Click the New button, select the path of the Python.exe, and open it to display a window with many check boxes. Click OK



If it is a Mac system, click the "Auto Config" button












7 Python Integrated Selenium



Method: Offline Installation



(1) First download Selenium installation package: Https://pypi.python.org/pypi/selenium#downloads



(2) Unzip after download



(3) Go to the command line, switch to the installation package path, enter the Python setup.py install command to perform the setup.py file installation selenium.



See in finished processing dependencies for selenium==3.6.0 installation succeeded



Of course, you can also use the PIP Show Selenium command to view Selenium installation status





















Note: The installation must appear finished processing .....



If there are other situations such as time out, you must reinstall





8 Download the driver for your browser






Google Browser driver Chromedriver



http://npm.taobao.org/mirrors/chromedriver/






Download down Chromedriver.exe and put it under Python's D:\python3.7\Scripts directory






Notes.txt inside can see Google each version of the corresponding chromedriver









Note that the browser driver must correspond to the version of the browser, without any problems.



This is due to the wrong version of the exception caused by the situation



The browser started successfully, but the address could not be entered, error: connectionreseterror: [Winerror 10054] The remote host forced the shutdown of an existing connection.



The browser appears as follows:









9 Start writing code



Start Eclipse, create a new project, file->new->projects ... Select Pydev->pydevproject to enter the project name.









New PyDev package. You can write the code.






Examples are as follows:


‘‘ ‘
Created on August 9, 2018

@author: Administrator
‘‘ ‘

# Introduce time module
import time

# Introduce webdriver from selenium

from selenium import webdriver

import sqlite3

# Create a browser object, it will automatically open when running
driver = webdriver.Chrome ()
# Open URL
driver.get (‘http://www.baidu.com’)

time.sleep (1)

print (driver.page_source)

# Find the input box tag in html based on id
input_kw = driver.find_element_by_id (‘kw’)
# Enter the content to be searched into the input box
input_kw.send_keys (‘python‘)
# Find Baidu button
button = driver.find_element_by_id (‘su’)
# Click the button
button.click ()
# Sleep
time.sleep (1)
# Quit the browser
driver.close ()

# Find the tag by the value of the class attribute in the html tag
# driver.find_element_by_class_name ()
# Find the label by the text content of the hyperlink
# driver.find_elements_by_link_text (‘News’)
# By tag name [attribute name = "attribute value"]
# Via css style selector
# driver.find_element_by_css_selector (‘button [type =" submit "]‘) 














Python3.7, Eclipse 4.5, Java 8, PyDev 5.2.0, selenium-3.14.0 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.