selenium控制浏览器为手机模式

# -*- coding: utf-8 -*-
from selenium import webdriver
from time import sleep


mobileEmulation = {'deviceName': 'Apple iPhone 4'}
options = webdriver.ChromeOptions()
options.add_experimental_option('mobileEmulation', mobileEmulation)

driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)

driver.get('http://m.baidu.com')

sleep(3)
driver.close()

  其中Apple iPhone 4为浏览器内支持的手机型号

转载于:https://www.cnblogs.com/xqnq2007/p/7921504.html

你可能感兴趣的:(selenium控制浏览器为手机模式)