-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow camera permissions with undetected driver #1566
-
Hello,I'm sorry to bring this up again, but I still haven't found a solution.
On selenium, I can do it this way because I call undetecter driver and I can use it with "driver ="
import undetected_chromedriver as uc
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import time
from selenium.webdriver.chrome.options import Options
from seleniumbase import BaseCase
tours = 100
options = uc.ChromeOptions()
options.add_argument("--password-store=basic")
options.add_experimental_option(
"prefs",
{
"credentials_enable_service": False,
"profile.password_manager_enabled": False,
},
)
driver = uc.Chrome(options=options, use_subprocess=True)
driver.execute_cdp_cmd(
"Browser.grantPermissions",
{
"origin": 'https://web.snapchat.com', # e.g https://www.google.com
"permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture",
"videoCapturePanTiltZoom"]
},
)
But on seleniumbase, I have no idea how I can call the driver with the use of SB()
from seleniumbase import SB
driver.execute_cdp_cmd(
"Browser.grantPermissions",
{
"origin": 'https://web.snapchat.com', # e.g https://www.google.com
"permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture",
"videoCapturePanTiltZoom"]
},
)
with SB(uc=True) as self:
self.open("https://web.snapchat.com")
# self.type("#username", username)
self.type('input[name="username"]', username)
self.type('input[name="password"]', password)
If you can help me, again, thank you.
Beta Was this translation helpful? Give feedback.
All reactions
You can access the SeleniumBase driver with sb.driver
or self.driver
(depending on whether you're using sb
or self
as the access point.
With your code, it would be:
from seleniumbase import SB with SB(uc=True) as self: self.driver.execute_cdp_cmd( "Browser.grantPermissions", { "origin": 'https://web.snapchat.com', "permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture", "videoCapturePanTiltZoom"] }, ) self.open("https://web.snapchat.com") self.type('input[name="username"]', username) self.type('input[name="password"]', password)
Replies: 1 comment 1 reply
-
You can access the SeleniumBase driver with sb.driver
or self.driver
(depending on whether you're using sb
or self
as the access point.
With your code, it would be:
from seleniumbase import SB with SB(uc=True) as self: self.driver.execute_cdp_cmd( "Browser.grantPermissions", { "origin": 'https://web.snapchat.com', "permissions": ["geolocation", "audioCapture", "displayCapture", "videoCapture", "videoCapturePanTiltZoom"] }, ) self.open("https://web.snapchat.com") self.type('input[name="username"]', username) self.type('input[name="password"]', password)
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you, it's perfect.
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 2