Home > database >  get() missing 1 required positional argument: 'self' error using Selenium 4.3.0 and Python
get() missing 1 required positional argument: 'self' error using Selenium 4.3.0 and Python

Time:07-20

I used to have a script to access to websites, the thing is that one day stoppe working because this error: "executable_path has been deprecated, please pass in a Service object". So, I updated Selenium and update the script too:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys

service = Service(executable_path="C:/Users/XXXXX/chromedriver.exe")
browser = webdriver.Chrome
browser.get(url='https://XXX.sis.ad.bia.XXX/XXX/pages/login.xhtml')

Now I got this error:

get() missing 1 required positional argument: 'self'

I know is a simply error but I cannot solve it.

P.s: the XXX are just for confidentiality

Update: When I tried this:

service = Service(executable_path="C:/Users/fer14538/chromedriver.exe")
browser = webdriver.Chrome(service=service)`
browser = webdriver.Chrome

I got this error:

Ordinal0 [0x0043F8D1 2029777]
BaseThreadInitThunk [0x7534FA29 25]
RtlGetAppContainerNamedObjectPath [0x77487A9E 286]
RtlGetAppContainerNamedObjectPath [0x77487A6E 238]

CodePudding user response:

Instead of:

browser = webdriver.Chrome

You need to invoke the Chrome() method passing the service object and simply pass the url_string as an argument to get() as follows:

service = Service("C:/Users/XXXXX/chromedriver.exe")
browser = webdriver.Chrome(service=service)
browser.get('https://XXX.sis.ad.bia.XXX/XXX/pages/login.xhtml')

References

You can find a couple of relevant detailed discussion in:

  • Related