Python 3.x 如何使用Selenium打开google chrome开发工具,并将切换设备工具栏设置为特定设备(例如:iPhone X)?

Python 3.x 如何使用Selenium打开google chrome开发工具,并将切换设备工具栏设置为特定设备(例如:iPhone X)?,python-3.x,selenium,mobile,google-chrome-devtools,chrome-web-driver,Python 3.x,Selenium,Mobile,Google Chrome Devtools,Chrome Web Driver,我现在的代码是- from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys options = webdriver.ChromeOptions() mobile_emulation = { "deviceName": "iPhone X" } #Specifying

我现在的代码是-

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

options = webdriver.ChromeOptions()
mobile_emulation = { "deviceName": "iPhone X" } #Specifying device
options.add_argument("start-maximized")
options.add_argument("--auto-open-devtools-for-tabs")
options.add_experimental_option("mobileEmulation", mobile_emulation) #For mobile
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'/Users/amigo/Documents/pet_projects/selenium/chromedriver')
driver.get("https://google.com")
这会像这样打开chrome-请注意,
切换移动设备
选项卡(位于
元素
旁边)未激活,默认情况下会以响应模式打开

我打算用选定的特定设备打开它,如下所示-


感谢所有建议和投入!提前谢谢你

这回答了你的问题吗?这应该是你问题的答案。你为什么要这么做?