I am a beginner in programming, and in selenium as well. Therefore, I am seeking for your help in fixing the code to set os.environ
in selenium4 as below.
service = ChromeService(executable_path="D:\\port\\driver\\chromedriver")
os.environ["wedriver.chrome.driver"] = service
driver = webdriver.Chrome(service=service)
driver.get(https://gisgeography.com/free-satellite-imagery-data-list/')
driver.maximize_window()
You will not need to use an environment variable for this.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s=Service('D:\\port\\driver\\chromedriver')
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)
however if you need to set ot read environment variables using python below is an example
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
# Setting an environment variable
os.environ["CHROME_DRIVER_PATH"] = "D:\\port\\driver\\chromedriver"
# Reading an environment variable
DRIVER_PATH = os.environ.get('CHROME_DRIVER_PATH')
s=Service(DRIVER_PATH)
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)