Если вы ищете предпочтение / настройку, которая не отображается в селене (она загружается из файла "webdriver_prefs.json", который содержит те, которые ему действительно нужны / могут контролировать), тогда вы можете получить его из страницы about: config.
ОТКАЗ ОТ ОТВЕТСТВЕННОСТИ - этот подход использует объекты Firefox js, которые могут измениться в будущих версиях - и, таким образом, перестанут работать.
Идея такова - откройте «about: config», найдите ключ и получите его значение. Если вы сделаете это вручную, вы увидите, что это не обычные html-страницы, с которыми вы обычно работаете, - это xml, полный пространств имен и т. Д. Однако данные хранятся в объекте js view
.
Итак, процесс - откройте страницу конфигурации и выполните всю работу через JS:
from selenium import webdriver
def get_preference(name):
""" Runs a JS that a) sets the value of the searched-for setting to the name argument,
b) looks for the value of the first element in the "table" below.
Thus the name better be exact, and you'd better be looking for the 1st match :) """
global driver
value = driver.execute_script("""
document.getElementById("textbox").value = arguments[0];
FilterPrefs();
view.selection.currentIndex = 0;
var value = view.getCellText(0, {id:"valueCol"});
return value;
""", name)
return value
if __name__ == '__main__':
try:
ff_profile = webdriver.FirefoxProfile()
ff_profile.set_preference("general.warnOnAboutConfig", False) # there's a nasty warning opening about:config (another setting not present in the selenium preferences ;)
driver = webdriver.Firefox(firefox_profile=ff_profile)
driver.get('about:config')
print(get_preference('devtools.jsonview.enabled'))
finally:
driver.quit()