SeleniumBase/help_docs/verify_webdriver.md

69 lines
1.9 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/) Verifying that web drivers are installed
2022-08-07 11:10:59 +08:00
On newer versions of SeleniumBase, the driver is automatically downloaded to the ``seleniumbase/drivers`` folder as needed, and does not need to be on the System Path when running tests.
2021-10-21 10:40:56 +08:00
2022-08-07 11:10:59 +08:00
Drivers can be manually downloaded to the ``seleniumbase/drivers`` folder with commands such as:
2021-10-21 10:40:56 +08:00
```bash
2022-08-07 11:10:59 +08:00
sbase get chromedriver
sbase get chromedriver latest
sbase get geckodriver
sbase get edgedriver
2021-10-21 10:40:56 +08:00
```
--------
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
2022-08-07 11:10:59 +08:00
sbase get chromedriver --path
2021-10-21 10:40:56 +08:00
```
(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
2022-08-09 17:06:06 +08:00
>>> from seleniumbase import get_driver
>>> driver = get_driver("chrome", headless=False)
2019-11-04 14:16:47 +08:00
>>> 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
2022-08-09 17:06:06 +08:00
>>> from seleniumbase import get_driver
>>> driver = get_driver("firefox", headless=False)
2019-11-04 14:16:47 +08:00
>>> 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
2022-08-09 17:06:06 +08:00
>>> from seleniumbase import get_driver
>>> driver = get_driver("safari", headless=False)
2019-11-04 14:16:47 +08:00
>>> driver.get("https://www.apple.com/safari")
>>> driver.quit()
>>> exit()
```