Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow camera permissions with undetected driver #1566

Answered by mdmintz
KolyStudio asked this question in Q&A
Discussion options

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.

You must be logged in to vote

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

Comment options

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)
You must be logged in to vote
1 reply
Comment options

Thank you, it's perfect.

Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /