TypeError: __init__() got an unexpected keyword argument ‘service’ error using Python Selenium ChromeDriver with company pac file

We Are Going To Discuss About TypeError: __init__() got an unexpected keyword argument ‘service’ error using Python Selenium ChromeDriver with company pac file. So lets Start this Python Article.

TypeError: __init__() got an unexpected keyword argument ‘service’ error using Python Selenium ChromeDriver with company pac file

  1. How to solve TypeError: __init__() got an unexpected keyword argument 'service' error using Python Selenium ChromeDriver with company pac file

    If you are still using Selenium v3.x then you shouldn't use the Service() and in that case the key executable_path is relevant. In that case the lines of code will be:
    driver = webdriver.Chrome(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe')

    Else, if you are using selenium4 then you have to use Service() and in that case the key executable_path is no more relevant. So you need to change the line of code:
    service = Service(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe') driver = webdriver.Chrome(service=service)
    as:
    service = Service('C:\Program Files\Chrome Driver\chromedriver.exe')

  2. TypeError: __init__() got an unexpected keyword argument 'service' error using Python Selenium ChromeDriver with company pac file

    If you are still using Selenium v3.x then you shouldn't use the Service() and in that case the key executable_path is relevant. In that case the lines of code will be:
    driver = webdriver.Chrome(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe')

    Else, if you are using selenium4 then you have to use Service() and in that case the key executable_path is no more relevant. So you need to change the line of code:
    service = Service(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe') driver = webdriver.Chrome(service=service)
    as:
    service = Service('C:\Program Files\Chrome Driver\chromedriver.exe')

Solution 1

If you are still using Selenium v3.x then you shouldn’t use the Service() and in that case the key executable_path is relevant. In that case the lines of code will be:

driver = webdriver.Chrome(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe')

Else, if you are using then you have to use Service() and in that case the key executable_path is no more relevant. So you need to change the line of code:

service = Service(executable_path='C:\Program Files\Chrome Driver\chromedriver.exe')
driver = webdriver.Chrome(service=service)

as:

service = Service('C:\Program Files\Chrome Driver\chromedriver.exe')

Original Author undetected Selenium Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment