Problem when runnin code

18 views
Skip to first unread message

cacti

unread,
May 8, 2024, 7:56:23 AMMay 8
to Selenium Users
Hello there! I'm not sure if this is selenium problem but I wrote simple code but VScode is reporting me error: 
PS C:\Users\CLAY> & "C:/Program Files/Python312/python.exe" d:/test1/test1.py
Traceback (most recent call last):
  File "d:\test1\test1.py", line 6, in <module>
    service = Service(executable_path="chromedriver.exe")
              ^^^^^^^
NameError: name 'Service' is not defined. Did you mean: 'service'?


I haven't seen anyone with this problem, and I don't know what to do. 
Here is code I wrote:

from selenium import webdriver

from selenium.webdriver.chrome.service import service
import time

service = Service(executable_path="chromedriver.exe")
driver = webdriver.chrome(service=service)

time.sleep(10)
driver.quit()
Reply all
Reply to author
Forward
0 new messages