跳到主要內容

setViewport

調整瀏覽器內的可視區域大小。與 setWindowSize 不同,此命令會變更可視區域的大小,而不是視窗的大小。

用法
browser.setViewport({ width, height, devicePixelRatio })
參數
名稱類型詳細資訊
optionsSetViewportOptions命令引數
options.widthnumber可視區域寬度(以像素為單位)
options.heightnumber可視區域高度(以像素為單位)
options.devicePixelRationumber可視區域的像素比

歡迎!我能幫上什麼忙?

WebdriverIO AI Copilot