Best Python code snippet using Airtest
adb.py
Source:adb.py
...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...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!