My selenium script (in Python) for chrome runs but does nothing

1.1k Views Asked by At

vscode says it run but it does nothing. My pip is up to date and i installed selenium with the command prompt. i have a valid path (i think) for chromedriver. Here's my code:

from selenium import webdriver
chromedriver = "C:Users/P-Lou/Downloads/chromedriver.exe"
driver = webdriver.Chrome(chromedriver)
driver.get("http:google.com")

The result is this:

[Running] python -u "w:\Python\Seletest\app.py"

[Done] exited with code=0 in 0.067 seconds
2

There are 2 best solutions below

0
Timeler On

I tried this code by only changing the browser to firefox and removing the chromedriver = part and it worked fine, you might be running the browser in headless mode, thats why nothing pops up. You can change that using The Chromedriver.options(set_headless="false") (not sure if that is the right code, you can check yourself here)

0
undetected Selenium On

Presuming the ChromeDriver binary location being C:\Users\P-Lou\Downloads on your system you can use the following solution:

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\Users\P-Lou\Downloads\chromedriver.exe')
driver.get("http:google.com")