- Download the latest version
$ py -m pip --version
$ pip 9.0.1 from c:\python36\lib\site-packages (Python 3.6.1)
- Installing virtualenv
$ py -m pip install --user virtualenv
- Creating a virtual environment
$ py -m venv env
- Activating a virtual environment
$ .\env\Scripts\activate
$ python3 -m pip install --user --upgrade pip
$ python3 -m pip --version
- Installing virtualenv
$ python3 -m pip install --user virtualenv
- Creating a virtual environment
$ python3 -m venv env
- Activating a virtual environment
$ source env/bin/activate
- Install
$ pip install selenium
- Selenium WebDriver
Browser | Link |
---|---|
Chrome: | ChromeDriver |
Edge: | EdgeDriver |
Firefox: | FirefoxDriver |
Safari | SafariDriver |
- Setup path
$ mkdir -p $HOME/bin
$ mv chromedriver $HOME/bin
$ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile
Note: macOS Catalina error
“chromedriver” cannot be opened because the developer cannot be verified.
macOS cannot verify that this app is free from malware.
Safari downloaded this file today at xx:yy from chromedriver.storage.googleapis.com.
The problem is solved by the command below:
$ sudo spctl --master-disable
- Excample
import time
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
Note: macOS Catalina error
“chromedriver” cannot be opened because the developer cannot be verified.
macOS cannot verify that this app is free from malware.
Safari downloaded this file today at xx:yy from chromedriver.storage.googleapis.com.
The problem is solved by the command below:
$ sudo spctl --master-disable
$ python3 delete_all_messages_from_facebook.py