how to disable save password popup #92
-
how to disable save password popup
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@gouravkumar99 |
Beta Was this translation helpful? Give feedback.
-
@gouravkumar99 import os.path
from selenium_driverless import webdriver
import asyncio
import json
from functools import reduce
def prefs_to_json(dot_prefs: dict):
# prefs as {key:value}
# for example {"profile.default_content_setting_values.images": 2}
def undot_key(key, value):
if "." in key:
key, rest = key.split(".", 1)
value = undot_key(rest, value)
return {key: value}
# undot prefs dict keys
undot_prefs = reduce(
lambda d1, d2: {**d1, **d2}, # merge dicts
(undot_key(key, value) for key, value in dot_prefs.items()),
)
return undot_prefs
def write_prefs(prefs: dict, prefs_path: str):
# prefs as a dict
with open(prefs_path, encoding="latin1", mode="w+") as f:
json.dump(prefs, f)
def read_prefs(prefs_path: str):
# prefs as a dict
with open(prefs_path, encoding="latin1", mode="r") as f:
return json.load(f)
async def main():
options = webdriver.ChromeOptions()
options.auto_clean_dirs = False
_dir = "C:/Users/aurin/Downloads/test_ua_dir"
dot_prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled":False,
"profile.default_content_setting_values.notifications":2
}
# setup prefs
prefs_path = _dir + "/Default/Preferences"
if os.path.isfile(prefs_path):
prefs = read_prefs(prefs_path)
else:
os.makedirs(os.path.dirname(prefs_path), exist_ok=True)
prefs = {}
prefs.update(prefs_to_json(dot_prefs))
write_prefs(prefs, prefs_path)
options.add_argument(f'--user-data-dir={_dir}')
async with webdriver.Chrome(options=options) as driver:
await driver.get("https://joomla-host.com/testselenium.php")
input()
await driver.quit(clean_dirs=False)
asyncio.run(main()) should work just fine for adding prefs. I plan to implement it in the next release |
Beta Was this translation helpful? Give feedback.
@gouravkumar99
Update:
smth like: