Reputation: 909
I'm trying to set preferences in python27 selenium firefox webdriver(because I need it to start with allowed flash), but no example I found seems to work. This is my non working code which works if Im not trying to set preference:
import pyautogui, sys
import time
import random
import subprocess
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
driver = webdriver.Firefox(('C:\\Users\\administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\0atm5xlq.default-1401786267631'))
driver.set_preference("plugin.state.flash", 2)
Upvotes: 1
Views: 4330
Reputation: 6551
Webdriver object has no attribute set_preference
This is because set_preference
is defined within the FirefoxProfile
object:
profile = webdriver.FirefoxProfile(<path-to-profile>)
profile.set_preference("plugin.state.flash", 2)
driver = webdriver.Firefox(profile)
Upvotes: 2