pythonpython-3.xseleniumselenium-webdriverchrome-options

Why is my webdriver.chrome() not working?


Before I get blasted in my comments on this question, I am well aware that this is a possible duplication of this link, but the answer provided is not helping me out with my instance of code, even after applying an adjusted version of the answer in my code. I have looked into many answers, including installing Chromedriver into my device, but to no avail.

My code is as follows:

from selenium import webdriver
import time

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome(executable_path = r'C:\Users\user\Downloads\chromedriver_win32')
driver.get('http://codepad.org')

text_area = driver.find_element_by_id('textarea')
text_area.send_keys("This text is send using Python code.")

Every time I run the code, including the executable_path = r'C:\Users\user\Downloads\chromedriver_win32' I keep getting a permission error message when I run the code with the executable path. My code without the path is the same minus the executable_path which I replace with driver = webdriver.Chrome(options), but I get the error message argument of type 'Options' is not iterable.

Any help with this problem is greatly appreciated. Admittedly I am a bit new to Python, and coding, in general, and I am trying new ideas to learn the program better, but everything that I try to find an answer to just breaks my code in general.


Solution

  • Try adding the executable file name at the end of executable_path argument:

    executable_path = r'C:\Users\user\Downloads\chromedriver_win32\chromedriver.exe'
    

    Code I used for testing:

    from selenium import webdriver
    import time
    
    options = webdriver.ChromeOptions()
    options.add_argument('--ignore-certificate-errors')
    options.add_argument("--test-type")
    options.binary_location = "/usr/bin/chromium"
    driver = webdriver.Chrome(executable_path = r'C:\Users\user\Downloads\chromedriver_win32\chromedriver.exe')
    driver.get('http://codepad.org')
    
    text_area = driver.find_element_by_id('textarea')
    text_area.send_keys("This text is send using Python code.")