When using selenium for Web automation testing, if the browser is using Firefox, there are some issues to be aware of in Selenium version selection and Firefox version selection and whether a separate Webdriver driver is required.
After installing selenium (pip3 install selenium), you will also need to install the driver Geckodriver. It is important to note that there is a version issue between them.
When you run the program with the following error, it may be the version issue.
Selenium.common.exceptions.WebDriverException:Message:connection refused
At first, I have been xshell operation, this will be an error. Then directly to the virtual machine terminal interface to directly operate, you can open Firefox, but there is no follow-up reflection, and then burst the above error. I query for half a day, first Firefox update to Mozilla Firefox 52.8.0, but still have problems, and finally looked at the Geckodriver version of Geckodriver 0.20.1, found that its version is too high (so not the newer the better). Finally, geckodriver 0.18.0 version: geckodriver-v0.18.0-linux64.tar.gz (: https://github.com/mozilla/geckodriver/releases) was downloaded.
Switch to the download path and enter the following command:
Tar-xvzf geckodriver*
chmod +x geckodriver
sudo mv geckodriver/usr/local/bin/
At this point, the Geckodriver installation is configured successfully.
I did not find the corresponding relationship between Firefox and the version of the driver Geckodriver, which is only for reference.
Reference article:
77268924
78803230
Configuration issues for Python3+firefox+geckodriver