Set auto download preference profile using selenium2library

寵の児 提交于 2019-12-04 20:01:57

I can find the open_browser() in selenium2library but it only eats a directory

No. It also eats preferences. The long story goes like this:

I am not quite sure how you actually use robotframework-selenium2library. The common usage, I would say, is to run robotframework test cases (i.e. simple UTF-8 text files) which import selenium2library. A possible solution to your problem would look like this (it goes without saying that all variables should be defined below *** Variables ***):

*** Settings ***
Library           Selenium2Library
Library           Collections

*** Variables ***

*** Test Cases ***
MyTestCase
    ${preferences} =    Create Dictionary   browser.download.folderList  2  browser.download.manager.showWhenStarting  False   # and so on ....
    Open Browser    <yourURL>    desired_capabilities=${preferences}

However, your question suggests that you intend to directly use python functions (like open_browser that you mentioned in your question) provided by selenium2library. In that case, all you need to do is to call that function with parameter desired_capabilities set appropriately.

Please note the documentation on that parameter ( full code is to be found here):

If you specify a value for remote you can also specify 'desired_capabilities' which is a string in the form key1:val1,key2:val2 that will be used to specify desired_capabilities to the remote server. This is useful for doing things like specify a proxy server for internet explorer or for specify browser and os if your using saucelabs.com. 'desired_capabilities' can also be a dictonary (created with 'Create Dictionary') to allow for more complex configurations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!