selenium installation --- Google (from selenium import webdriver error)

Installation selenium steps:

1. Install pip (cmd command line administrator mode):

pip install pip

You can also directly search pip, the official website to download and install

2. Install the Selenium (Administrator cmd command line mode) :

pip install -U selenium

3. Install Google Drive:

Wherein the drive version to the version that corresponds with Google

I do not know if you can see the link https://npm.taobao.org/mirrors/chromedriver/

The drive is placed into the root directory of the python installation directory, there are kinds of argument is put Scripts, I did not feel two kinds of problems like

4. In tests in pycharm:

from selenium import webdriver

driver = webdriver.Chrome()

driver.maximize_window()

driver.get('http://www.baidu.com')

The desired effect: Baidu will open interface to maximize page

 Congratulations on the success of the configuration is complete it! ! !

 

If not successful, then read on. . .

Among them, pay attention: from the Selenium Import webdriver error likely cause is:

Is not introduced into the new project A. selenium, need to file ----> setting ----> project: ----> Project Interprester

Add and clicking on the left button to install selenium, pip

 

 

 

B.python repository configuration choose incorrectly, you need to select the corresponding item Python

 

 

C. to the most silent, if the above have confirmed that there is no problem, but still reported webdriver red line, then take a look at their own error code path is not a file called selenium.py, and if so, the name change to change it well, no surprise surprise? ! Meaning no accident? ! ! This is because when imported, pycharm prefers selenium.py file before we create. So if you want to create our own file selenium.py changed names just fine!

 

the above.

 

Guess you like

Origin www.cnblogs.com/suijing-luck/p/11468978.html