chrome浏览器5.0_Chrome模拟iPhone x系列手机进行H5兼容性测试

在缺乏iPhone X系列物理设备的情况下,为解决H5在这些设备上的兼容性问题,本文介绍了通过Chrome浏览器进行模拟测试的方法。首先,阐述了H5页面依赖CSS进行渲染的原理,然后详细说明了模拟过程:安装Chrome,打开H5页面,启用开发者工具,模拟手机设备,添加自定义的iPhone XR, iPhone XS, iPhone XS Max设备,并调整User Agent字符串,从而实现对不同型号的模拟测试。" 79111859,7379371,Layui数据表格动态添加行及跳转,"['前端开发', 'Layui', '表格操作']
摘要由CSDN通过智能技术生成

背景

在测试过程中,在iPhone x系列手机上h5经常出现兼容性问题。但是测试过程中iPhone x系列手机比较少,公司大量测试争用1台iPhone x设备。面对众多使用h5进行开发的页面,iPhone x系列手机兼容性又必须做。面对这一窘境,本文提出使用Chrome模拟iPhone x系列手机进行h5兼容性测试。

原理

H5页面使用CSS进行页面渲染,在研究我们如何进行iPhone x系列手机兼容时,发现使用的css如下所示:

@charset "UTF-8";@media only screen and (device-width: 375px) and (device-height:812px) and (-webkit-device-pixel-ratio:3) and (orientation:portrait) {
    .fixed-bottom-bar {
        bottom:34px!important
    }
}

@media only screen and (device-width: 375px) and (device-height:812px) and (-webkit-device-pixel-ratio:2) and (orientation:portrait) {
    .fixed-bottom-bar {
        bottom:34px!important
    }
}

@media only screen and (device-width: 414px) and (device-height:896px) and (-webkit-device-pixel-ratio:3) and (orientation:portrait) {
    .fixed-bottom-bar {
        bottom:34px!important
    }
}

@media only screen and (device-width: 414px) and (device-height:896px) and (-webkit-device-pixel-ratio:2) and (orientation:portrait) {
    .fixed-bottom-bar {
        bottom:34px!important
    }
}

根据上述css,可以通过Chrome来模拟h5测试。

实施步骤

1、安装Chrome浏览器后,打开H5页面(以知乎h5为例演示)。按F12打开开发工具。

d5fc0cb80f4c884919f873fc42e584f2.png

2、点击开发工具左上角的手机图标,可以模拟手机中h5展示效果。

40853e883150fec73006ca9a546e8ae1.png

3、点击下图中的Edit,添加设备

f3d471cd0d5fee385d4f24856e00de9a.png

4、点击Add Custom Device,添加设备

7137274c12e501d8a88ff7170585f79d.png

5、添加名为iPhone XR的设备,设备配置如下:

d8e077f4f6e9aefb2a3b327fc3a6a273.png

其中User agent string如下:

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

6、同步骤5,添加iPhone xs、iPhone xs max设备,分别如下

4a582affeb8c0546a328543b2107993e.png

8baff51b4b88eb761a79870796369e35.png

7、下一步便可愉快的模拟iPhone x系列手机进行H5兼容性测试了。

参考资料

1、iPhone x系列手机屏幕分辨率、竖屏点。

1e35d021189dc0c441b3a4d7bf57deb3.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值