I am trying to open Brave using Selenium (in Python). It actually opens but then immediately closes with the following errors appearing in the console:
[23340:9252:1107/063438.209:ERROR:os_crypt_win.cc(93)] Failed to
decrypt: The parameter is incorrect. (0x57)
[23340:9252:1107/063438.210:ERROR:brave_sync_prefs.cc(114)] Decrypt
sync seed failure
DevTools listening on
ws://127.0.0.1:53809/devtools/browser/ecce3b0e-2884-4173-bdab-2215a3d7f507
[23340:9252:1107/063438.480:ERROR:CONSOLE(1)] "[Shields]: Can't
request shields panel data for tabId: 2. Error: No tab url
specified", source:
chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js
(1)
I've done some searching but couldn't really find anything helpful.
Here is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
class Selen:
def __init__(self):
options = Options()
service = Service("C:/Auxiliary/chromedriver_win32/chromedriver.exe")
options.binary_location = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
self.driver = webdriver.Chrome(service=service, options=options)
self.driver.get("https://google.com")
Selen()
I'm using Windows 11.
Firstly, do you have chrome installed, and secondly, does it work if you do this?
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
class Selen:
def __init__(self):
options = Options()
path = "C:/Auxiliary/chromedriver_win32/chromedriver.exe"
self.driver = webdriver.Chrome(executable_path=path, options=options)
self.driver.get("https://google.com")
time.sleep(20)
driver.close()
instance = Selen()
If it does work, try this to get it to work with brave,
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
class Selen:
def __init__(self):
options = Options()
options.binary_location = "C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
path = "C:/Auxiliary/chromedriver_win32/chromedriver.exe"
self.driver = webdriver.Chrome(executable_path=path, options=options)
self.driver.get("https://google.com")
time.sleep(20)
driver.close()
instance = Selen()
Related
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s)
driver.maximize_window()
driver.get('https://www.google.com')
driver.find_element(By.NAME, 'q').send_keys('Hello world' + Keys.ENTER)`
Help me pls,who faced such problem? There is a solution?
The browser starts and after a couple of seconds it closes, although I did not give the command to close. What's wrong?
Try using the detach option when initializing the chromedriver. As following:
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_argument("start-maximized")
s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(options=chrome_options, service=s)
I'm looking to setup a webdriver in a script as a headless. I'm able to run it as a non headless way but when i'm creating an instance of the Option() it says me missing 1 required positional argument: 'value'
chrome_options = Options()
Here's a replication of the issue I'm having on the project.
from selenium import webdriver
from webbrowser import Chrome
from ssl import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
class PythonOrg():
def Setup(self):
self.chrome_options = Options()
self.chrome_options.add_argument("--headless")
# self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) #not a headless
self.driver = webdriver.Chrome(options=chrome_options)
def GetLink(self):
driver = self.driver
driver.get('https://www.python.org')
print(driver.title)
driver.close()
inst = PythonOrg()
inst.Setup()
inst.GetLink()
Note: I'm new to Python!
You imported a wrong import.
Instead of
from ssl import Options
It should be
from selenium.webdriver.chrome.options import Options
for chrome_options add self.
and use from selenium.webdriver.chrome.options import Options not from ssl import Options
from selenium import webdriver
from webbrowser import Chrome
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
class PythonOrg():
def Setup(self):
self.chrome_options = Options()
self.chrome_options.add_argument("--headless")
# self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) #not a headless
self.driver = webdriver.Chrome(options=self.chrome_options)
def GetLink(self):
driver = self.driver
driver.get('https://www.python.org')
print(driver.title)
driver.close()
inst = PythonOrg()
inst.Setup()
inst.GetLink()
I try to load this site
https://www.pferdewetten.de/
with the following code:
import time
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from sys import platform
import os, sys
import xlwings as xw
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from fake_useragent import UserAgent
if __name__ == '__main__':
SAVE_INTERVAL = 5
WAIT = 3
print(f"Checking chromedriver...")
os.environ['WDM_LOG_LEVEL'] = '0'
ua = UserAgent()
userAgent = ua.random
options = Options()
# options.add_argument('--headless')
options.add_experimental_option ('excludeSwitches', ['enable-logging'])
options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
options.add_argument("--disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("start-maximized")
options.add_argument('window-size=1920x1080')
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument(f'user-agent={userAgent}')
srv=Service(ChromeDriverManager().install())
driver = webdriver.Chrome (service=srv, options=options)
waitWebDriver = WebDriverWait (driver, 10)
link = f"https://www.pferdewetten.de/"
driver.get (link)
But i allways only get this information:
Is there any way to load this site using selenium?
Possibly elenium driven ChromeDriver initiated google-chrome Browsing Context is geting detected as a bot.
To evade the detection you can make a few tweaks as follows:
Remove the --no-sandbox argument and execute as non-root user.
Remove the --disable-infobars argument as it is no more effective.
Remove the --disable-extensions argument as it is no more effective.
Add an experimental option "excludeSwitches", ["enable-automation"] to evade detection.
Add an experimental option 'useAutomationExtension', False to evade detection.
Add the argument '--disable-blink-features=AutomationControlled' to evade detection.
Effectively your code block will be:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.pferdewetten.de/")
driver.quit()
Here is what it shows me when I try to log in:
What options.add_argument arguments should I use?
My code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import time
url = "url"
options = Options()
options.add_argument('--no-sandbox') # Bypass OS security model
options.add_argument("--window-size=1360,768")
driver = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=options)
driver.get(url)
I'm pretty new to programming.So i have this code its supposed to log me in at instagram but i doesnt works.
I tried to find it by x_path and other methods but didnt get it right.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import webbrowser
driver = webdriver.Chrome()
webbrowser.open('https://www.instagram.com/accounts/login/')
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-infobars")
browser = webdriver.Chrome(executable_path =
"C:\chromedriver",chrome_options=chrome_options)
browser = webbrowser
login_elem =
webbrowser.find_element_by_xpath('//article/div/div/p/a[text()="Anmelden"]')
login_elem.click()
driver.find_element_by_css_selector('.button.c_button.s_button').click()
ese.clickButton(Anmelden)