robotframework-platynui 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. PlatynUI/ButtonKeywords.py +9 -0
  2. PlatynUI/TextKeywords.py +7 -0
  3. PlatynUI/__about__.py +4 -0
  4. PlatynUI/__init__.py +34 -0
  5. PlatynUI/core/__init__.py +13 -0
  6. PlatynUI/core/adapter.py +152 -0
  7. PlatynUI/core/adapterfactory.py +51 -0
  8. PlatynUI/core/adapterproxy.py +168 -0
  9. PlatynUI/core/contextbase.py +586 -0
  10. PlatynUI/core/exceptions.py +77 -0
  11. PlatynUI/core/internal/__init__.py +0 -0
  12. PlatynUI/core/internal/decorator.py +148 -0
  13. PlatynUI/core/locatorbase.py +197 -0
  14. PlatynUI/core/locatorscope.py +17 -0
  15. PlatynUI/core/predicate.py +15 -0
  16. PlatynUI/core/settings.py +63 -0
  17. PlatynUI/core/strategies/__init__.py +1 -0
  18. PlatynUI/core/strategies/strategies.py +26 -0
  19. PlatynUI/core/strategybase.py +8 -0
  20. PlatynUI/core/strategyimpl.py +102 -0
  21. PlatynUI/core/technology.py +25 -0
  22. PlatynUI/core/types.py +421 -0
  23. PlatynUI/core/wait_for.py +47 -0
  24. PlatynUI/core/weight_calculator.py +110 -0
  25. PlatynUI/py.typed +0 -0
  26. PlatynUI/robot/__init__.py +0 -0
  27. PlatynUI/robot/reporting.py +74 -0
  28. PlatynUI/technology/__init__.py +0 -0
  29. PlatynUI/technology/uiautomation/.gitignore +1 -0
  30. PlatynUI/technology/uiautomation/__init__.py +4 -0
  31. PlatynUI/technology/uiautomation/core/adapterfactory.py +88 -0
  32. PlatynUI/technology/uiautomation/core/displaydevice.py +23 -0
  33. PlatynUI/technology/uiautomation/core/impls/__init__.py +2 -0
  34. PlatynUI/technology/uiautomation/core/impls/control.py +31 -0
  35. PlatynUI/technology/uiautomation/core/impls/window.py +83 -0
  36. PlatynUI/technology/uiautomation/core/keyboarddevice.py +21 -0
  37. PlatynUI/technology/uiautomation/core/loader.py +117 -0
  38. PlatynUI/technology/uiautomation/core/mousedevice.py +29 -0
  39. PlatynUI/technology/uiautomation/core/technology.py +61 -0
  40. PlatynUI/technology/uiautomation/core/uiaadapter.py +197 -0
  41. PlatynUI/technology/uiautomation/core/uiabase.py +19 -0
  42. PlatynUI/technology/uiautomation/desktop.py +11 -0
  43. PlatynUI/technology/uiautomation/locator.py +435 -0
  44. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Core.dll +0 -0
  45. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Platform.Core.dll +0 -0
  46. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Platform.dll +0 -0
  47. PlatynUI/technology/uiautomation/runtime/Microsoft.Xaml.Behaviors.dll +0 -0
  48. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.deps.json +266 -0
  49. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.dll +0 -0
  50. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.exe +0 -0
  51. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.runtimeconfig.json +19 -0
  52. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.dll +0 -0
  53. PlatynUI/technology/uiautomation/runtime/System.ComponentModel.Composition.dll +0 -0
  54. PlatynUI/technology/uiautomation/spy/__init__.py +0 -0
  55. PlatynUI/technology/uiautomation/spy/__main__.py +24 -0
  56. PlatynUI/ui/__init__.py +65 -0
  57. PlatynUI/ui/application.py +27 -0
  58. PlatynUI/ui/buttons.py +82 -0
  59. PlatynUI/ui/combobox.py +149 -0
  60. PlatynUI/ui/container.py +9 -0
  61. PlatynUI/ui/control.py +49 -0
  62. PlatynUI/ui/core/__init__.py +3 -0
  63. PlatynUI/ui/core/devices/__init__.py +6 -0
  64. PlatynUI/ui/core/devices/basedisplaydevice.py +25 -0
  65. PlatynUI/ui/core/devices/basekeyboarddevice.py +64 -0
  66. PlatynUI/ui/core/devices/basemousedevice.py +30 -0
  67. PlatynUI/ui/core/devices/basescreendevice.py +16 -0
  68. PlatynUI/ui/core/devices/displaydevice.py +113 -0
  69. PlatynUI/ui/core/devices/inputdevice.py +24 -0
  70. PlatynUI/ui/core/devices/keyboarddevice.py +279 -0
  71. PlatynUI/ui/core/devices/keyboardproxy.py +69 -0
  72. PlatynUI/ui/core/devices/mousebutton.py +11 -0
  73. PlatynUI/ui/core/devices/mousedevice.py +279 -0
  74. PlatynUI/ui/core/devices/mouseproxy.py +178 -0
  75. PlatynUI/ui/core/ui_technology.py +31 -0
  76. PlatynUI/ui/core/window_manager.py +59 -0
  77. PlatynUI/ui/desktopbase.py +56 -0
  78. PlatynUI/ui/dialog.py +10 -0
  79. PlatynUI/ui/edit.py +48 -0
  80. PlatynUI/ui/element.py +265 -0
  81. PlatynUI/ui/graphic.py +14 -0
  82. PlatynUI/ui/header.py +33 -0
  83. PlatynUI/ui/item.py +100 -0
  84. PlatynUI/ui/lists.py +37 -0
  85. PlatynUI/ui/menus.py +42 -0
  86. PlatynUI/ui/orientation.py +9 -0
  87. PlatynUI/ui/pane.py +14 -0
  88. PlatynUI/ui/proxies/__init__.py +4 -0
  89. PlatynUI/ui/proxies/standardproxies.py +391 -0
  90. PlatynUI/ui/scrollbar.py +9 -0
  91. PlatynUI/ui/strategies/__init__.py +19 -0
  92. PlatynUI/ui/strategies/activatable.py +27 -0
  93. PlatynUI/ui/strategies/application.py +28 -0
  94. PlatynUI/ui/strategies/closeable.py +22 -0
  95. PlatynUI/ui/strategies/control.py +16 -0
  96. PlatynUI/ui/strategies/editable.py +13 -0
  97. PlatynUI/ui/strategies/element.py +65 -0
  98. PlatynUI/ui/strategies/expandable.py +27 -0
  99. PlatynUI/ui/strategies/hasnativewindowhandle.py +14 -0
  100. PlatynUI/ui/strategies/hasorientation.py +15 -0
  101. PlatynUI/ui/strategies/maximizeable.py +27 -0
  102. PlatynUI/ui/strategies/minimizeable.py +27 -0
  103. PlatynUI/ui/strategies/movable.py +14 -0
  104. PlatynUI/ui/strategies/resizable.py +13 -0
  105. PlatynUI/ui/strategies/restorable.py +13 -0
  106. PlatynUI/ui/strategies/selectable.py +27 -0
  107. PlatynUI/ui/strategies/text.py +55 -0
  108. PlatynUI/ui/strategies/title.py +14 -0
  109. PlatynUI/ui/strategies/toggleable.py +23 -0
  110. PlatynUI/ui/strategies/value.py +15 -0
  111. PlatynUI/ui/table.py +56 -0
  112. PlatynUI/ui/tabs.py +28 -0
  113. PlatynUI/ui/text.py +14 -0
  114. PlatynUI/ui/togglestate.py +12 -0
  115. PlatynUI/ui/tree.py +99 -0
  116. PlatynUI/ui/unknown.py +9 -0
  117. PlatynUI/ui/window.py +177 -0
  118. robotframework_platynui-0.0.1.dist-info/METADATA +49 -0
  119. robotframework_platynui-0.0.1.dist-info/RECORD +122 -0
  120. robotframework_platynui-0.0.1.dist-info/WHEEL +4 -0
  121. robotframework_platynui-0.0.1.dist-info/entry_points.txt +2 -0
  122. robotframework_platynui-0.0.1.dist-info/licenses/LICENSE.txt +73 -0
