Selenium 关于 selenium+Chrome 浏览器,搭建 H5 页面,浏览器中模拟器中的顶部型号,参数都传那些,怎么传

Jared_YJ · November 15, 2018 · Last by Pactortester replied at May 30, 2019 · 1352 hits

关于 selenium+Chrome 浏览器,搭建 H5 页面,浏览器中模拟器中的顶部型号,参数都传那些,怎么传

共收到 5 条回复 时间 点赞

搭建 H5 页面?你的题目没看明白。

Kevin Gu 回复


截图中这些顶部的数据,在 java 中怎么写。

这叫模拟移动设备吧。
参考一下 selenium chromedriver 的 chromeOptions - mobileEmulation, 一般传 device name 就可以了

mobile_emulation = {
            "deviceMetrics": {"width": 360, "height": 840, "pixelRatio": 3.0},
            "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"}
        options = webdriver.ChromeOptions()
        options.add_experimental_option("mobileEmulation", mobile_emulation)
        self.driver = webdriver.Chrome(executable_path=driver_path + "\\" + "chromedriver.exe", options=options)
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up