Selenium3 automated test [5] browser driver installation (FireFox)

Selenium supports various browsers, and readers can carry out automated tests in different browsers. It supports browsers including IE, FireFox, Chrome, Opera, Safari, etc. This lecture will focus on the combination of commonly used FireFox, Chrome and Selenium.
Since Selenium3.0 calls FireFox48 (including 48) and above, you need to install the driver of the browser first, so this section explains the installation of the browser driver.

FireFox browser

geckodriver deployment

Download the FireFox driver (geckodriver.exe). The download address of the FireFox browser driver is: https://gitHub.com/mozilla/geckodriver/releases .
Selenium3 automated test [5] browser driver installation (FireFox)
The operating system I use is windows 10 64 bit, so download [geckodriver-v0.24.0-win64.zip] (used by the author) FireFox browser corresponds to the driver version, which can be found in the information package provided in this book).

After decompressing the downloaded geckodriver compressed package, copy geckodriver.exe to the Python installation directory (the author's Python installation path is C:\Program Files\python36), as shown in the figure.
Selenium3 automated test [5] browser driver installation (FireFox)

[Note]:
Python, FireFox, and geckodriver must be added to the environment variables during the build process. Because Python has been added to the environment variables, you can directly put geckodriver in the Python installation file.

Verify Selenium

Run cmd as an administrator, enter Python in the cmd command window, enter the Python editing state, and enter commands in sequence:

  1. from selenium import webdriver
  2. After webdriver.Firefox()
    deploys geckodriver to the Python installation directory, you can see that the FireFox browser is successfully invoked. It also verified that Selenium can work perfectly.
    Selenium3 automated test [5] browser driver installation (FireFox)
    Type the test code in the PyCharm IDE and run it. You can see that the FireFox browser is successfully called and the bing homepage is opened.
    Selenium3 automated test [5] browser driver installation (FireFox)

    Possible problems

  3. Question 1: Message:'geckodriver' executable needs to be in PATH.
    Solution: Download the geckodriver.exe driver file. Find the path of geckodriver.exe and configure it in the environment variable PATH. It is also possible to use the method in this section to put it directly in the Python installation directory.
  4. Question 2: Message: Expected browser binary location, but unable to find binary in default location, no'moz:FireFoxOptions.binary' capability provided, and no binary flag set on the command line.
    Solution: The file FireFox.exe also needs to be configured under the environment variable path. After installing FireFox, find the address of the file FireFox.exe and add it to the PATH. Such as C:\Program Files\Mozilla FireFox\FireFox.exe, as shown in the figure.
    Selenium3 automated test [5] browser driver installation (FireFox)
    Selenium3 automated test [5] browser driver installation (FireFox)

Guess you like

Origin blog.51cto.com/starpoint/2544185