Best Python code snippet using fMBT_python
fmbtwindows.py
Source:fmbtwindows.py
...1113 "window": window,1114 "view": str(self._lastView),1115 "item count": itemCount}1116 return self._lastView1117 def refreshViewDefaults(self):1118 """Returns default arguments for refreshView() calls.1119 See also setRefreshViewDefaults().1120 """1121 return dict(self._refreshViewDefaults)1122 def setClipboard(self, data):1123 """1124 Set text on clipboard1125 Parameters:1126 data (string):1127 data to be set on the clipboard.1128 Note: any type of data on clipboard will be emptied.1129 See also: getClipboard()1130 """1131 return self.existingConnection().evalPython(1132 "setClipboardText(%s)" % (repr(data),))1133 def setErrorReporting(self, settings):1134 """1135 Modify Windows error reporting settings (WER)1136 Parameters:1137 settings (dictionary):1138 WER settings and values to be set.1139 Example: disable showing interactive crash dialogs1140 setErrorReporting({"DontShowUI": 1})1141 See also: errorReporting(),1142 MSDN WER Settings.1143 """1144 for setting in settings:1145 self.setRegistry(1146 r"HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows Error Reporting",1147 setting, settings[setting])1148 return True1149 def setDisplaySize(self, size):1150 """1151 Transform coordinates of synthesized events (like a tap) from1152 screenshot resolution to display input area size. By default1153 events are synthesized directly to screenshot coordinates.1154 Parameters:1155 size (pair of integers: (width, height)):1156 width and height of display in pixels. If not given,1157 values from EnumDisplayMonitors are used.1158 Returns None.1159 """1160 width, height = size1161 screenWidth, screenHeight = self.screenSize()1162 self._conn.setScreenToDisplayCoords(1163 lambda x, y: (x * width / screenWidth,1164 y * height / screenHeight))1165 self._conn.setDisplayToScreenCoords(1166 lambda x, y: (x * screenWidth / width,1167 y * screenHeight / height))1168 def setForegroundWindow(self, window):1169 """1170 Set a window with the title as a foreground window1171 Parameters:1172 window (title (string) or hwnd (integer):1173 title or handle of the window to be raised1174 foreground.1175 Returns True if the window was brought to the foreground,1176 otherwise False.1177 Notes: calls SetForegroundWindow in user32.dll.1178 """1179 return self.existingConnection().sendSetForegroundWindow(window)1180 def setRefreshViewDefaults(self, **kwargs):1181 """Set new default arguments for refreshView() calls1182 Parameters:1183 **kwargs (keyword arguments)1184 new default values for optional refreshView() parameters.1185 Note: default arguments are overridden by arguments given1186 directly in refreshView calls.1187 Note: setViewSource() can change the default arguments.1188 Example:1189 setRefreshViewDefaults(window="My app title",1190 viewSource="uiautomation/content")1191 """1192 self._refreshViewDefaults = kwargs1193 def findRegistry(self, rootKey, key=None, valueName=None, limit=1):1194 """Search for key and/or valueName from the registry.1195 Returns a list of matching (fullKeyPath, valueName) pairs1196 found under the rootKey. The list has at most limit items, the1197 default is 1.1198 Parameters:1199 rootKey (string):1200 root key path for the search. Example:1201 "HKEY_LOCAL_MACHINE".1202 key (string, optional):1203 key name to be searched for under the rootKey.1204 The key is a regular expression that is searched for1205 from full key path. Use "\\name$" to require exact1206 match.1207 If not given, valueName should be defined.1208 valueName (string, optional):1209 value name to be searched for under the rootKey.1210 The value can be a regular expression.1211 If not given, key should be defined and1212 returned valueName will be None.1213 limit (integer, optional):1214 maximum number of matches to be returned. The1215 default is 1. limit=None returns all matching1216 pairs.1217 Example:1218 findRegistry("HKEY_LOCAL_MACHINE", key="\\Windows$")1219 """1220 if key == None and valueName == None:1221 raise ValueError("either key or valueName must be provided")1222 return self.existingConnection().evalPython(1223 'findRegistry(%s, key=%s, valueName=%s, limit=%s)' % (1224 repr(rootKey), repr(key), repr(valueName), repr(limit)))1225 def setRegistry(self, key, valueName, value, valueType=None):1226 """1227 Set Windows registry value.1228 Parameters:1229 key (string):1230 full key name.1231 valueName (string):1232 name of the value to be set.1233 value (string):1234 string that specifies the new value.1235 valueType (string, optional for str and int values):1236 REG_BINARY, REG_DWORD, REG_DWORD_LITTLE_ENDIAN,1237 REG_DWORD_BIG_ENDIAN, REG_EXPAND_SZ, REG_LINK,1238 REG_MULTI_SZ, REG_NONE, REG_RESOURCE_LIST or REG_SZ.1239 Default types for storing str and int values1240 are REG_SZ and REG_DWORD.1241 Example:1242 setRegistry(r"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"1243 "\Control\Session Manager\Environment",1244 "PATH", r"C:\MyExecutables", "REG_EXPAND_SZ")1245 Returns True on success.1246 """1247 return self.existingConnection().evalPython(1248 "setRegistry(%s,%s,%s,%s)" % (repr(key), repr(valueName),1249 repr(value), repr(valueType)))1250 def getRegistry(self, key, valueName):1251 """1252 Return Windows registry value and type1253 Parameters:1254 key (string):1255 full key name.1256 valueName (string):1257 name of the value to be read.1258 Returns a pair (value, valueType)1259 Example:1260 getRegistry(r"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet"1261 "\Control\Session Manager\Environment", "PATH")1262 """1263 return self.existingConnection().evalPython(1264 "getRegistry(%s,%s)" % (repr(key), repr(valueName)))1265 def processList(self):1266 """1267 Return list of processes running on the device.1268 Returns list of dictionaries with keys:1269 "pid": process ID, and1270 "ProcessImageFileName": full path to the executable in win32 format.1271 """1272 return self.existingConnection().evalPython("processList()")1273 def processStatus(self, pid):1274 """1275 Return status of a process1276 Parameters:1277 pid (integer):1278 Process ID of the process1279 Returns properties in a dictionary.1280 Example:1281 print "Memory usage:", processStatus(4242)["WorkingSetSize"]1282 """1283 return self.existingConnection().evalPython(1284 "processStatus(%s)" % (repr(pid),))1285 def productList(self):1286 """1287 Return list of products installed or advertised in the system1288 Returns list of dictionaries, each containing properties of a product.1289 """1290 return self.existingConnection().evalPython("products()")1291 def pycosh(self, command):1292 """1293 Run command in pycosh shell on the device.1294 Parameters:1295 command (string):1296 pycosh command to be executed. Pycosh implements1297 stripped-down versions of zip, tar, find, md5sum, diff,1298 grep, head, tail, curl,... the usual handy shell utils.1299 For information on pycosh commands, try1300 device.pycosh("help") or run in shell:1301 echo help | python -m pycosh.1302 """1303 return self.existingConnection().pycosh(command)1304 def setScreenshotSize(self, size):1305 """1306 Force screenshots from device to use given resolution.1307 Overrides detected monitor resolution on device.1308 Parameters:1309 size (pair of integers: (width, height)):1310 width and height of screenshot.1311 """1312 self._conn.setScreenshotSize(size)1313 def setTopWindow(self, window):1314 """1315 Set a window as a foreground window and bring it to front.1316 Parameters:1317 window (title (string) or hwnd (integer):1318 title or handle of the window to be raised1319 foreground.1320 Returns True if the window was brought to the foreground,1321 otherwise False.1322 Notes: calls SetForegroundWindow in user32.dll.1323 """1324 return self.existingConnection().sendSetTopWindow(window)1325 def setViewSource(self, source, properties=None):1326 """1327 Set default view source for refreshView()1328 Parameters:1329 source (string):1330 default source, "enumchildwindow" or "uiautomation",1331 "uiautomation/raw", "uiautomation/control",1332 "uiautomation/content".1333 properties (string or list of strings, optional):1334 set list of view item properties to be read.1335 "all" reads all available properties for each item.1336 "fast" reads a set of preselected properties.1337 list of strings reads properties in the list.1338 The default is "all".1339 Returns None.1340 See also refreshView(), viewSource(), refreshViewDefaults().1341 """1342 if not source in _g_viewSources:1343 raise ValueError(1344 'invalid view source "%s", expected one of: "%s"' %1345 (source, '", "'.join(_g_viewSources)))1346 if properties != None:1347 self._refreshViewDefaults["properties"] = properties1348 self._refreshViewDefaults["viewSource"] = source1349 def shell(self, command):1350 """1351 Execute command in Windows.1352 Parameters:1353 command (string or list of strings):1354 command to be executed. Will be forwarded directly...
fmbtx11.py
Source:fmbtx11.py
...274 itemOnScreen=lambda i: self.itemOnScreen(i))275 else:276 raise ValueError('viewSource "%s" not supported' % (viewSource,))277 return self._lastView278 def refreshViewDefaults(self):279 return self._refreshViewDefaults280 def setRefreshViewDefaults(self, **kwargs):281 """Set default arguments for refreshView() calls282 Parameters:283 **kwargs (keyword arguments)284 new default values for optional refreshView() parameters.285 """286 self._refreshViewDefaults = kwargs287 def tapText(self, text, partial=False, **tapKwArgs):288 """289 Find an item with given text from the latest view, and tap it.290 Parameters:291 partial (boolean, optional):292 refer to verifyText documentation. The default is...
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!!