Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyDriver does not accept custom profile #16

Closed
chfw opened this issue Apr 29, 2013 · 3 comments
Closed

MyDriver does not accept custom profile #16

chfw opened this issue Apr 29, 2013 · 3 comments

Comments

@chfw
Copy link

chfw commented Apr 29, 2013

class MyDriver(object):
def init(self):
driver = getattr(webdriver, settings.SELENIUM_DRIVER, None)
assert driver, "settings.SELENIUM_DRIVER contains non-existing driver"
if driver is webdriver.Remote:
....
else:
self.driver = driver() <- there is no way to pass custom profile to local selenium instance.!!!! <_<

@dragoon
Copy link
Owner

dragoon commented Apr 29, 2013

Hi, could you please tell me what do you mean by a custom profile?
You can assign a different browser from selenium by setting, for example:
SELENIUM_DRIVER = 'Firefox' in your settings file.

@chfw
Copy link
Author

chfw commented Apr 30, 2013

Hi,

The use case is:

to disable download dialog for certain type of downloaded file.

In order to do that, selenium allows customization of browser profile, such as:

profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2)
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/tmp/')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/zip')

then

self.driver = driver(profile) helps

I verified above hack and they worked. If you could help expose that parameter to settings elegantly as you did for other parameters, that'd very helpful.

Br,
simo

@dragoon
Copy link
Owner

dragoon commented May 1, 2013

Hi simo,
as far as I understand, you need to set custom settings for the profile. In this case I would recommend you subclass MyDriver with your own implementation and set the required profile preferences inside __init__ after call to super.

At the moment your use-case looks too specific to me, and subclassing seems to be an adequate solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants