问题
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