0

While learning Selenium in Python i opened the Python interpreter and wrote the following lines of code:

from selenium import webdriver
driver = webdriver.Chrome()

Selenium opened a new window and was working even though i haven't supplied a path to a chromedriver executable or have a path set in my operating system.

This is the output i got back from the intepreter:

enter image description here

The Python intepreter also in real time can perform interactions with the browser and print back in the console details about elements. Is there any use for this?

For example when clicking on the search button in Google.

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://www.google.com")
driver.find_element(By.CSS_SELECTOR, "[name='btnK']")

This is the output i get back in the terminal

Output

Thanks

dudex198
  • 25
  • 5
  • 2
    Please read [ask], especially the part about [mcve] (MCVE). Take the code you are using, reduce it to an MCVE, and then post that code, properly formatted. – JeffC Mar 14 '23 at 20:27

1 Answers1

0

Executing this line of code...

driver = webdriver.Chrome()

... Selenium opens a new window and was working as the path to to chromedriver executable was automatically detected either through:

Hence, the Python interpreter automatically finds it.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Could you perhaps explain a bit more? i haven't completely understood your answer. Thank you very much regardless – dudex198 Mar 15 '23 at 13:56
  • 1
    Selenium will check for the driver executable at the path provided, at the system environment PATH variable, and as a final fallback at the current directory (where the assembled code is running from). – pcalkins Mar 15 '23 at 19:53
  • The thing is i don't have a PATH variable setup for chromedriver – dudex198 Mar 17 '23 at 10:24