pythong biding not able to pass firefox profile to remote node

372 views
Skip to first unread message

Gaurang shah

unread,
Feb 20, 2013, 7:39:47 AM2/20/13
to webd...@googlegroups.com
Hi guys, 

I am working with python binding and need to change the Firefox profile through code, I tried following way however it gives error that Firefox profile object is not JSON serializable

Following is the code. 

    caps = { "browserName": "firefox" }
    
    
    fp = webdriver.FirefoxProfile()                  
    fp.set_preference("browser.download.folderList",2)
    fp.set_preference("browser.download.manager.showWhenStarting",False)
    fp.set_preference("browser.download.dir", "C:\Downloads")
    fp.update_preferences()
    
    desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
    desired_capabilities['browserName'] = 'firefox'
    desired_capabilities['firefox_profile'] = fp
    driver = webdriver.Remote(desired_capabilities=desired_capabilities,
                                   command_executor=remote
                                   )

Error: TypeError: <extern.selenium.webdriver.firefox.firefox_profile.FirefoxProfile object at 0x02389FF0> is not JSON serializable

would some please let me know how to convert this firefox profile object into JSON object ????

Luke Inman-Semerau

unread,
Feb 20, 2013, 9:14:21 AM2/20/13
to webd...@googlegroups.com
Pass the profile to the constructor of Remote instead of adding it to the desired capabilities. 

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alexandr Savchuk

unread,
Mar 23, 2013, 6:24:35 PM3/23/13
to webd...@googlegroups.com
1. webriver.Remote does not support named arguments.
Arguments shoul be in predefined order.
Expected order is 
command_executor,
desired_capabilities, browser_profile, proxy

So please use:

driver = webdriver.Remote(remote, desired_capabilities)

2. about passing FirefoxProfile to driver. Local FirefoxDriver supports passing it by 1 parameter of constructor.
Remote supports 2 ways: by passing it as 3 parameter of constructor
and as specifying it as 'firefox_profile' in desired capabilities.
But in this case you need to pass encoded object.
So you need to use:
desired_capabilities['firefox_profile'] = fp.encoded
Reply all
Reply to author
Forward
0 new messages