1. Intro
I'm going to explain how to install a selenium web driver.
Below thing is the information I will use.
Editor: Pycharm
Language: Python
Brower: Chrome
2. Install
1) Install Selenium
I'm going to use 'pip' for installing selenium on the terminal
pip3 install selenium
2) Check installation
Check if selenium is properly installed in Pycharm.
Go to settings and Project. Check the package and version.
3) Download chrome driver
URL: https://chromedriver.chromium.org/downloads
The important thing when you download is that the downloaded driver and chrome browser must be the same version.
If you have chrome browser version 96, you should download the driver version 96.
3. Test
from selenium import webdriver
import time
class test():
def test(self):
# Instantiate Chrome Browser Command
driver = webdriver.Chrome(executable_path="D:\\workspace_python\\drivers\\chromedriver.exe")
# Open the provided URL
driver.get("http://www.google.com")
time.sleep(5)
cc = test()
cc.test()
There is a deprecation warning when the code is executed.
This warning is caused by executable_path.
4. Solution
I'm going to use chrome as a Service.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
class test():
def test(self):
# Instantiate Chrome Browser Command
s = Service('D:\\workspace_python\\drivers\\chromedriver.exe')
driver = webdriver.Chrome(service=s)
# Open the provided URL
driver.get("http://www.google.com")
time.sleep(5)
cc = test()
cc.test()
Now, there is no warning.
This is for studying English and Selenium webdrivers.
So, the English may not be good enough.
'Testing Automation > 01. Selenium' 카테고리의 다른 글
06. Selenium | Wait ( Implicit / Explicit) (0) | 2022.03.05 |
---|---|
05. Selenium | Alert (0) | 2022.03.04 |
04. Selenium | Browser navigation (0) | 2022.03.04 |
03. Selenium | Browser control (0) | 2022.01.14 |
02. Selenium | Finding Element (0) | 2022.01.08 |