How to use _convenienceMatch method in pyatom

Best Python code snippet using pyatom_python

AXClasses.py

Source:AXClasses.py Github

copy

Full Screen

...1039 callback = AXCallbacks.returnElemCallback1040 retelem = None1041 return self.waitFor(timeout, 'AXFocusedWindowChanged',1042 AXTitle=nextWinName)1043 def _convenienceMatch(self, role, attr, match):1044 """Method used by role based convenience functions to find a match"""1045 kwargs = {}1046 # If the user supplied some text to search for,1047 # supply that in the kwargs1048 if match:1049 kwargs[attr] = match1050 return self.findAll(AXRole=role, **kwargs)1051 def _convenienceMatchR(self, role, attr, match):1052 """Method used by role based convenience functions to find a match"""1053 kwargs = {}1054 # If the user supplied some text to search for,1055 # supply that in the kwargs1056 if match:1057 kwargs[attr] = match1058 return self.findAllR(AXRole=role, **kwargs)1059 def textAreas(self, match=None):1060 """Return a list of text areas with an optional match parameter."""1061 return self._convenienceMatch('AXTextArea', 'AXTitle', match)1062 def textAreasR(self, match=None):1063 """Return a list of text areas with an optional match parameter."""1064 return self._convenienceMatchR('AXTextArea', 'AXTitle', match)1065 def textFields(self, match=None):1066 """Return a list of textfields with an optional match parameter."""1067 return self._convenienceMatch('AXTextField', 'AXRoleDescription', match)1068 def textFieldsR(self, match=None):1069 """Return a list of textfields with an optional match parameter."""1070 return self._convenienceMatchR('AXTextField', 'AXRoleDescription',1071 match)1072 def buttons(self, match=None):1073 """Return a list of buttons with an optional match parameter."""1074 return self._convenienceMatch('AXButton', 'AXTitle', match)1075 def buttonsR(self, match=None):1076 """Return a list of buttons with an optional match parameter."""1077 return self._convenienceMatchR('AXButton', 'AXTitle', match)1078 def windows(self, match=None):1079 """Return a list of windows with an optional match parameter."""1080 return self._convenienceMatch('AXWindow', 'AXTitle', match)1081 def windowsR(self, match=None):1082 """Return a list of windows with an optional match parameter."""1083 return self._convenienceMatchR('AXWindow', 'AXTitle', match)1084 def sheets(self, match=None):1085 """Return a list of sheets with an optional match parameter."""1086 return self._convenienceMatch('AXSheet', 'AXDescription', match)1087 def sheetsR(self, match=None):1088 """Return a list of sheets with an optional match parameter."""1089 return self._convenienceMatchR('AXSheet', 'AXDescription', match)1090 def staticTexts(self, match=None):1091 """Return a list of statictexts with an optional match parameter."""1092 return self._convenienceMatch('AXStaticText', 'AXValue', match)1093 def staticTextsR(self, match=None):1094 """Return a list of statictexts with an optional match parameter"""1095 return self._convenienceMatchR('AXStaticText', 'AXValue', match)1096 def genericElements(self, match=None):1097 """Return a list of genericelements with an optional match parameter."""1098 return self._convenienceMatch('AXGenericElement', 'AXValue', match)1099 def genericElementsR(self, match=None):1100 """Return a list of genericelements with an optional match parameter."""1101 return self._convenienceMatchR('AXGenericElement', 'AXValue', match)1102 def groups(self, match=None):1103 """Return a list of groups with an optional match parameter."""1104 return self._convenienceMatch('AXGroup', 'AXRoleDescription', match)1105 def groupsR(self, match=None):1106 """Return a list of groups with an optional match parameter."""1107 return self._convenienceMatchR('AXGroup', 'AXRoleDescription', match)1108 def radioButtons(self, match=None):1109 """Return a list of radio buttons with an optional match parameter."""1110 return self._convenienceMatch('AXRadioButton', 'AXTitle', match)1111 def radioButtonsR(self, match=None):1112 """Return a list of radio buttons with an optional match parameter."""1113 return self._convenienceMatchR('AXRadioButton', 'AXTitle', match)1114 def popUpButtons(self, match=None):1115 """Return a list of popup menus with an optional match parameter."""1116 return self._convenienceMatch('AXPopUpButton', 'AXTitle', match)1117 def popUpButtonsR(self, match=None):1118 """Return a list of popup menus with an optional match parameter."""1119 return self._convenienceMatchR('AXPopUpButton', 'AXTitle', match)1120 def rows(self, match=None):1121 """Return a list of rows with an optional match parameter."""1122 return self._convenienceMatch('AXRow', 'AXTitle', match)1123 def rowsR(self, match=None):1124 """Return a list of rows with an optional match parameter."""1125 return self._convenienceMatchR('AXRow', 'AXTitle', match)1126 def sliders(self, match=None):1127 """Return a list of sliders with an optional match parameter."""1128 return self._convenienceMatch('AXSlider', 'AXValue', match)1129 def slidersR(self, match=None):1130 """Return a list of sliders with an optional match parameter."""...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...64 flag = True65 except:66 pass67 if not flag:68 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '持仓')[0].Press()69 time.sleep(0.1)70 flag = False71 while not flag:72 try:73 s = _tdx.windows()[0].staticTextsR('人民币: 余额:*')[0].AXValue74 if len(s) > 0:75 flag = True76 break77 except:78 pass79 time.sleep(0.1)80 s = _tdx.windows()[0].staticTextsR('人民币: 余额:*')[0].AXValue81 cash_balance, cash_available, _, stocks_total, assets_total = re.match(82 r'人民币:余额:([\d\.]*)可用:([\d\.]*)可取:([\d\.]*)股票市值:([\d\.]*)资产:([\d\.]*)', s.replace(' ', '')).groups()83 if portfolio:84 portfolio = _table_to_dataframe('累计浮动盈亏').iloc[:, :-1]85 portfolio.set_index('证券代码', inplace=True)86 return (float(cash_balance), float(cash_available), float(stocks_total), float(assets_total)), portfolio87def query_orders():88 global _tdx89 _activate()90 time.sleep(0.1)91 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '成交')[0].Press()92 time.sleep(1.8)93 today_orders = _table_to_dataframe('成交日期').iloc[:, :-2]94 print(today_orders)95 _click(_tdx.windows()[0].AXChildren[2]._convenienceMatchR('AXTextField', 'AXValue', ' 历史成交')[0])96 time.sleep(1.8)97 history_orders = _table_to_dataframe('成交日期').iloc[:, :-1]98 print(history_orders)99 import pandas as pd100 orders = pd.concat([today_orders, history_orders])101 return orders102def _table_to_dataframe(header_key):103 global _tdx104 table = _tdx.windows()[0].buttonsR(header_key)[0].AXParent.AXParent105 rows = table._convenienceMatch('AXRow', 'AXRoleDescription', 'table row')106 data = [[column.AXValue for column in row.AXChildren] for row in rows]107 columns = [button.AXTitle for button in table.buttonsR()]108 import pandas as pd109 return pd.DataFrame(data, columns=columns)110def buy(codes, positions):111 # logger.debug('enter buy')112 global _tdx113 _activate()114 time.sleep(0.1)115 # logger.debug('will press buy button')116 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '买入')[0].Press()117 time.sleep(0.2)118 codes = [codes] if isinstance(codes, str) else codes119 # logger.debug('loop codes for buy')120 for code, money in zip(codes, positions):121 # logger.debug('target code is: {}'.format(code))122 try:123 time.sleep(0.2)124 # logger.debug('will press order type 1')125 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()126 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()127 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[128 0].AXChildren129 type_index = 0130 # logger.debug('will click type option')131 _click(types[type_index])132 time.sleep(0.1)133 # logger.debug('set code focus')134 _tdx.windows()[0].textFields()[0].AXFocused = True135 _tdx.windows()[0].textFields()[0].setString('AXValue', code)136 # _tdx.windows()[0].textFields()[0].Confirm()137 time.sleep(1.5)138 price = _tdx.windows()[0].textFields()[2].AXValue139 price = float(price)140 # logger.debug('price is: {}'.format(price))141 amount = int(money / price / 100) * 100142 if amount < 100:143 print(33)144 # logger.error('money: {} can not buy {} 100 shares, stock price: {}'.format(money, code, price))145 # amount = 100146 # logger.debug('amount is: {}'.format(amount))147 _tdx.windows()[0].textFields()[1].setString('AXValue', amount)148 _tdx.windows()[0].textFields()[1].Confirm()149 time.sleep(0.5)150 # logger.debug('select order type option')151 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()152 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()153 # time.sleep(0.1)154 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[155 0].AXChildren156 type_index = 4 if len(types) > 3 else 1157 # logger.debug('click order option: {}'.format(types[type_index]))158 _click(types[type_index])159 time.sleep(0.1)160 if not DEBUG:161 _click(_tdx.windows()[0].buttonsR('买入下单')[0])162 time.sleep(0.2)163 _confirmIfMessage()164 time.sleep(0.5)165 _confirmIfMessage()166 time.sleep(0.2)167 except:168 pass169 # logger.exception('Exception while tdx.buy')170def sell(codes):171 # logger.debug('enter sell')172 global _tdx173 _activate()174 time.sleep(0.1)175 # logger.debug('press the sell button')176 _tdx.windows()[0]._convenienceMatch('AXCheckBox', 'AXTitle', '卖出')[0].Press()177 time.sleep(0.1)178 codes = [codes] if isinstance(codes, str) else codes179 # logger.debug('loop codes for sell')180 for code in codes:181 # logger.debug('target code: {}'.format(code))182 try:183 _tdx.windows()[0].textFields()[0].AXFocused = True184 _tdx.windows()[0].textFields()[0].setString('AXValue', code)185 # _tdx.windows()[0].textFields()[0].Confirm()186 time.sleep(1.5)187 _click(_tdx.windows()[0].buttonsR('全部')[0])188 time.sleep(0.1)189 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()190 _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[0].Press()191 # time.sleep(0.1)192 types = _tdx.windows()[0]._convenienceMatch('AXComboBox', 'AXTitle', None)[1].AXChildren[1].AXChildren[193 0].AXChildren194 type_index = 4 if len(types) > 3 else 1195 # logger.debug('click order option: {}'.format(types[type_index]))196 _click(types[type_index])197 time.sleep(0.1)198 # stop_price = _tdx.windows()[0]._convenienceMatch('AXScrollArea', 'AXTitle', None)[1].AXChildren[0]._convenienceMatch('AXRow', 'AXTitle', None)[-3].AXChildren[1].AXValue199 if not DEBUG:200 _click(_tdx.windows()[0].buttonsR('卖出下单')[0])201 time.sleep(0.2)202 _confirmIfMessage()203 time.sleep(0.2)204 _confirmIfMessage()205 time.sleep(0.2)206 except:207 pass208 # logger.exception('Exception while tdx.sell')209# def query_order(codes, flag=None):210# global _tdx211# _activate()212# time.sleep(0.1)...

