Creating Firefox profile with responsive design preset

﹥>﹥吖頭↗ 提交于 2019-12-23 05:37:05

问题


I am new to mobile automation. How can I create Firefox profile with responsive design preset?


回答1:


You need to set the devtools.responsiveUI.presets firefox preference.

Example, using Python:

import json

from selenium import webdriver


presets = [
    {
        "key": "480x800",
        "name": "Google Nexus one",
        "width": 480,
        "height": 800
    },

    # TO FILL

    {
        "key": "1680x1050",
        "name": "Desktop - stat 2.96%",
        "width": 1680,
        "height": 1050
    }
]

profile = webdriver.FirefoxProfile()
profile.set_preference('devtools.responsiveUI.presets', json.dumps(presets))

driver = webdriver.Firefox(profile)

Also, see:

  • Responsive Design View Presets in Firefox for Web Development


来源:https://stackoverflow.com/questions/30641779/creating-firefox-profile-with-responsive-design-preset

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