SeleniumBase/help_docs/webdriver_installation.md

91 lines
4.0 KiB
Markdown
Raw Normal View History

2022-08-06 06:27:38 +08:00
## [<img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32">](https://github.com/seleniumbase/SeleniumBase/) Installing webdrivers
2017-11-02 02:09:00 +08:00
2022-08-06 06:27:38 +08:00
To run web automation, you'll need webdrivers for each browser you plan on using. With SeleniumBase, drivers are downloaded automatically as needed into the SeleniumBase ``drivers`` folder.
2017-10-31 09:59:24 +08:00
2022-08-06 06:27:38 +08:00
You can also download drivers manually with these commands:
2018-08-01 02:47:10 +08:00
```bash
2022-08-07 11:10:59 +08:00
sbase get chromedriver
sbase get geckodriver
sbase get edgedriver
2018-08-01 02:47:10 +08:00
```
2021-01-28 00:54:19 +08:00
2022-10-02 08:28:31 +08:00
* To get the latest ``chromedriver`` when you don't have the latest Chrome, use:
2021-01-28 00:54:19 +08:00
2019-11-11 12:58:02 +08:00
```bash
2022-08-07 11:10:59 +08:00
sbase get chromedriver latest
2019-11-11 12:58:02 +08:00
```
2021-01-28 00:54:19 +08:00
2022-09-02 04:27:34 +08:00
* You can also get a specific version of chromedriver for a specific version of Chrome:
2021-01-28 00:54:19 +08:00
2020-06-08 01:41:56 +08:00
```bash
2022-10-02 08:28:31 +08:00
sbase get chromedriver 105.0.5195.52
2021-01-28 00:54:19 +08:00
2022-10-02 08:28:31 +08:00
sbase get chromedriver 105
2020-06-08 01:41:56 +08:00
```
2018-08-01 02:47:10 +08:00
2021-10-23 04:27:08 +08:00
* On Linux, you can run the following two commands (once you've installed SeleniumBase) to automatically upgrade your Chromedriver to match your version of Chrome: (``wget`` downloads the file, and ``pytest`` runs it.)
2021-10-21 10:40:56 +08:00
```bash
wget https://raw.githubusercontent.com/seleniumbase/SeleniumBase/master/examples/upgrade_chromedriver.py
pytest upgrade_chromedriver.py -s
```
2022-09-02 04:27:34 +08:00
* If you run a test without the correct webdriver available, the driver will be downloaded automatically.
2021-10-23 04:27:08 +08:00
If you plan on using the [Selenium Grid integration](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md) (which allows for remote webdriver), you'll need to put the drivers on your System PATH. On macOS and Linux, ``/usr/local/bin`` is a good PATH spot. On Windows, you may need to set the System PATH under Environment Variables to include the location where you placed the driver files. As a shortcut, you could place the driver files into your Python ``Scripts/`` folder in the location where you have Python installed, which should already be on your System PATH.
2018-08-01 02:47:10 +08:00
2022-09-02 04:27:34 +08:00
Here's where you can go to manually get web drivers from the source:
2017-10-31 09:59:24 +08:00
2018-03-26 09:07:05 +08:00
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System PATH.
2017-10-31 09:59:24 +08:00
2018-03-26 09:07:05 +08:00
* For Firefox, get [Geckodriver](https://github.com/mozilla/geckodriver/releases) on your System PATH.
2017-10-31 09:59:24 +08:00
2018-03-26 09:07:05 +08:00
* For Microsoft Edge, get [Edge Driver (Microsoft WebDriver)](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/) on your System PATH.
2017-10-31 09:59:24 +08:00
2018-03-26 09:07:05 +08:00
* For Safari, get [Safari Driver](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/using_safari_driver.md) on your System PATH.
2017-10-31 09:59:24 +08:00
2018-08-08 10:05:27 +08:00
* For Opera, get [Opera Chromium Driver](https://github.com/operasoftware/operachromiumdriver/releases) on your System PATH..
2018-03-26 09:07:05 +08:00
* For PhantomJS headless browser automation, get [PhantomJS](http://phantomjs.org/download.html) on your System PATH. (NOTE: <i>PhantomJS is no longer officially supported by SeleniumHQ</i>)
2017-10-31 09:59:24 +08:00
2020-05-13 07:21:55 +08:00
**macOS shortcuts**:
2017-10-31 09:59:24 +08:00
* You can also install drivers by using ``brew`` (aka ``homebrew``), but you'll need to install that first. [Brew installation instructions are here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/install_python_pip_git.md).
2017-10-31 09:59:24 +08:00
```bash
2022-08-16 07:28:53 +08:00
brew install --cask chromedriver
2018-03-09 08:28:23 +08:00
brew install geckodriver
2017-10-31 09:59:24 +08:00
```
2020-05-13 07:21:55 +08:00
You can also upgrade existing webdrivers:
2017-10-31 09:59:24 +08:00
```bash
2022-08-16 07:28:53 +08:00
brew upgrade --cask chromedriver
2018-03-09 08:28:23 +08:00
brew upgrade geckodriver
2017-10-31 09:59:24 +08:00
```
2020-05-13 07:21:55 +08:00
**Linux shortcuts**:
2018-02-14 05:03:36 +08:00
2022-09-02 04:27:34 +08:00
If you still need the web drivers, here are some scripts to help you get chromedriver and geckodriver on a Linux machine:
2018-08-01 02:47:10 +08:00
2018-02-14 05:03:36 +08:00
```bash
2022-07-09 05:02:17 +08:00
wget https://chromedriver.storage.googleapis.com/72.0.3626.69/chromedriver_linux64.zip
2018-02-14 05:03:36 +08:00
unzip chromedriver_linux64.zip
mv chromedriver /usr/local/bin/
chmod +x /usr/local/bin/chromedriver
```
```bash
2022-04-15 04:07:57 +08:00
wget https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz
tar xvfz geckodriver-v0.31.0-linux64.tar.gz
2018-02-14 05:03:36 +08:00
mv geckodriver /usr/local/bin/
chmod +x /usr/local/bin/geckodriver
```
2018-08-01 02:47:10 +08:00
* If you wish to verify that web drivers are working, **[follow these instructions](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/verify_webdriver.md)**.
2022-08-06 06:27:38 +08:00
[<img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" title="SeleniumBase" width="280">](https://github.com/seleniumbase/SeleniumBase)