Full Screen

Full Screen

automateMac.py

Source:automateMac.py Github

copy

Full Screen

...8if platform.system() != 'Windows':9 import atomac10 11 def get_group(self, match = None):12 return self._convenienceMatch('AXGroup', 'AXRoleDescription', match)13 14 atomac.NativeUIElement.group = get_group15 16 17 def get_splitgroup(self, match = None):18 return self._convenienceMatch('AXSplitGroup', 'AXRoleDescription', match)19 20 atomac.NativeUIElement.splitgroup = get_splitgroup21 22 def get_outline(self, match = None):23 return self._convenienceMatch('AXOutline', 'AXRoleDescription', match)24 25 atomac.NativeUIElement.outline = get_outline26 27 def get_row(self, match = None):28 return self._convenienceMatch('AXRow', 'AXRoleDescription', match)29 30 atomac.NativeUIElement.row = get_row31 32 def get_scollarea(self, match = None):33 return self._convenienceMatch('AXScrollArea', 'AXRoleDescription', match)34 35 atomac.NativeUIElement.scollarea = get_scollarea36 def get_table(self, match = None):37 return self._convenienceMatch('AXTable', 'AXRoleDescription', match)38 39 atomac.NativeUIElement.table = get_table40 41 42 def get_statictext(self, match = None):43 return self._convenienceMatch('AXStaticText', 'AXRoleDescription', match)44 45 atomac.NativeUIElement.text = get_statictext46 def get_toolbars(self, match = None):47 return self._convenienceMatch('AXToolbar', 'AXRoleDescription', match)48 49 atomac.NativeUIElement.toolbars = get_toolbars50 51 def get_checkboxs(self, match = None):52 return self._convenienceMatch('AXCheckBox', 'AXRoleDescription', match)53 54 atomac.NativeUIElement.checkboxs = get_checkboxs 55 # 打开指定序列的控件页面:1-Activity;2-gpu56 def jump_page(instrument, index):57 page_group = instrument.windows()[0].group()[0].splitgroup()[0]58 page_obj = page_group.group()[0].outline()[0].row()[index].table()[0].row()[1]59 # 第一次点击只到app窗口,第二次点击才到控件分页60 page_obj.clickMouseButtonLeft(page_obj.AXPosition)61 time.sleep(0.1)62 page_obj.clickMouseButtonLeft(page_obj.AXPosition)63 64 def get_systeminfo(instrument, appname):65 systeminfo = []66 s_splitgroup = instrument.windows()[0].group()[0].splitgroup()[0]...

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 pyatom 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