@@ -0,0 +1,435 @@
1
+ import collections
2
+ import enum
3
+ import numbers
4
+ import xml.sax.saxutils as xmlutils
5
+ from typing import Any, Dict, List, Optional, Type, cast
6
+
7
+ from typing_extensions import Self
8
+
9
+ from PlatynUI import ui
10
+ from PlatynUI.core import Adapter, ContextBase, LocatorBase, LocatorScope, TContextBase, Technology
11
+
12
+ from .core.technology import get_technology
13
+
14
+ __all__ = ["Locator", "locator", "LocatorScope"]
15
+
16
+
17
+ # noinspection PyPep8Naming
18
+ class Locator(LocatorBase):
19
+ node: Optional[str] = None
20
+ prefix: Optional[str] = None
21
+ use_default_prefix: bool = False
22
+ axis: Optional[str] = None
23
+ path: Optional[str] = None
24
+ __id: Optional[str] = None
25
+ __name: Optional[str] = None
26
+ __class_name: Optional[str] = None
27
+ __role: Optional[str] = None
28
+ __runtime_id: Optional[str] = None
29
+ __framework_id: Optional[str] = None
30
+ index: Optional[int] = None
31
+ scope: Optional[LocatorScope] = None
32
+ position: Optional[int] = None
33
+
34
+ __xpath_axis = {
35
+ LocatorScope.Root: "/",
36
+ LocatorScope.Descendants: ".//",
37
+ LocatorScope.Children: "",
38
+ LocatorScope.Parent: "parent::",
39
+ LocatorScope.Ancestor: "ancestor::",
40
+ LocatorScope.AncestorOrSelf: "ancestor-or-self::",
41
+ LocatorScope.DescendantsOrSelf: "descendant-or-self::",
42
+ LocatorScope.Following: "following::",
43
+ LocatorScope.FollowingSibling: "following-sibling::",
44
+ LocatorScope.Preceding: "preceding::",
45
+ LocatorScope.PrecedingSibling: "preceding-sibling::",
46
+ }
47
+
48
+ # noinspection PyShadowingBuiltins
49
+ def __init__(
50
+ self,
51
+ *args: Any,
52
+ path: Optional[str] = None,
53
+ id: Optional[str] = None,
54
+ name: Optional[str] = None,
55
+ class_name: Optional[str] = None,
56
+ role: Optional[str] = None,
57
+ prefix: Optional[str] = None,
58
+ use_default_prefix: Optional[bool] = None,
59
+ runtime_id: Optional[str] = None,
60
+ framework_id: Optional[str] = None,
61
+ index: Optional[int] = None,
62
+ node: Optional[str] = None,
63
+ scope: Optional[LocatorScope] = None,
64
+ axis: Optional[str] = None,
65
+ position: Optional[int] = None,
66
+ **kwargs: Any,
67
+ ) -> None:
68
+
69
+ super().__init__()
70
+
71
+ self.custom_attributes: List[Any] = list(args)
72
+ self.attributes: Dict[str, Any] = dict(kwargs)
73
+
74
+ self.path = path
75
+ self.node = node
76
+ self.prefix = prefix
77
+
78
+ self.axis = axis
79
+
80
+ if id is not None:
81
+ self.id = id
82
+
83
+ if name is not None:
84
+ self.name = name
85
+
86
+ if class_name is not None:
87
+ self.class_name = class_name
88
+
89
+ if role is not None:
90
+ self.role = role
91
+
92
+ if runtime_id is not None:
93
+ self.runtime_id = runtime_id
94
+
95
+ if framework_id is not None:
96
+ self.framework_id = framework_id
97
+
98
+ if use_default_prefix is not None:
99
+ self.use_default_prefix = use_default_prefix
100
+
101
+ self.index = index
102
+ self.position = position
103
+ self.scope = scope
104
+
105
+ @property
106
+ def id(self) -> Optional[str]:
107
+ return self.__id
108
+
109
+ @id.setter
110
+ def id(self, v: Optional[str]) -> None:
111
+ self.__id = v
112
+ if v is None:
113
+ self.attributes.pop("Id", None)
114
+ else:
115
+ self.attributes["Id"] = self.__id
116
+
117
+ @property
118
+ def name(self) -> Optional[str]:
119
+ return self.__name
120
+
121
+ @name.setter
122
+ def name(self, v: Optional[str]) -> None:
123
+ self.__name = v
124
+ if v is None:
125
+ self.attributes.pop("Name", None)
126
+ else:
127
+ self.attributes["Name"] = self.__name
128
+
129
+ @property
130
+ def class_name(self) -> Optional[str]:
131
+ return self.__class_name
132
+
133
+ @class_name.setter
134
+ def class_name(self, v: Optional[str]) -> None:
135
+ self.__class_name = v
136
+ if v is None:
137
+ self.attributes.pop("ClassName", None)
138
+ else:
139
+ self.attributes["ClassName"] = self.__class_name
140
+
141
+ @property
142
+ def role(self) -> Optional[str]:
143
+ return self.__role
144
+
145
+ @role.setter
146
+ def role(self, v: Optional[str]) -> None:
147
+ self.__role = v
148
+
149
+ @property
150
+ def framework_id(self) -> Optional[str]:
151
+ return self.__framework_id
152
+
153
+ @framework_id.setter
154
+ def framework_id(self, v: Optional[str]) -> None:
155
+ self.__framework_id = v
156
+ if v is None:
157
+ self.attributes.pop("FrameworkId", None)
158
+ else:
159
+ self.attributes["FrameworkId"] = self.__framework_id
160
+
161
+ @property
162
+ def runtime_id(self) -> Optional[str]:
163
+ return self.__runtime_id
164
+
165
+ @runtime_id.setter
166
+ def runtime_id(self, v: Optional[str]) -> None:
167
+ self.__runtime_id = v
168
+ if v is None:
169
+ self.attributes.pop("RuntimeId", None)
170
+ else:
171
+ self.attributes["RuntimeId"] = self.__runtime_id
172
+
173
+ def _create_technology(self) -> Technology:
174
+ return get_technology()
175
+
176
+ def create_context(
177
+ self, context_parent: Optional[ContextBase], context_type: Optional[Type[TContextBase]]
178
+ ) -> TContextBase:
179
+
180
+ if isinstance(context_parent, ui.DesktopBase):
181
+ context_parent = None
182
+
183
+ if context_type is None:
184
+ context_type = cast(Type[TContextBase], ui.Element)
185
+
186
+ return super().create_context(context_parent=context_parent, context_type=context_type)
187
+
188
+ def __repr__(self) -> str:
189
+ if self.__last_path is not None:
190
+ params = "path=%s" % repr(self.__last_path)
191
+ else:
192
+ params = ""
193
+
194
+ if self.path is not None:
195
+ if params != "":
196
+ params += ", "
197
+ params += "path=%s" % repr(self.path)
198
+
199
+ if self.axis is not None:
200
+ if params != "":
201
+ params += ", "
202
+ params += "axis=%s" % repr(self.axis)
203
+
204
+ if self.node is not None:
205
+ if params != "":
206
+ params += ", "
207
+ params += "node=%s" % repr(self.node)
208
+
209
+ if self.prefix is not None:
210
+ if params != "":
211
+ params += ", "
212
+ params += "prefix=%s" % repr(self.prefix)
213
+
214
+ for v in self.custom_attributes:
215
+ if v is not None:
216
+ if params != "":
217
+ params += ", "
218
+ params += '"%s"' % str(v)
219
+
220
+ for n, v in self.attributes.items():
221
+ if v is not None:
222
+ if params != "":
223
+ params += ", "
224
+ params += "%s=%s" % (n, repr(v))
225
+
226
+ if self.scope is not None:
227
+ if params != "":
228
+ params += ", "
229
+ params += "scope=%s" % repr(self.scope)
230
+
231
+ if self.position is not None:
232
+ if params != "":
233
+ params += ", "
234
+ params += "position=%s" % repr(self.position)
235
+
236
+ return "locator(%s)" % params
237
+
238
+ __last_path: Optional[str] = None
239
+
240
+ __last_parent: Optional[ContextBase] = None
241
+ __last_context_type: Optional[Type[Any]] = None
242
+ __last_attributes: Optional[Dict[str, Any]] = None
243
+ __last_custom_attributes: Optional[List[Any]] = None
244
+
245
+ def get_path(self, parent: Optional[ContextBase], context_type: Optional[Type[TContextBase]]) -> str:
246
+
247
+ combined = (
248
+ self.copy_from(getattr(context_type, "_locator"))
249
+ if context_type is not None and hasattr(context_type, "_locator")
250
+ else self
251
+ )
252
+
253
+ if (
254
+ combined.__last_path is not None
255
+ and combined.__last_parent == parent
256
+ and combined.__last_context_type == context_type
257
+ and combined.attributes == combined.__last_attributes
258
+ and combined.__last_custom_attributes == combined.custom_attributes
259
+ ):
260
+ return combined.__last_path
261
+
262
+ combined.__last_parent = parent
263
+ combined.__last_context_type = context_type
264
+ combined.__last_attributes = combined.attributes.copy()
265
+ combined.__last_custom_attributes = combined.custom_attributes.copy()
266
+
267
+ result = ""
268
+
269
+ real_path = combined.path if combined.path is not None else None
270
+
271
+ if real_path is not None:
272
+ result = real_path
273
+ else:
274
+ attrs = ""
275
+
276
+ for n, v in combined.attributes.items():
277
+ if v is not None:
278
+ if attrs != "":
279
+ attrs += " and "
280
+ attrs += "@%s=%s" % (n, combined.xquery_repr(v))
281
+
282
+ for v in combined.custom_attributes:
283
+ if v is not None:
284
+ if attrs != "":
285
+ attrs += " and "
286
+ attrs += str(v)
287
+
288
+ if combined.position is not None:
289
+ if attrs != "":
290
+ attrs += " and "
291
+ attrs += "position()=%s" % combined.position
292
+
293
+ role = self.role or getattr(context_type, "default_role", None)
294
+ if combined.node is not None:
295
+ result = combined.node + result
296
+ elif role:
297
+ result = role + result
298
+ else:
299
+ result = "*" + result
300
+
301
+ prefix = self.prefix or getattr(context_type, "default_prefix", None)
302
+
303
+ if combined.prefix is not None:
304
+ result = combined.prefix + ":" + result
305
+ elif self.use_default_prefix and prefix:
306
+ result = prefix + ":" + result
307
+
308
+ if combined.axis is not None:
309
+ result = combined.axis + result
310
+ else:
311
+ real_scope = combined.scope
312
+ if real_scope is None:
313
+ if parent is None:
314
+ real_scope = LocatorScope.Children
315
+ else:
316
+ real_scope = (
317
+ LocatorScope.Children
318
+ if isinstance(parent, (ui.Application, ui.DesktopBase))
319
+ else LocatorScope.Descendants
320
+ )
321
+
322
+ result = combined.__xpath_axis[real_scope] + result
323
+
324
+ if attrs != "":
325
+ attrs = "[%s]" % attrs
326
+ if combined.index is not None:
327
+ attrs += "[%s]" % combined.index
328
+
329
+ result += attrs
330
+
331
+ self.__last_path = result
332
+
333
+ return result
334
+
335
+ def copy_from(self, other: Optional[LocatorBase]) -> Self:
336
+ if other is None:
337
+ return self
338
+
339
+ if isinstance(other, type(self)):
340
+ for n in [
341
+ "path",
342
+ "id",
343
+ "name",
344
+ "class_name",
345
+ "role",
346
+ "prefix",
347
+ "framework_id",
348
+ "index",
349
+ "node",
350
+ "axis",
351
+ "scope",
352
+ "runtime_id",
353
+ "position",
354
+ "use_default_prefix"
355
+ ]:
356
+
357
+ v = getattr(self, n)
358
+ if v is None:
359
+ setattr(self, n, getattr(other, n))
360
+
361
+ o = cast(Locator, other)
362
+
363
+ if o._technology is not None:
364
+ self._technology = o._technology
365
+
366
+ for a in o.custom_attributes:
367
+ if a not in self.custom_attributes:
368
+ self.custom_attributes.append(a)
369
+
370
+ for a in o.attributes:
371
+ if a not in self.attributes:
372
+ self.attributes[a] = o.attributes[a]
373
+
374
+ return self
375
+
376
+ def copy(self) -> "Locator":
377
+ # return copy.deepcopy(self)
378
+ result = Locator()
379
+
380
+ result._technology = self._technology
381
+
382
+ result.node = self.node
383
+ result.prefix = self.prefix
384
+ result.axis = self.axis
385
+ result.path = self.path
386
+ result.name = self.name
387
+ result.id = self.id
388
+ result.class_name = self.class_name
389
+ result.role = self.role
390
+ result.framework_id = self.framework_id
391
+ result.index = self.index
392
+ result.scope = self.scope
393
+ result.position = self.position
394
+ result.runtime_id = self.runtime_id
395
+ result.attributes = self.attributes.copy()
396
+ result.custom_attributes = self.custom_attributes.copy()
397
+ result.use_default_prefix = self.use_default_prefix
398
+
399
+ return result
400
+
401
+ def create_children_locator(self, *args: Any, **kwargs: Any) -> LocatorBase:
402
+ return Locator(*args, **kwargs)
403
+
404
+ def make_unique_locator(self, adapter: Adapter) -> LocatorBase:
405
+ result = self.copy()
406
+ result.runtime_id = adapter.runtime_id
407
+ return result
408
+
409
+ def create_child_locator(self, adapter: Adapter) -> LocatorBase:
410
+ return Locator(scope=LocatorScope.Descendants, runtime_id=adapter.runtime_id)
411
+
412
+ def create_parent_locator(self, adapter: Adapter) -> LocatorBase:
413
+ return Locator(path="..")
414
+
415
+ def create_top_level_locator(self, adapter: "Adapter") -> Optional["LocatorBase"]:
416
+ return Locator(runtime_id=adapter.runtime_id, scope=LocatorScope.Root)
417
+
418
+ @staticmethod
419
+ def xquery_repr(v: Any) -> str:
420
+ if isinstance(v, enum.Enum):
421
+ return '"' + repr(v.value) + '"'
422
+ if isinstance(v, bool):
423
+ return repr(v).lower() + "()"
424
+ if isinstance(v, str):
425
+ return xmlutils.quoteattr(v)
426
+ if isinstance(v, numbers.Number):
427
+ return repr(v)
428
+ if isinstance(v, dict):
429
+ return "(" + ", ".join([Locator.xquery_repr(c) for c in v.items()]) + ")"
430
+ if isinstance(v, collections.Iterable):
431
+ return "(" + ", ".join([Locator.xquery_repr(c) for c in v]) + ")"
432
+ return xmlutils.quoteattr(repr(v))
433
+
434
+
435
+ locator = Locator