Profile inheritance
tnt2k opened this issue · comments
Tell me how to inherit a profile when opening a new tab or when clicking on a link from a window with a profile?
For some reason, my profile flies when I open a new tab. Found a solution to this problem via
driver.profiles.apply(profile)
and that results in an warnings
UserWarning: profile["options"] can't be applied when driver allready started
warnings.warn('profile["options"] can\'t be applied when driver allready started')
, this warning is understandable since the proxy options are specified, but for some reason when trying to apply
driver.profiles.apply(profile["cdp" ])
getting the error
ValueError: 'touch' isn't a valid key for profile (selenium-profiles)
?
I did not understand how to solve the problem with following a link from a tab with a changed profile to a new tab opening.
Got what you mean. You're basically not supposed to pass the profile with driver.profiles.apply(profile["cdp" ])
The warning ppears when "options"
is in profile
. If you don't want the waring, just remove that key with del profile["options"]
.
Maybe the source-code helps you to understand:
def apply(self, profile:dict):
"""
apply options after driver allready started
:param profile: selenium-profiles options
"""
from selenium_profiles.utils.utils import valid_key
valid_key(profile.keys(),["cdp", "options"], "profile (selenium-profiles)")
if "options" in profile.keys():
warnings.warn('profile["options"] can\'t be applied when driver allready started')
if "cdp" in profile.keys():
# noinspection PyUnresolvedReferences
self.cdp.apply(profile["cdp"])
or you could simply do: driver.profiles.cdp.apply(profile["cdp"])
I'll might implement in feature automatic apply for profiles. Also, you might need to execute:
from selenium_profiles.scripts.undetected import exec_cdp
exec_cdp(driver, driver.profiles.cdp_tools)
for undetectability on a new tab