How to combine Python+Selenium and Chrome perfectly

Opening: Recently, some students have problems using firefox when learning Selenium, so they want to try chrome, and they encounter various problems when using crome... The following articles are specially organized for the reference of those who encounter this problem

Whole article: How to solve it? Please refer to the following..

  1. Basic environment introduction:

    python3.5 + selenium2.48 (or above) + chrome ( version 65.0.3325.181 64-bit ), of which chrome has been updated to the latest version as of April 2018...

    QQ picture 20180413135326.png

  2. download chromedriver.exe

    The chromedriver.exe file is the driver file that calls chrome, so the version of this file must be compatible with the version of chrome

    The download address of chromedriver.exe is as follows: http://chromedriver.storage.googleapis.com/index.html

    Among them , there are many versions of chromedriver.exe. For chrome ( version 65.0.3325.181 ), the version shown in the figure below (2.37) is downloaded

    QQ picture 20180413135255.png

    Click on version 2.37 in the image above.

    3. Put (copy or move) the downloaded chromedriver.exe (2.37) into the chrome installation directory (generally the installation path of chrome is as follows, C:\Program Files (x86)\Google\Chrome\Application)

    QQ picture 20180413140720.png

   4. Set the system environment variable and add the path of chrome to Path (the specific steps are as follows).

      QQ picture 20180413141651.png

    

   5. Open the IDE (such as pycharm) to write the code and test, the code is as follows:

     QQ picture 20180413141804.png

   6. Run the code in step 5, it is very likely that an error will be reported, giving an error message similar to chromedriver.exe.....path and so on.... How to solve it?

  •       Close all open chrome browsers and run again.

  •        If you close the chrome browser, it still doesn't work, and an error will be reported, then restart the computer, it should be fine

   7. After solving according to the method in step 6, you can call chrome through selenium. . . .

Conclusion: So far, you're done... I hope it helps you


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324479305&siteId=291194637