0

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Pierre
  • 1
  • 3
  • What do you mean by "it does nothing"? Just from the code you posted, it is not supposed to do anything. Also, the url does not look correct. Instead, `http://google.com` should be it, I think. – Jonathan Scholbach Dec 01 '20 at 13:54
  • it is supposed to open google but it doesnt. I changed the adress and still no responce. – Pierre Dec 01 '20 at 13:56
  • 1
    Not a Selenium expert but it looks like all your code is telling it to do is go onto the Google homepage. You may be running a headless browser in which case there wont be a visible window that pops up on your screen. Try telling it to get elements from the page and examine what it finds. – Jacob Myer Dec 01 '20 at 13:58
  • its a good idea but it did nothing. i tried to run it in mcrosoft visual studio instead and mow my error message is: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home – Pierre Dec 01 '20 at 14:03
  • Try using the following: chromedriver = r"C:Users/P-Lou/Downloads/chromedriver.exe" – Arundeep Chohan Dec 01 '20 at 17:34

2 Answers2

1

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)

Timeler
  • 377
  • 1
  • 11
0

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")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352