How to use update_cur_display method in Airtest

Best Python code snippet using Airtest

adb.py

Source:adb.py Github

copy

Full Screen

...849 return int(m.group(1))850 # We couldn't obtain the orientation851 warnings.warn("Could not obtain the orientation, return 0")852 return 0853 def update_cur_display(self, display_info):854 """855 Some phones support resolution modification, try to get the modified resolution from dumpsys856 adb shell dumpsys window displays | find "cur="857 本方法虽然可以更好地获取到部分修改过分辨率的手机信息858 但是会因为cur=(\d+)x(\d+)的数值在不同设备上width和height的顺序可能不同,导致横竖屏识别出现问题859 airtest不再使用本方法作为通用的屏幕尺寸获取方法,但依然可用于部分设备获取当前被修改过的分辨率860 Examples:861 >>> # 部分三星和华为设备,若分辨率没有指定为最高,可能会导致点击偏移,可以用这个方式强制修改:862 >>> # For some Samsung and Huawei devices, if the resolution is not specified as the highest,863 >>> # it may cause click offset, which can be modified in this way:864 >>> dev = device()865 >>> info = dev.display_info866 >>> info2 = dev.adb.update_cur_display(info)867 >>> dev.display_info.update(info2)868 Args:869 display_info: the return of self.getPhysicalDisplayInfo()870 Returns:871 display_info872 """873 # adb shell dumpsys window displays | find "init="874 # 上面的命令行在dumpsys window里查找init=widthxheight,得到的结果是物理分辨率,且部分型号手机不止一个结果875 # 如果改为读取 cur=widthxheight 的数据,得到的是修改过分辨率手机的结果(例如三星S8)876 actual = self.shell("dumpsys window displays")877 arr = re.findall(r'cur=(\d+)x(\d+)', actual)878 if len(arr) > 0:879 # 强制设定宽度width为更小的数字、height为更大的数字,避免因为各手机厂商返回结果的顺序不同导致问题880 # Set the width to a smaller number and the height to a larger number...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful