selenium-webdriverselenium-chromedriverundetected-chromedrivertiktok

Selenium tiktok-uploader issues with chromedriver


I'm trying to upload to TikTok using the TikTok-uploader package and I can't seem to get it working. The documentation says that chromedriver should be downloaded automatically when I try to run this code:

upload_video(f"ViralBear/ready/{filepath}", description= description,  cookies_list =    cookies)

However, I get this error:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

But then when I add the chromedriver myself in this code along with some other options:

options = Options() 
options.binary_location = "ViralBear/chromedriver"
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
upload_video(f"ViralBear/ready/{filepath}", description= description, cookies_list =   cookies, options= options)

I get this error:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to        start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location ViralBear/chromedriver is no longer running, so     ChromeDriver is assuming that Chrome has crashed.)

If someone would help me out, I would very much appreciate it. Thanks.

I tried to add the chromedriver, but then it gave me a different error. I have a feeling it might be related to my chromedriver version. My chrome is Version 115.0.5790.114 (Official Build) (arm64), but the one I downloaded is the most recent stable release "115.0.5790.102" for mac arm64.


Solution

  • That's an active bug with the latest chromedriver 115:

    To fix, delete your chromedriver 115, download the latest version of selenium, and use this code: (Selenium Manager will give you a working chromedriver, which is currently at 114 until fixed very soon.)

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    
    service = Service()
    options = webdriver.ChromeOptions()
    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    driver = webdriver.Chrome(service=service, options=options)
    # ...
    driver.quit()
    

    If the driver isn't found on your system PATH, Selenium Manager will automatically download it.


    Note that https://chromedriver.chromium.org/downloads only goes up to version 114 due to driver restructuring by the Chromium Team for the new Chrome-for-Testing.