seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.95k stars 938 forks source link

Allow camera with undetect driver #1559

Closed KolyStudio closed 1 year ago

KolyStudio commented 1 year ago

Hello, i'm trying to allow the camera permission, i have no idea how to do it. Thank you!

from seleniumbase import SB

username = 'xx'
password = 'xx'

with SB(maximize=True, uc=True) as self:
        self.open("https://google.com")
        self.type("#username", username)
        self.type("#password", password)
        self.sleep(1.5)
        self.click("button:contains('Connexion')")
        self.sleep(10)
        self.click('button.sAhcF')

self.sleep(1000)
mdmintz commented 1 year ago

If you're referring to chrome://settings/content/camera see https://stackoverflow.com/a/69586993/7058266

KolyStudio commented 1 year ago

I wanted to refer to allowing access to the camera as I do on selenium like this

driver.execute_cdp_cmd(
            "Browser.grantPermissions",
            {
                "origin": 'https://google.com',   # e.g https://www.google.com
                "permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture",
                                "videoCapturePanTiltZoom"]
            },
        )
mdmintz commented 1 year ago

It looks like you're referring to https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/452#issuecomment-1017293933

I don't have the cheat-sheet on execute_cdp_cmd commands, so I can't vouch for their accuracy. I would refer to that thread for more info, or possibly a Stack Overflow solution if you need a more customized execute_cdp_cmd command to allow the camera on sites when using undetected-chromedriver. You may also want to confirm if that command works without undetected-chromedriver mode, because it might not.