Best Python code snippet using Airtest
ios.py
Source:ios.py
...110 @property111 def uuid(self):112 return self.addr113 @property114 def using_ios_tagent(self):115 """116 å½ååºç¡çæ¬ï¼appium/WebDriverAgent 4.1.4117 åºäºä¸è¿°çæ¬ï¼2022.3.30ä¹ååå¸çiOS-Tagentçæ¬ï¼å¨/statusæ¥å£ä¸æ°å¢äºä¸ä¸ªVersionåæ°ï¼å¦æè½æ£æ¥å°æ¬åæ°ï¼è¯´æ使ç¨äºæ°çæ¬ios-Tagent118 该çæ¬åºäºAppiumççWDAåäºä¸äºæ¹å¨ï¼å¯ä»¥æ´å¿«å°è¿è¡ç¹å»åæ»å¨ï¼å¹¶ä¼åäºé¨åUIæ çè·åé»è¾119 ä½æ¯ææçåæ é½ä¸ºç«å±åæ ï¼éè¦airtestèªè¡æ ¹æ®æ¹åå转æ¢120 åæ¶ï¼å¤§äº4.1.4çæ¬çappium/WebDriverAgentä¸åéè¦é对ipadè¿è¡ç¹æ®ç横å±åæ å¤çäº121 Returns:122 """123 if self._using_ios_tagent is None:124 status = self.driver.status()125 if 'Version' in status:126 self._using_ios_tagent = True127 else:128 self._using_ios_tagent = False...
__init__.py
Source:__init__.py
1# coding=utf-82import xml.etree.ElementTree as ET3from poco.pocofw import Poco4from poco.agent import PocoAgent5from poco.freezeui.hierarchy import FrozenUIDumper, FrozenUIHierarchy6from poco.utils.airtest import AirtestInput, AirtestScreen7from poco.utils import six8from airtest.core.api import device as current_device9try:10 from airtest.core.ios.rotation import XYTransformer11except AttributeError:12 raise RuntimeError('The iOS module of Airtest>1.1.7 only supports python3, if you want to use, please upgrade to python3 first.')13from pprint import pprint14class iosPoco(Poco):15 def __init__(self, device=None, **kwargs):16 device = device or current_device()17 if not device or device.__class__.__name__ != 'IOS':18 raise RuntimeError('Please call `connect_device` to connect an iOS device first')19 agent = iosPocoAgent(device)20 super(iosPoco, self).__init__(agent, **kwargs)21class iosPocoAgent(PocoAgent):22 def __init__(self, client):23 self.client = client24 hierarchy = FrozenUIHierarchy(iosDumper(self.client))25 screen = AirtestScreen()26 input = AirtestInput()27 super(iosPocoAgent, self).__init__(hierarchy, input, screen, None)28class iosDumper(FrozenUIDumper):29 def __init__(self, client):30 super(iosDumper, self).__init__()31 self.client = client32 self.size = client.display_info["window_width"], client.display_info["window_height"]33 def dumpHierarchy(self, onlyVisibleNode=True):34 # å½ä½¿ç¨äºappium/WebDriverAgentæ¶ï¼ipad横å±ä¸å¨æ¡é¢ä¸ï¼åæ éè¦æç
§ç«å±åæ é¢å¤è½¬æ¢ä¸æ¬¡35 # å¤ææ¡ä»¶å¦ä¸ï¼36 # å½ios.using_ios_tagentæå¼ãä¸ä¸ºfalseï¼è¯´æ使ç¨çæ¯appium/WebDriverAgent37 # airtest<=1.2.4æ¶ï¼æ²¡æios.using_ios_tagentçå¼ï¼è¯´æä¹æ¯ç¨çappium/wda38 if ((hasattr(self.client, "using_ios_tagent") and not self.client.using_ios_tagent) or39 (not hasattr(self.client, "using_ios_tagent"))) \40 and (self.client.is_pad and self.client.orientation != 'PORTRAIT' and self.client.home_interface()):41 switch_flag = True42 else:43 switch_flag = False44 jsonObj = self.client.driver.source(format='json')45 w, h = self.size46 if self.client.orientation in ['LANDSCAPE', 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT']:47 w, h = h, w48 data = json_parser(jsonObj, (w, h), switch_flag=switch_flag, ori=self.client.orientation)49 return data50 def dumpHierarchy_xml(self):51 xml = self.client.driver.source()52 xml = xml.encode("utf-8")53 data = ios_dump_xml(xml, self.size)54 return data55def ios_dump_xml(xml, screen_size):56 root = ET.fromstring(xml)57 data = xml_parser(root, screen_size)58 return data59def json_parser(node, screen_size, switch_flag=False, ori='PORTRAIT'):60 """61 :param node: node info {}62 :param screen_size: ios.windows_size()63 :param switch_flag: If it is an ipad , when on the desktop, all coordinates must be converted to vertical screen coordinates64 :param ori: wda ['PORTRAIT', 'LANDSCAPE',65 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT',66 'UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN']67 :return:68 """69 screen_w, screen_h = screen_size70 if "name" in node and node["name"]:71 name = node["name"]72 else:73 name = node["type"]74 data = {75 "name": name,76 "payload": {}77 }78 if six.PY2:79 for key in [x for x in node.keys() if x not in ['frame', 'children']]:80 data["payload"][key.encode("utf-8")] = node[key]81 else:82 for key in [x for x in node.keys() if x not in ['frame', 'children']]:83 data["payload"][key] = node[key]84 w = float(node["rect"]["width"])85 h = float(node["rect"]["height"])86 x = float(node["rect"]["x"])87 y = float(node["rect"]["y"])88 if switch_flag:89 x, y = XYTransformer.ori_2_up(90 (x, y),91 (screen_w, screen_h),92 ori93 )94 if switch_flag and ori == 'LANDSCAPE':95 w, h = h, w96 data["payload"]["pos"] = [97 (x + w / 2) / screen_w,98 (y - h / 2) / screen_h99 ]100 elif switch_flag and ori == 'UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT':101 w, h = h, w102 data["payload"]["pos"] = [103 (x - w / 2) / screen_w,104 (y + h / 2) / screen_h105 ]106 elif switch_flag and ori == 'UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN':107 data["payload"]["pos"] = [108 (x - w / 2) / screen_w,109 (y - h / 2) / screen_h110 ]111 else:112 data["payload"]["pos"] = [113 (x + w / 2) / screen_w,114 (y + h / 2) / screen_h115 ]116 data["payload"]["name"] = name117 data["payload"]["size"] = [w / screen_w, h / screen_h]118 119 data["payload"]["zOrders"] = {120 "local": 0,121 "global": 0,122 }123 data["payload"]["anchorPoint"] = [0.5, 0.5]124 # TODO: w = 0 and h = 0 situation need to solve with125 # roll back set as True when finding a visible child126 if "visible" not in node:127 if (x >= 0 or x + w > 0) and (x < screen_w) and (y >= 0 or y + h > 0) and (y < screen_h):128 data["payload"]["visible"] = True129 elif w == 0 or h == 0:130 data["payload"]["visible"] = True131 else:132 data["payload"]["visible"] = False133 children_data = []134 if "children" in node:135 for child in node["children"]:136 child_data = json_parser(child, screen_size=screen_size, switch_flag=switch_flag, ori=ori)137 children_data.append(child_data)138 if children_data:139 data["children"] = children_data140 if data["payload"]["visible"] is False:141 for child_node in children_data:142 if child_node["payload"].get("visible") is True:143 data["payload"]["visible"] = True144 break145 return data146def xml_parser(node, screen_size):147 # print(node)148 # print(node.attrib)149 screen_w, screen_h = screen_size150 name = node.attrib.get("name", node.tag)151 data = {152 "name": name,153 "payload": node.attrib,154 }155 w = float(node.attrib["width"])156 h = float(node.attrib["height"])157 x = float(node.attrib["x"])158 y = float(node.attrib["y"])159 data["payload"]["name"] = name160 data["payload"]["size"] = [w / screen_w, h / screen_h]161 data["payload"]["pos"] = [162 (x + w / 2) / screen_w,163 (y + h / 2) / screen_h164 ]165 data["payload"]["zOrders"] = {166 "local": 0,167 "global": 0,168 }169 data["payload"]["anchorPoint"] = (0.5, 0.5)170 children_data = []171 for child in node:172 child_data = xml_parser(child, screen_size)173 children_data.append(child_data)174 if children_data:175 data["children"] = children_data176 return data177if __name__ == '__main__':178 XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<XCUIElementTypeApplication type=\"XCUIElementTypeApplication\" name=\"å¥åº·\" label=\"å¥åº·\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeWindow type=\"XCUIElementTypeWindow\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeNavigationBar type=\"XCUIElementTypeNavigationBar\" name=\"WDTodayDayPageView\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"44\" width=\"375\" height=\"44\">\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" name=\"äºæ\" label=\"äºæ\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"44\" width=\"65\" height=\"44\"/>\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" name=\"æ¥ç个人èµæ\" label=\"æ¥ç个人èµæ\" enabled=\"true\" visible=\"true\" x=\"334\" y=\"53\" width=\"25\" height=\"26\"/>\n </XCUIElementTypeNavigationBar>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeTable type=\"XCUIElementTypeTable\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"å¥èº«è®°å½\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"176\" width=\"375\" height=\"37\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"å¥èº«è®°å½\" label=\"å¥èº«è®°å½\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"176\" width=\"375\" height=\"37\"/>\n </XCUIElementTypeOther>\n <XCUIElementTypeCell type=\"XCUIElementTypeCell\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"213\" width=\"375\" height=\"82\">\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"1.8å
¬é\" name=\"1.8å
¬é\" label=\"1.8å
¬é\" enabled=\"true\" visible=\"true\" x=\"254\" y=\"214\" width=\"93\" height=\"54\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"ä»å¤© ä¸å10:05\" name=\"ä»å¤© ä¸å10:05\" label=\"ä»å¤© ä¸å10:05\" enabled=\"true\" visible=\"true\" x=\"262\" y=\"266\" width=\"86\" height=\"15\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"æ¥è¡ + è·æ¥è·ç¦»\" name=\"æ¥è¡ + è·æ¥è·ç¦»\" label=\"æ¥è¡ + è·æ¥è·ç¦»\" enabled=\"true\" visible=\"true\" x=\"28\" y=\"220\" width=\"124\" height=\"21\"/>\n </XCUIElementTypeCell>\n <XCUIElementTypeCell type=\"XCUIElementTypeCell\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"295\" width=\"375\" height=\"82\">\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"2,438æ¥\" name=\"2,438æ¥\" label=\"2,438æ¥\" enabled=\"true\" visible=\"true\" x=\"209\" y=\"296\" width=\"138\" height=\"54\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"ä»å¤© ä¸å10:05\" name=\"ä»å¤© ä¸å10:05\" label=\"ä»å¤© ä¸å10:05\" enabled=\"true\" visible=\"true\" x=\"262\" y=\"348\" width=\"86\" height=\"15\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"æ¥æ°\" name=\"æ¥æ°\" label=\"æ¥æ°\" enabled=\"true\" visible=\"true\" x=\"28\" y=\"302\" width=\"35\" height=\"21\"/>\n </XCUIElementTypeCell>\n <XCUIElementTypeCell type=\"XCUIElementTypeCell\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"377\" width=\"375\" height=\"82\">\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"ä»å¤© ä¸å9:24\" name=\"ä»å¤© ä¸å9:24\" label=\"ä»å¤© ä¸å9:24\" enabled=\"true\" visible=\"true\" x=\"268\" y=\"430\" width=\"79\" height=\"15\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"4å±\" name=\"4å±\" label=\"4å±\" enabled=\"true\" visible=\"true\" x=\"300\" y=\"378\" width=\"48\" height=\"54\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"å·²ç¬æ¥¼å±\" name=\"å·²ç¬æ¥¼å±\" label=\"å·²ç¬æ¥¼å±\" enabled=\"true\" visible=\"true\" x=\"28\" y=\"384\" width=\"70\" height=\"21\"/>\n </XCUIElementTypeCell>\n </XCUIElementTypeTable>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"88\" width=\"375\" height=\"88\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"88\" width=\"375\" height=\"88\">\n <XCUIElementTypeScrollView type=\"XCUIElementTypeScrollView\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"105\" width=\"375\" height=\"35\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"105\" width=\"375\" height=\"58\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ13æ¥ æææ¥\" label=\"5æ13æ¥ æææ¥\" enabled=\"true\" visible=\"true\" x=\"13\" y=\"110\" width=\"36\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"ä»å¤©, 5æ14æ¥ ææä¸\" label=\"ä»å¤©, 5æ14æ¥ ææä¸\" enabled=\"true\" visible=\"true\" x=\"65\" y=\"110\" width=\"36\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ15æ¥ ææäº\" label=\"5æ15æ¥ ææäº\" enabled=\"true\" visible=\"true\" x=\"118\" y=\"110\" width=\"35\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ16æ¥ ææä¸\" label=\"5æ16æ¥ ææä¸\" enabled=\"true\" visible=\"true\" x=\"170\" y=\"110\" width=\"35\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ17æ¥ ææå\" label=\"5æ17æ¥ ææå\" enabled=\"true\" visible=\"true\" x=\"222\" y=\"110\" width=\"35\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ18æ¥ ææäº\" label=\"5æ18æ¥ ææäº\" enabled=\"true\" visible=\"true\" x=\"274\" y=\"110\" width=\"36\" height=\"35\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"5æ19æ¥ ææå
\" label=\"5æ19æ¥ ææå
\" enabled=\"true\" visible=\"true\" x=\"326\" y=\"110\" width=\"36\" height=\"35\"/>\n </XCUIElementTypeOther>\n </XCUIElementTypeScrollView>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"2018å¹´5æ14æ¥ ææä¸\" name=\"2018å¹´5æ14æ¥ ææä¸\" label=\"2018å¹´5æ14æ¥ ææä¸\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"148\" width=\"375\" height=\"20\"/>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n </XCUIElementTypeOther>\n <XCUIElementTypeTabBar type=\"XCUIElementTypeTabBar\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"729\" width=\"375\" height=\"83\">\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" value=\"1\" name=\"ä»å¤©\" label=\"ä»å¤©\" enabled=\"true\" visible=\"true\" x=\"2\" y=\"730\" width=\"90\" height=\"48\"/>\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" name=\"å¥åº·æ°æ®\" label=\"å¥åº·æ°æ®\" enabled=\"true\" visible=\"true\" x=\"96\" y=\"730\" width=\"90\" height=\"48\"/>\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" name=\"æ°æ®æ¥æº\" label=\"æ°æ®æ¥æº\" enabled=\"true\" visible=\"true\" x=\"190\" y=\"730\" width=\"89\" height=\"48\"/>\n <XCUIElementTypeButton type=\"XCUIElementTypeButton\" name=\"å»çæ¥æå¡\" label=\"å»çæ¥æå¡\" enabled=\"true\" visible=\"true\" x=\"283\" y=\"730\" width=\"90\" height=\"48\"/>\n </XCUIElementTypeTabBar>\n </XCUIElementTypeOther>\n </XCUIElementTypeWindow>\n <XCUIElementTypeWindow type=\"XCUIElementTypeWindow\" enabled=\"true\" visible=\"false\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"0\" y=\"812\" width=\"375\" height=\"233\"/>\n </XCUIElementTypeOther>\n </XCUIElementTypeWindow>\n <XCUIElementTypeWindow type=\"XCUIElementTypeWindow\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"812\">\n <XCUIElementTypeStatusBar type=\"XCUIElementTypeStatusBar\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"44\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"44\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"0\" y=\"0\" width=\"375\" height=\"44\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"14\" y=\"0\" width=\"172\" height=\"29\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"true\" x=\"190\" y=\"0\" width=\"171\" height=\"29\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"14\" y=\"10\" width=\"68\" height=\"19\">\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"10:56\" name=\"10:56\" label=\"10:56\" enabled=\"true\" visible=\"false\" x=\"27\" y=\"14\" width=\"42\" height=\"18\"/>\n </XCUIElementTypeOther>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"21\" y=\"8\" width=\"56\" height=\"22\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"293\" y=\"10\" width=\"68\" height=\"19\">\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" name=\"ä¿¡å·å¼ºåº¦ï¼4ï¼å
± 4 æ ¼ï¼\" label=\"ä¿¡å·å¼ºåº¦ï¼4ï¼å
± 4 æ ¼ï¼\" enabled=\"true\" visible=\"false\" x=\"293\" y=\"17\" width=\"18\" height=\"12\"/>\n <XCUIElementTypeStaticText type=\"XCUIElementTypeStaticText\" value=\"4G\" name=\"4G\" label=\"4G\" enabled=\"true\" visible=\"false\" x=\"315\" y=\"16\" width=\"17\" height=\"15\"/>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" value=\"æ£å¨å
çµ\" name=\"çµæ± çµéï¼68%\" label=\"çµæ± çµéï¼68%\" enabled=\"true\" visible=\"false\" x=\"336\" y=\"17\" width=\"25\" height=\"12\"/>\n </XCUIElementTypeOther>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"293\" y=\"10\" width=\"68\" height=\"19\"/>\n </XCUIElementTypeOther>\n <XCUIElementTypeOther type=\"XCUIElementTypeOther\" enabled=\"true\" visible=\"false\" x=\"8\" y=\"24\" width=\"82\" height=\"14\"/>\n </XCUIElementTypeOther>\n </XCUIElementTypeStatusBar>\n </XCUIElementTypeWindow>\n</XCUIElementTypeApplication>\n"179 import json180 import requests181 jsonStr = requests.get("http://10.254.51.239:8100/source?format=json")182 jsonStr = jsonStr.text183 jsonObj = json.loads(jsonStr)184 dump = ios_dump_xml(XML, (375, 812))185 dumpJson = ios_dump_json(jsonObj["value"], (375, 812))...
test_ios.py
Source:test_ios.py
...40 # 以ä¸ç¨ä¾å¯è½ä¼å 为wdaæ´æ°è失败ï¼å°æ¶åéè¦å»æ ios._display_infoéçipad横å±ä¸çé¢å¤å¤ç41 # å½ipad å¨æ¨ªå±+æ¡é¢çæ
åµä¸ï¼è·åå°çwindow_sizeçå¼ä¸º height*heightï¼æ²¡æwidthçå¼42 if self.ios.is_pad and self.client.orientation != 'PORTRAIT' and self.ios.home_interface():43 self.assertEqual(window_size.width, window_size.height)44 def test_using_ios_tagent(self):45 status = self.ios.driver.status()46 print(self.ios.using_ios_tagent)47 self.assertEqual('Version' in status, self.ios.using_ios_tagent)48 def test_snapshot(self):49 print("test_snapshot")50 filename = "./screen.png"51 if os.path.exists(filename):52 os.remove(filename)53 54 screen = self.ios.snapshot(filename=filename)55 self.assertIsInstance(screen, numpy.ndarray)56 self.assertTrue(os.path.exists(filename))57 def test_get_frames(self):58 frame = self.ios.get_frame_from_stream()...
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!!