1

so I have started working on selenium, and this is my first time working with it, the code provided below opens chrome but doesnt open the url mentioned in the .get function.

from selenium import webdriver
import time

# open chrome and access the page
driver = webdriver.Chrome("C:\Program Files\Google\Chrome\Application\chrome.exe")
driver.get('https://dex.onxrp.com/?project=XREEFS')
time.sleep(5)
driver.close()

I have installed the selenium pip library, do i need something else as well for it to load the link?

1 Answers1

0

Using the default argument which can be passed within webdriver.Chrome() is the value of the KEY executable_path i.e. the logical/absolute path of the ChromeDriver executable but not of executable.


Solution

Ideally, your line of code will be:

driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • File "c:\Users\aadit\OneDrive\Desktop\testing_py\web_scrap_test.py", line 5 driver = webdriver.Chrome("C:\Users\aadit\Downloads\chromedriver_win32\chromedriver.exe") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape – Aaditya Thakkar Mar 09 '22 at 15:33
  • use it as a raw string: `driver = webdriver.Chrome(r"C:\Users\aadit\Downloads\chromedriver_win32\chromedriver.exe")` or use double slash in lieu of single slash` as single slash acts as escape character – Anand Gautam Mar 09 '22 at 15:36
  • @AadityaThakkar Checkout the updated answer and let me know the status. – undetected Selenium Mar 09 '22 at 15:37
  • 1
    yes works, thanks – Aaditya Thakkar Mar 10 '22 at 08:37