https://blog.csdn.net/qq_42623386/article/details/123391709
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.desired_capabilities import DesiredCapabilities #方法一: mobile_emulation = {"deviceName":"Galaxy S5"} capabilities = DesiredCapabilities.CHROME capabilities['loggingPrefs'] = { 'browser':'ALL' } options = webdriver.ChromeOptions() options.add_experimental_option("mobileEmulation", mobile_emulation) driver = webdriver.Chrome(desired_capabilities=capabilities, chrome_options=options) #方法二 WIDTH = 320 # 宽度 HEIGHT = 640 # 高度 PIXEL_RATIO = 3.0 # 分辨率 mobileEmulation = {"deviceMetrics": {"width": WIDTH, "height": HEIGHT, "pixelRatio": PIXEL_RATIO}} options = webdriver.ChromeOptions() options.add_experimental_option('mobileEmulation', mobileEmulation) capabilities = DesiredCapabilities.CHROME capabilities['loggingPrefs'] = {'browser': 'ALL'} driver = webdriver.Chrome(desired_capabilities=capabilities,chrome_options=options)
标签:webdriver,mobileEmulation,selenium,capabilities,设置,DesiredCapabilities,chrom,opt From: https://www.cnblogs.com/hls-code/p/17247334.html