Use python + selenium in windows to open firebox and pythonfirebox
Install selenium through pycharm
1. Configure python and pycharm, open pycharm, click File> Setting> Project Interpreter in the upper left corner, and click Add on the right.
2. In the displayed window, enter selenium, select selenium, and click install package in the lower left corner. The installation is successful, and the version number is displayed on the right.
3. Create a python file and enter the following code to open the Firefox browser:
4.1 after running, the following error occurs:
Selenium. common. exceptions. WebDriverException: Message: 'geckodriver 'executable needs to be in PATH
Information Display geckodriver must be in the path environment variable
The cause of this error is that the firebox browser version on the local machine is relatively high.
Solution:
Download geckodriver at: https://github.com/mozilla/geckodriver/releases
Find the downloaded directory and add the installation path of geckodriver.exe to the path.
4.2 After the preceding method is modified, the following error occurs when the system runs again:
Selenium. common. exceptions. WebDriverException: Message: Unable to find a matching set of capabilities
Information Display: geckodriver and selenium versions are incompatible
My version: selenium3.10.0 geckodriver V0.15.0
4.3 after the change, the system still reports an error (Khan ~)
Selenium. common. exceptions. SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz: firefoxOptions. binary 'capability provided, and no binary flag
It took me a lot of effort to solve this error... No matter how you do it, this error message is still reported. It will not work if you Upgrade Firefox to the highest version. Finally, I re-installed Firefox and added the installation path of Firefox to the path. (The prompt is as follows: multiple paths must be separated by semicolons (;). I do not know the reason for installation or other reasons. I have no file name when installing the D Drive, the file path is D: \ (which may be the cause of my failure). So I created a new directory!