SeleniumBase/help_docs/verify_webdriver.md

69 lines
1.7 KiB
Markdown
Raw Normal View History

2019-11-04 14:16:47 +08:00
## Verifying that web drivers are installed
2021-10-21 10:40:56 +08:00
On newer versions of SeleniumBase, the driver is automatically downloaded to the ``seleniumbase/drivers`` folder, and does not need to be on the System Path when running tests.
Drivers can be manually downloaded with commands such as:
```bash
sbase install chromedriver
sbase install chromedriver latest
sbase install geckodriver
sbase install edgedriver
```
--------
If you want to check that you have the correct driver installed on your System PATH (which is no longer necessary unless using the Selenium Grid), then continue reading below:
*This assumes you've already downloaded a driver to your **System PATH** with a command such as:*
```bash
sbase install chromedriver --path
```
(The above ``--path`` addition is for Linux/Mac only, which uses ``/usr/local/bin/``. The "Path" is different on Windows, and you'll need to manually copy the driver to your System Path, which is defined in the Control Panel's System Environment Variables.)
*You can verify that the correct drivers exist on your System Path by checking inside a Python command prompt.*
#### Verifying ChromeDriver
2021-10-21 10:40:56 +08:00
```bash
python
2019-11-04 14:16:47 +08:00
```
2021-10-21 10:40:56 +08:00
2019-11-04 14:16:47 +08:00
```python
>>> from selenium import webdriver
2019-11-04 14:16:47 +08:00
>>> driver = webdriver.Chrome()
>>> driver.get("https://www.google.com/chrome")
>>> driver.quit()
>>> exit()
```
2019-11-04 14:16:47 +08:00
#### Verifying Geckodriver (Firefox WebDriver)
2021-10-21 10:40:56 +08:00
```bash
python
2019-11-04 14:16:47 +08:00
```
2021-10-21 10:40:56 +08:00
2019-11-04 14:16:47 +08:00
```python
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
>>> driver.get("https://www.mozilla.org/firefox")
>>> driver.quit()
>>> exit()
```
#### Verifying WebDriver for Safari
2021-10-21 10:40:56 +08:00
2019-11-04 14:16:47 +08:00
```bash
python
```
2021-10-21 10:40:56 +08:00
2019-11-04 14:16:47 +08:00
```python
>>> from selenium import webdriver
2019-11-04 14:16:47 +08:00
>>> driver = webdriver.Safari()
>>> driver.get("https://www.apple.com/safari")
>>> driver.quit()
>>> exit()
```