Search code examples
pythonseleniumconsoleoutput

Empty Console Output Python


I added and used undetected_chromedriver library, and after that the program stopped working. Did I do something wrong? Nothing is written in the console

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import undetected_chromedriver as uc

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
service = Service(executable_path="path")
driver = uc.Chrome(options=options, service=service)

driver.get("link")

Next comes the code of the program, but it worked well

Console image


Solution

  • I never figured out the options, but the problem was with the path. You need to use driver_executable_path="". And add the module import check if __name__ == '__main__':, and put all the code there. Now the program looks like this:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.service import Service
    from selenium import webdriver
    import undetected_chromedriver as uc
    
    if __name__ == '__main__':
        options = webdriver.ChromeOptions() #or options = uc.ChromeOptions()
        options.add_argument("start-maximized")
        driver = uc.Chrome(options=options, driver_executable_path="path")
    
        driver.get("link")