【问题标题】:Selenium Window Size Not Changing While Using Device Emulation使用设备仿真时 Selenium 窗口大小不会改变
【发布时间】:2022-01-17 20:14:34
【问题描述】:

我在使用设备仿真时尝试使用 chrome 选项更改窗口大小,但它对宽度没有影响,但对高度有效。

chrome_options.add_argument("--window-size=400,600")
chrome_options.add_argument('--log-level=3')
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
mobile_emulation = { "deviceName": "iPhone 6/7/8 Plus" }
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)

也试过

browser.set_window_size(400, 600)

有什么遗漏吗?还是我做错了?

【问题讨论】:

    标签: selenium google-chrome webdriver


    【解决方案1】:

    您不能将 selenium 驱动程序窗口宽度设置为 400。
    AFAIK 最小计算机屏幕宽度为 512。
    要使用较小的窗口宽度,您可以模拟移动设备的屏幕尺寸。
    关于这个问题有几个讨论,例如here

    【讨论】:

      猜你喜欢
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-16
      相关资源
      最近更新 更多