Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

implement Prefs class to get/set/clear Firefox preferences #32

Open
deepsweet opened this issue Sep 6, 2018 · 1 comment
Open

implement Prefs class to get/set/clear Firefox preferences #32

deepsweet opened this issue Sep 6, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@deepsweet
Copy link
Owner

Will allow to set a dom.w3c_touch_events.enabled = 1 by foxr.connect({ defaultViewport: { hasTouch } }) for elementHandle.tap() method.

@deepsweet deepsweet added the enhancement New feature or request label Sep 6, 2018
@deepsweet deepsweet changed the title implement Prefs class to get/set/clear Firefox preferencies implement Prefs class to get/set/clear Firefox preferences Sep 6, 2018
@saidsay-so
Copy link
Contributor

Hi!
After many researches, I found a way to access to the preferences, which is to use the XPCOM API.

def get_pref(self, pref, default_branch=False, value_type="unspecified"):

 pref_value = self.execute_script("""
 Components.utils.import("resource://gre/modules/Preferences.jsm");
 let pref = arguments[0];
 let defaultBranch = arguments[1];
 let valueType = arguments[2];

 prefs = new Preferences({defaultBranch: defaultBranch});
 return prefs.get(pref, null, Components.interfaces[valueType]);
 """, script_args=(pref, default_branch, value_type))

(picked from here)
This seems to be the only option, from what I found. I also saw it in Marionette's maillist.
In addition, it's necessary to change the context of the browser, which is trivial to do.

self._send_message("Marionette:SetContext", {"value": context})

(To another extent, I found this in the docs, but I don't know if it could help to find another way to do it)

deepsweet added a commit that referenced this issue Oct 12, 2019
➕ browser: add `getPref()` and `setPref()` (#32)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants