-I tried it on Mac while watching Official Tutorial. ――There was a part that was a little clogged, so make a note.
pip install -U selenium
The driver will download what you need according to the browser version you are using. Even if I updated my browser, I didn't have to install the latest version of the driver. (Please note that the version is different if you look closely) I put it in the same location as the directory where I run the program.
vaivailx@MacBook-Pro-2 selenium_test % tree.
├── chromedriver
├── memo.md
└── sample.py
0 directories, 3 files
vaivailx@MacBook-Pro-2 selenium_test %
The following may differ from person to person or depending on the environment even on the same Mac. If you get a word that you can't execute the downloaded one, please try it. After downloading and unzipping the driver, open "Security & Privacy" in "System Preferences". When you execute the unzipped file, you will be asked whether to allow execution in the "Execution permission of downloaded application" item, so allow it.
The Official Tutorial is written with a path to the location where the driver is located.
However, it seemed that I had to pass the path where the driver is located when creating an instance of the driver class, so I tried specifying the path.
from selenium import webdriver
browser = webdriver.Chrome(executable_path="./chromedriver")
browser.get('http://seleniumhq.org/')
moved!
When operating the browser with selenium, when it is chrome, it says "Chrome is controlled by automatic test software."
I did not know.
Recommended Posts