0

Here is my code.

from selenium import webdriver
chrome_options = webdriver.ChromeOptions(); 
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);
options = webdriver.Chrome(options=chrome_options)
options.get('https://www.google.com/')
images = options.find_elements_by_tag_name('img')
for image in images:
    print(image.get_attribute('src'))
options.close()

when i run this code i get this error

**Traceback (most recent call last):
Python\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "Python\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "Python\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified**

Kindly check if i have made any mistakes in the code or if you understand this error do let me know Thanks

1
  • Please mark this question as solved, either answer will do. Commented Nov 28, 2019 at 9:35

2 Answers 2

3

You would need to add the path to your chrome driver when you declare your driver.

driver = webdriver.Chrome(options=chrome_options, executable_path=r"C:\path\to\chromedriver.exe")
Sign up to request clarification or add additional context in comments.

Comments

3

First download and install browser driver from https://link.jianshu.com/?t=https://sites.google.com/a/chromium.org/chromedriver/ Unzip and put it in a directory like "browserdriver" and change your code as follows:

from  selenium import webdriver
browser = webdriver.Chrome(r"C:\browserdriver\chromedriver.exe")
browser.get("http://www.google.com")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.