appium-novawindows2-driver 0.2.4 → 0.2.5

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.
@@ -13,42 +13,42 @@ const powershell_1 = require("../powershell");
13
13
  const util_1 = require("../util");
14
14
  const base_driver_1 = require("@appium/base-driver");
15
15
  const user32_1 = require("../winapi/user32");
16
- const GET_PAGE_SOURCE_COMMAND = (0, powershell_1.pwsh$ /* ps1 */) `
17
- $el = ${0}
18
-
19
- if ($el -eq $null) {
20
- $el = [AutomationElement]::RootElement
21
- }
22
-
23
- $source = Get-PageSource $el
24
- if ($null -ne $source) {
25
- $source.OuterXml
26
- } else {
27
- # Final fallback if even Get-PageSource fails for some reason
28
- "<DummyRoot />"
29
- }
16
+ const GET_PAGE_SOURCE_COMMAND = (0, powershell_1.pwsh$ /* ps1 */) `
17
+ $el = ${0}
18
+
19
+ if ($el -eq $null) {
20
+ $el = [AutomationElement]::RootElement
21
+ }
22
+
23
+ $source = Get-PageSource $el
24
+ if ($null -ne $source) {
25
+ $source.OuterXml
26
+ } else {
27
+ # Final fallback if even Get-PageSource fails for some reason
28
+ "<DummyRoot />"
29
+ }
30
30
  `;
31
- const GET_SCREENSHOT_COMMAND = (0, powershell_1.pwsh /* ps1 */) `
32
- if ($rootElement -eq $null) {
33
- $bitmap = New-Object Drawing.Bitmap 1,1
34
- $stream = New-Object IO.MemoryStream
35
- $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
36
- $bitmap.Dispose()
37
- return [Convert]::ToBase64String($stream.ToArray())
38
- }
39
-
40
- $rect = $rootElement.Current.BoundingRectangle
41
- $bitmap = New-Object Drawing.Bitmap([int32]$rect.Width, [int32]$rect.Height)
42
-
43
- $graphics = [Drawing.Graphics]::FromImage($bitmap)
44
- $graphics.CopyFromScreen([int32]$rect.Left, [int32]$rect.Top, 0, 0, $bitmap.Size)
45
- $graphics.Dispose()
46
-
47
- $stream = New-Object IO.MemoryStream
48
- $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
49
- $bitmap.Dispose()
50
-
51
- [Convert]::ToBase64String($stream.ToArray())
31
+ const GET_SCREENSHOT_COMMAND = (0, powershell_1.pwsh /* ps1 */) `
32
+ if ($rootElement -eq $null) {
33
+ $bitmap = New-Object Drawing.Bitmap 1,1
34
+ $stream = New-Object IO.MemoryStream
35
+ $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
36
+ $bitmap.Dispose()
37
+ return [Convert]::ToBase64String($stream.ToArray())
38
+ }
39
+
40
+ $rect = $rootElement.Current.BoundingRectangle
41
+ $bitmap = New-Object Drawing.Bitmap([int32]$rect.Width, [int32]$rect.Height)
42
+
43
+ $graphics = [Drawing.Graphics]::FromImage($bitmap)
44
+ $graphics.CopyFromScreen([int32]$rect.Left, [int32]$rect.Top, 0, 0, $bitmap.Size)
45
+ $graphics.Dispose()
46
+
47
+ $stream = New-Object IO.MemoryStream
48
+ $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
49
+ $bitmap.Dispose()
50
+
51
+ [Convert]::ToBase64String($stream.ToArray())
52
52
  `;
53
53
  async function getPageSource() {
54
54
  return await this.sendPowerShellCommand(GET_PAGE_SOURCE_COMMAND.format(powershell_1.AutomationElement.automationRoot));
@@ -78,20 +78,20 @@ const AUTOMATION_ELEMENT_MODE = (0, util_1.$ /* ps1 */) `$cacheRequest.Pop(); $c
78
78
  const SET_PLAINTEXT_CLIPBOARD_FROM_BASE64 = (0, util_1.$ /* ps1 */) `$bytes = [Convert]::FromBase64String('${0}'); $str = [System.Text.Encoding]::UTF8.GetString($bytes); Set-Clipboard -Value $str`;
79
79
  const GET_PLAINTEXT_CLIPBOARD_BASE64 = /* ps1 */ `$str = Get-Clipboard | Out-String; if ($null -eq $str) { $str = '' }; [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($str))`;
80
80
  const SET_IMAGE_CLIPBOARD_FROM_BASE64 = (0, util_1.$ /* ps1 */) `$b = [Convert]::FromBase64String('${0}'); $s = New-Object IO.MemoryStream; $s.Write($b, 0, $b.Length); $s.Position = 0; $i = [System.Windows.Media.Imaging.BitmapFrame]::Create($s); [Windows.Clipboard]::SetImage($i); $s.Close()`;
81
- const GET_IMAGE_CLIPBOARD_BASE64 = (0, powershell_1.pwsh /* ps1 */) `
82
- [Windows.Clipboard]::GetImage() | ForEach-Object {
83
- if ($_ -ne $null) {
84
- $stream = New-Object IO.MemoryStream
85
- $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
86
- $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($_))
87
- $encoder.Save($stream)
88
- $stream.Position = 0
89
- $bytes = $stream.ToArray()
90
- $base64String = [Convert]::ToBase64String($bytes)
91
- $stream.Close()
92
- Write-Output $base64String
93
- }
94
- }
81
+ const GET_IMAGE_CLIPBOARD_BASE64 = (0, powershell_1.pwsh /* ps1 */) `
82
+ [Windows.Clipboard]::GetImage() | ForEach-Object {
83
+ if ($_ -ne $null) {
84
+ $stream = New-Object IO.MemoryStream
85
+ $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
86
+ $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($_))
87
+ $encoder.Save($stream)
88
+ $stream.Position = 0
89
+ $bytes = $stream.ToArray()
90
+ $base64String = [Convert]::ToBase64String($bytes)
91
+ $stream.Close()
92
+ Write-Output $base64String
93
+ }
94
+ }
95
95
  `;
96
96
  async function execute(script, args) {
97
97
  if (script.startsWith(PLATFORM_COMMAND_PREFIX)) {
@@ -181,18 +181,18 @@ async function patternScrollIntoView(element) {
181
181
  try {
182
182
  // Manual repair using FindFirst with strict PS types to avoid marshalling issues
183
183
  const idParts = elementId.split('.').join(',');
184
- const repairScript = `
185
- $targetIdArray = [int32[]]@(${idParts});
186
- $cond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::RuntimeIdProperty, $targetIdArray);
187
- $found = [System.Windows.Automation.AutomationElement]::RootElement.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond);
188
-
189
- if ($null -ne $found) {
190
- $runtimeId = $found.GetRuntimeId() -join '.';
191
- if (-not $elementTable.ContainsKey($runtimeId)) {
192
- $elementTable.Add($runtimeId, $found)
193
- };
194
- $runtimeId
195
- }
184
+ const repairScript = `
185
+ $targetIdArray = [int32[]]@(${idParts});
186
+ $cond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::RuntimeIdProperty, $targetIdArray);
187
+ $found = [System.Windows.Automation.AutomationElement]::RootElement.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond);
188
+
189
+ if ($null -ne $found) {
190
+ $runtimeId = $found.GetRuntimeId() -join '.';
191
+ if (-not $elementTable.ContainsKey($runtimeId)) {
192
+ $elementTable.Add($runtimeId, $found)
193
+ };
194
+ $runtimeId
195
+ }
196
196
  `;
197
197
  const repairedId = await this.sendPowerShellCommand(repairScript);
198
198
  if (repairedId && repairedId.trim() === elementId) {
@@ -7,13 +7,13 @@ async function pushFile(remotePath, base64Data) {
7
7
  this.log.debug(`Pushing file to: ${remotePath}`);
8
8
  // Escape single quotes in remotePath for PowerShell
9
9
  const escapedPath = remotePath.replace(/'/g, "''");
10
- const command = `
11
- $targetPath = '${escapedPath}';
12
- $base64String = '${base64Data}';
13
- $parentDir = Split-Path -Path $targetPath -Parent;
14
- if (-not (Test-Path -Path $parentDir)) { New-Item -ItemType Directory -Force -Path $parentDir | Out-Null };
15
- $bytes = [Convert]::FromBase64String($base64String);
16
- [System.IO.File]::WriteAllBytes($targetPath, $bytes);
10
+ const command = `
11
+ $targetPath = '${escapedPath}';
12
+ $base64String = '${base64Data}';
13
+ $parentDir = Split-Path -Path $targetPath -Parent;
14
+ if (-not (Test-Path -Path $parentDir)) { New-Item -ItemType Directory -Force -Path $parentDir | Out-Null };
15
+ $bytes = [Convert]::FromBase64String($base64String);
16
+ [System.IO.File]::WriteAllBytes($targetPath, $bytes);
17
17
  `;
18
18
  // Send the command to PowerShell
19
19
  // We use sendPowerShellCommand to ensure it goes through the queue/lock mechanism
@@ -22,27 +22,27 @@ $bytes = [Convert]::FromBase64String($base64String);
22
22
  async function pullFile(remotePath) {
23
23
  this.log.debug(`Pulling file from: ${remotePath}`);
24
24
  const escapedPath = remotePath.replace(/'/g, "''");
25
- const command = `
26
- $targetPath = '${escapedPath}';
27
- if (-not (Test-Path -Path $targetPath -PathType Leaf)) { throw "File not found: $targetPath" };
28
- $bytes = [System.IO.File]::ReadAllBytes($targetPath);
29
- [Convert]::ToBase64String($bytes);
25
+ const command = `
26
+ $targetPath = '${escapedPath}';
27
+ if (-not (Test-Path -Path $targetPath -PathType Leaf)) { throw "File not found: $targetPath" };
28
+ $bytes = [System.IO.File]::ReadAllBytes($targetPath);
29
+ [Convert]::ToBase64String($bytes);
30
30
  `;
31
31
  return await this.sendPowerShellCommand(command);
32
32
  }
33
33
  async function pullFolder(remotePath) {
34
34
  this.log.debug(`Pulling folder from: ${remotePath}`);
35
35
  const escapedPath = remotePath.replace(/'/g, "''");
36
- const command = `
37
- $targetPath = '${escapedPath}';
38
- $tempGuid = [Guid]::NewGuid().ToString();
39
- $zipPath = Join-Path $env:TEMP "appium_$tempGuid.zip";
40
- if (-not (Test-Path -Path $targetPath -PathType Container)) { throw "Folder not found: $targetPath" };
41
- Compress-Archive -Path $targetPath -DestinationPath $zipPath -Force;
42
- $bytes = [System.IO.File]::ReadAllBytes($zipPath);
43
- $base64 = [Convert]::ToBase64String($bytes);
44
- Remove-Item -Path $zipPath -Force;
45
- $base64;
36
+ const command = `
37
+ $targetPath = '${escapedPath}';
38
+ $tempGuid = [Guid]::NewGuid().ToString();
39
+ $zipPath = Join-Path $env:TEMP "appium_$tempGuid.zip";
40
+ if (-not (Test-Path -Path $targetPath -PathType Container)) { throw "Folder not found: $targetPath" };
41
+ Compress-Archive -Path $targetPath -DestinationPath $zipPath -Force;
42
+ $bytes = [System.IO.File]::ReadAllBytes($zipPath);
43
+ $base64 = [Convert]::ToBase64String($bytes);
44
+ Remove-Item -Path $zipPath -Force;
45
+ $base64;
46
46
  `;
47
47
  return await this.sendPowerShellCommand(command);
48
48
  }
@@ -2,195 +2,195 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PAGE_SOURCE = exports.FIND_CHILDREN_RECURSIVELY = void 0;
4
4
  const powershell_1 = require("../powershell");
5
- exports.FIND_CHILDREN_RECURSIVELY = (0, powershell_1.pwsh /* ps1 */) `
6
- function Find-ChildrenRecursively {
7
- param (
8
- [Parameter(Mandatory=$true)]
9
- [AutomationElement]$element,
10
- [Parameter(Mandatory=$true)]
11
- [Condition]$condition,
12
- [Parameter(Mandatory=$false)]
13
- [bool]$includeSelf = $false
14
- )
15
-
16
- $scope = if ($includeSelf) {
17
- [TreeScope]::Element -bor [TreeScope]::Children
18
- } else {
19
- [TreeScope]::Children
20
- }
21
-
22
- $validChild = $element.FindFirst($scope, $condition)
23
-
24
- if ($validChild -ne $null) {
25
- return $validChild
26
- }
27
-
28
- $children = $element.FindAll([TreeScope]::Children, [Condition]::TrueCondition)
29
- foreach ($child in $children) {
30
- $result = Find-AllChildrenRecursively -element $child -condition $condition -returnFirstResult $true
31
- if ($result -ne $null) {
32
- return $result[0]
33
- }
34
- }
35
-
36
- return $null
37
- }
38
-
39
- function Find-AllChildrenRecursively {
40
- param (
41
- [Parameter(Mandatory=$true)]
42
- [AutomationElement]$element,
43
- [Parameter(Mandatory=$true)]
44
- [Condition]$condition,
45
- [bool]$returnFirstResult = $false,
46
- [Parameter(Mandatory=$false)]
47
- [bool]$includeSelf = $false
48
- )
49
-
50
- $children = $element.FindAll([TreeScope]::Children, [Condition]::TrueCondition)
51
- $validChildren = @($children | Where-Object { $_.FindFirst([TreeScope]::Element, $condition) -ne $null })
52
-
53
- if ($includeSelf) {
54
- $self = $element.FindFirst([TreeScope]::Element, $condition)
55
- }
56
-
57
- if ($null -ne $self) {
58
- $validChildren += $self
59
- }
60
-
61
- foreach ($child in $children) {
62
- $Allresults = Find-AllChildrenRecursively -element $child -condition $condition
63
- if ($returnFirstResult -and $Allresults.Count -gt 0) {
64
- return $Allresults
65
- }
66
-
67
- foreach ($result in $Allresults) {
68
- $validChildren += ($result | Where-Object { $_.FindFirst([TreeScope]::Element, $condition) -ne $null })
69
- }
70
- }
71
-
72
- return $validChildren
73
- }
5
+ exports.FIND_CHILDREN_RECURSIVELY = (0, powershell_1.pwsh /* ps1 */) `
6
+ function Find-ChildrenRecursively {
7
+ param (
8
+ [Parameter(Mandatory=$true)]
9
+ [AutomationElement]$element,
10
+ [Parameter(Mandatory=$true)]
11
+ [Condition]$condition,
12
+ [Parameter(Mandatory=$false)]
13
+ [bool]$includeSelf = $false
14
+ )
15
+
16
+ $scope = if ($includeSelf) {
17
+ [TreeScope]::Element -bor [TreeScope]::Children
18
+ } else {
19
+ [TreeScope]::Children
20
+ }
21
+
22
+ $validChild = $element.FindFirst($scope, $condition)
23
+
24
+ if ($validChild -ne $null) {
25
+ return $validChild
26
+ }
27
+
28
+ $children = $element.FindAll([TreeScope]::Children, [Condition]::TrueCondition)
29
+ foreach ($child in $children) {
30
+ $result = Find-AllChildrenRecursively -element $child -condition $condition -returnFirstResult $true
31
+ if ($result -ne $null) {
32
+ return $result[0]
33
+ }
34
+ }
35
+
36
+ return $null
37
+ }
38
+
39
+ function Find-AllChildrenRecursively {
40
+ param (
41
+ [Parameter(Mandatory=$true)]
42
+ [AutomationElement]$element,
43
+ [Parameter(Mandatory=$true)]
44
+ [Condition]$condition,
45
+ [bool]$returnFirstResult = $false,
46
+ [Parameter(Mandatory=$false)]
47
+ [bool]$includeSelf = $false
48
+ )
49
+
50
+ $children = $element.FindAll([TreeScope]::Children, [Condition]::TrueCondition)
51
+ $validChildren = @($children | Where-Object { $_.FindFirst([TreeScope]::Element, $condition) -ne $null })
52
+
53
+ if ($includeSelf) {
54
+ $self = $element.FindFirst([TreeScope]::Element, $condition)
55
+ }
56
+
57
+ if ($null -ne $self) {
58
+ $validChildren += $self
59
+ }
60
+
61
+ foreach ($child in $children) {
62
+ $Allresults = Find-AllChildrenRecursively -element $child -condition $condition
63
+ if ($returnFirstResult -and $Allresults.Count -gt 0) {
64
+ return $Allresults
65
+ }
66
+
67
+ foreach ($result in $Allresults) {
68
+ $validChildren += ($result | Where-Object { $_.FindFirst([TreeScope]::Element, $condition) -ne $null })
69
+ }
70
+ }
71
+
72
+ return $validChildren
73
+ }
74
74
  `;
75
- exports.PAGE_SOURCE = (0, powershell_1.pwsh /* ps1 */) `
76
- function Get-PageSource {
77
- param (
78
- [Parameter(Mandatory = $true)]
79
- [AutomationElement]$element,
80
- [Xml.XmlDocument]$xmlDoc,
81
- [Xml.XmlElement]$xmlElement
82
- )
83
-
84
- try {
85
- $localizedControlType = $element.GetCurrentPropertyValue([AutomationElement]::LocalizedControlTypeProperty)
86
- $controlType = $element.GetCurrentPropertyValue([AutomationElement]::ControlTypeProperty)
87
-
88
- $tagName = ''
89
- try {
90
- $tagName = $controlType.ProgrammaticName.Split('.')[-1]
91
- if ($tagName -eq 'DataGrid') { $tagName = 'List' }
92
- elseif ($tagName -eq 'DataItem') { $tagName = 'ListItem' }
93
- } catch {
94
- # fallback to LocalizedControlType ControlType is empty
95
- $tagName = -join ($localizedControlType -split ' ' | ForEach-Object {
96
- $_.Substring(0, 1).ToUpper() + $_.Substring(1).ToLower()
97
- })
98
- }
99
-
100
- $acceleratorKey = $element.GetCurrentPropertyValue([AutomationElement]::AcceleratorKeyProperty)
101
- $accessKey = $element.GetCurrentPropertyValue([AutomationElement]::AccessKeyProperty)
102
- $automationId = $element.GetCurrentPropertyValue([AutomationElement]::AutomationIdProperty)
103
- $className = $element.GetCurrentPropertyValue([AutomationElement]::ClassNameProperty)
104
- $frameworkId = $element.GetCurrentPropertyValue([AutomationElement]::FrameworkIdProperty)
105
- $hasKeyboardfocus = $element.GetCurrentPropertyValue([AutomationElement]::HasKeyboardfocusProperty)
106
- $helpText = $element.GetCurrentPropertyValue([AutomationElement]::HelpTextProperty)
107
- $isContentelement = $element.GetCurrentPropertyValue([AutomationElement]::IsContentelementProperty)
108
- $isControlelement = $element.GetCurrentPropertyValue([AutomationElement]::IsControlelementProperty)
109
- $isEnabled = $element.GetCurrentPropertyValue([AutomationElement]::IsEnabledProperty)
110
- $isKeyboardfocusable = $element.GetCurrentPropertyValue([AutomationElement]::IsKeyboardfocusableProperty)
111
- $isOffscreen = $element.GetCurrentPropertyValue([AutomationElement]::IsOffscreenProperty)
112
- $isPassword = $element.GetCurrentPropertyValue([AutomationElement]::IsPasswordProperty)
113
- $isRequiredforform = $element.GetCurrentPropertyValue([AutomationElement]::IsRequiredforformProperty)
114
- $itemStatus = $element.GetCurrentPropertyValue([AutomationElement]::ItemStatusProperty)
115
- $itemType = $element.GetCurrentPropertyValue([AutomationElement]::ItemTypeProperty)
116
- $name = $element.GetCurrentPropertyValue([AutomationElement]::NameProperty)
117
- $orientation = $element.GetCurrentPropertyValue([AutomationElement]::OrientationProperty)
118
- $processId = $element.GetCurrentPropertyValue([AutomationElement]::ProcessIdProperty)
119
- $runtimeId = $element.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.'
120
- $boundingRectangle = $element.Current.BoundingRectangle
121
- $x = $boundingRectangle.X - $rootElement.Current.BoundingRectangle.X
122
- $y = $boundingRectangle.Y - $rootElement.Current.BoundingRectangle.Y
123
- $width = $boundingRectangle.Width
124
- $height = $boundingRectangle.Height
125
-
126
- if ($null -eq $xmlDoc) { $xmlDoc = [Xml.XmlDocument]::new() }
127
-
128
- $newXmlElement = $xmlDoc.CreateElement($tagName)
129
- $newXmlElement.SetAttribute("AcceleratorKey", $acceleratorKey)
130
- $newXmlElement.SetAttribute("AccessKey", $accessKey)
131
- $newXmlElement.SetAttribute("AutomationId", $automationId)
132
- $newXmlElement.SetAttribute("ClassName", $className)
133
- $newXmlElement.SetAttribute("FrameworkId", $frameworkId)
134
- $newXmlElement.SetAttribute("HasKeyboardfocus", $hasKeyboardfocus)
135
- $newXmlElement.SetAttribute("HelpText", $helpText)
136
- $newXmlElement.SetAttribute("IsContentelement", $isContentelement)
137
- $newXmlElement.SetAttribute("IsControlelement", $isControlelement)
138
- $newXmlElement.SetAttribute("IsEnabled", $isEnabled)
139
- $newXmlElement.SetAttribute("IsKeyboardfocusable", $isKeyboardfocusable)
140
- $newXmlElement.SetAttribute("IsOffscreen", $isOffscreen)
141
- $newXmlElement.SetAttribute("IsPassword", $isPassword)
142
- $newXmlElement.SetAttribute("IsRequiredforform", $isRequiredforform)
143
- $newXmlElement.SetAttribute("ItemStatus", $itemStatus)
144
- $newXmlElement.SetAttribute("ItemType", $itemType)
145
- $newXmlElement.SetAttribute("LocalizedControlType", $localizedControlType)
146
- $newXmlElement.SetAttribute("Name", $name)
147
- $newXmlElement.SetAttribute("Orientation", $orientation)
148
- $newXmlElement.SetAttribute("ProcessId", $processId)
149
- $newXmlElement.SetAttribute("RuntimeId", $runtimeId)
150
- $newXmlElement.SetAttribute("x", $x)
151
- $newXmlElement.SetAttribute("y", $y)
152
- $newXmlElement.SetAttribute("width", $width)
153
- $newXmlElement.SetAttribute("height", $height)
154
-
155
- $pattern = $null
156
-
157
- if ($element.TryGetCurrentPattern([WindowPattern]::Pattern, [ref]$pattern)) {
158
- $newXmlElement.SetAttribute("CanMaximize", $pattern.Current.CanMaximize)
159
- $newXmlElement.SetAttribute("CanMinimize", $pattern.Current.CanMinimize)
160
- $newXmlElement.SetAttribute("IsModal", $pattern.Current.IsModal)
161
- $newXmlElement.SetAttribute("WindowVisualState", $pattern.Current.WindowVisualState)
162
- $newXmlElement.SetAttribute("WindowInteractionState", $pattern.Current.WindowInteractionState)
163
- $newXmlElement.SetAttribute("IsTopmost", $pattern.Current.IsTopmost)
164
- }
165
-
166
- if ($element.TryGetCurrentPattern([TransformPattern]::Pattern, [ref]$pattern)) {
167
- $newXmlElement.SetAttribute("CanRotate", $pattern.Current.CanRotate)
168
- $newXmlElement.SetAttribute("CanResize", $pattern.Current.CanResize)
169
- $newXmlElement.SetAttribute("CanMove", $pattern.Current.CanMove)
170
- }
171
-
172
- # TODO: more to be added depending on the available patterns
173
-
174
- if ($null -eq $xmlElement) {
175
- $xmlElement = $xmlDoc.AppendChild($newXmlElement)
176
- } else {
177
- $xmlElement = $xmlElement.AppendChild($newXmlElement)
178
- }
179
-
180
- $elementsToProcess = New-Object System.Collections.Queue
181
- $element.FindAll([TreeScope]::Children, $cacheRequest.TreeFilter) | ForEach-Object {
182
- $elementsToProcess.Enqueue($_)
183
- }
184
-
185
- while ($elementsToProcess.Count -gt 0) {
186
- $currentElement = $elementsToProcess.Dequeue()
187
- Get-PageSource $currentElement $xmlDoc $xmlElement | Out-Null
188
- }
189
- } catch {
190
- # noop
191
- }
192
-
193
- return $xmlElement
194
- }
75
+ exports.PAGE_SOURCE = (0, powershell_1.pwsh /* ps1 */) `
76
+ function Get-PageSource {
77
+ param (
78
+ [Parameter(Mandatory = $true)]
79
+ [AutomationElement]$element,
80
+ [Xml.XmlDocument]$xmlDoc,
81
+ [Xml.XmlElement]$xmlElement
82
+ )
83
+
84
+ try {
85
+ $localizedControlType = $element.GetCurrentPropertyValue([AutomationElement]::LocalizedControlTypeProperty)
86
+ $controlType = $element.GetCurrentPropertyValue([AutomationElement]::ControlTypeProperty)
87
+
88
+ $tagName = ''
89
+ try {
90
+ $tagName = $controlType.ProgrammaticName.Split('.')[-1]
91
+ if ($tagName -eq 'DataGrid') { $tagName = 'List' }
92
+ elseif ($tagName -eq 'DataItem') { $tagName = 'ListItem' }
93
+ } catch {
94
+ # fallback to LocalizedControlType ControlType is empty
95
+ $tagName = -join ($localizedControlType -split ' ' | ForEach-Object {
96
+ $_.Substring(0, 1).ToUpper() + $_.Substring(1).ToLower()
97
+ })
98
+ }
99
+
100
+ $acceleratorKey = $element.GetCurrentPropertyValue([AutomationElement]::AcceleratorKeyProperty)
101
+ $accessKey = $element.GetCurrentPropertyValue([AutomationElement]::AccessKeyProperty)
102
+ $automationId = $element.GetCurrentPropertyValue([AutomationElement]::AutomationIdProperty)
103
+ $className = $element.GetCurrentPropertyValue([AutomationElement]::ClassNameProperty)
104
+ $frameworkId = $element.GetCurrentPropertyValue([AutomationElement]::FrameworkIdProperty)
105
+ $hasKeyboardfocus = $element.GetCurrentPropertyValue([AutomationElement]::HasKeyboardfocusProperty)
106
+ $helpText = $element.GetCurrentPropertyValue([AutomationElement]::HelpTextProperty)
107
+ $isContentelement = $element.GetCurrentPropertyValue([AutomationElement]::IsContentelementProperty)
108
+ $isControlelement = $element.GetCurrentPropertyValue([AutomationElement]::IsControlelementProperty)
109
+ $isEnabled = $element.GetCurrentPropertyValue([AutomationElement]::IsEnabledProperty)
110
+ $isKeyboardfocusable = $element.GetCurrentPropertyValue([AutomationElement]::IsKeyboardfocusableProperty)
111
+ $isOffscreen = $element.GetCurrentPropertyValue([AutomationElement]::IsOffscreenProperty)
112
+ $isPassword = $element.GetCurrentPropertyValue([AutomationElement]::IsPasswordProperty)
113
+ $isRequiredforform = $element.GetCurrentPropertyValue([AutomationElement]::IsRequiredforformProperty)
114
+ $itemStatus = $element.GetCurrentPropertyValue([AutomationElement]::ItemStatusProperty)
115
+ $itemType = $element.GetCurrentPropertyValue([AutomationElement]::ItemTypeProperty)
116
+ $name = $element.GetCurrentPropertyValue([AutomationElement]::NameProperty)
117
+ $orientation = $element.GetCurrentPropertyValue([AutomationElement]::OrientationProperty)
118
+ $processId = $element.GetCurrentPropertyValue([AutomationElement]::ProcessIdProperty)
119
+ $runtimeId = $element.GetCurrentPropertyValue([AutomationElement]::RuntimeIdProperty) -join '.'
120
+ $boundingRectangle = $element.Current.BoundingRectangle
121
+ $x = $boundingRectangle.X - $rootElement.Current.BoundingRectangle.X
122
+ $y = $boundingRectangle.Y - $rootElement.Current.BoundingRectangle.Y
123
+ $width = $boundingRectangle.Width
124
+ $height = $boundingRectangle.Height
125
+
126
+ if ($null -eq $xmlDoc) { $xmlDoc = [Xml.XmlDocument]::new() }
127
+
128
+ $newXmlElement = $xmlDoc.CreateElement($tagName)
129
+ $newXmlElement.SetAttribute("AcceleratorKey", $acceleratorKey)
130
+ $newXmlElement.SetAttribute("AccessKey", $accessKey)
131
+ $newXmlElement.SetAttribute("AutomationId", $automationId)
132
+ $newXmlElement.SetAttribute("ClassName", $className)
133
+ $newXmlElement.SetAttribute("FrameworkId", $frameworkId)
134
+ $newXmlElement.SetAttribute("HasKeyboardfocus", $hasKeyboardfocus)
135
+ $newXmlElement.SetAttribute("HelpText", $helpText)
136
+ $newXmlElement.SetAttribute("IsContentelement", $isContentelement)
137
+ $newXmlElement.SetAttribute("IsControlelement", $isControlelement)
138
+ $newXmlElement.SetAttribute("IsEnabled", $isEnabled)
139
+ $newXmlElement.SetAttribute("IsKeyboardfocusable", $isKeyboardfocusable)
140
+ $newXmlElement.SetAttribute("IsOffscreen", $isOffscreen)
141
+ $newXmlElement.SetAttribute("IsPassword", $isPassword)
142
+ $newXmlElement.SetAttribute("IsRequiredforform", $isRequiredforform)
143
+ $newXmlElement.SetAttribute("ItemStatus", $itemStatus)
144
+ $newXmlElement.SetAttribute("ItemType", $itemType)
145
+ $newXmlElement.SetAttribute("LocalizedControlType", $localizedControlType)
146
+ $newXmlElement.SetAttribute("Name", $name)
147
+ $newXmlElement.SetAttribute("Orientation", $orientation)
148
+ $newXmlElement.SetAttribute("ProcessId", $processId)
149
+ $newXmlElement.SetAttribute("RuntimeId", $runtimeId)
150
+ $newXmlElement.SetAttribute("x", $x)
151
+ $newXmlElement.SetAttribute("y", $y)
152
+ $newXmlElement.SetAttribute("width", $width)
153
+ $newXmlElement.SetAttribute("height", $height)
154
+
155
+ $pattern = $null
156
+
157
+ if ($element.TryGetCurrentPattern([WindowPattern]::Pattern, [ref]$pattern)) {
158
+ $newXmlElement.SetAttribute("CanMaximize", $pattern.Current.CanMaximize)
159
+ $newXmlElement.SetAttribute("CanMinimize", $pattern.Current.CanMinimize)
160
+ $newXmlElement.SetAttribute("IsModal", $pattern.Current.IsModal)
161
+ $newXmlElement.SetAttribute("WindowVisualState", $pattern.Current.WindowVisualState)
162
+ $newXmlElement.SetAttribute("WindowInteractionState", $pattern.Current.WindowInteractionState)
163
+ $newXmlElement.SetAttribute("IsTopmost", $pattern.Current.IsTopmost)
164
+ }
165
+
166
+ if ($element.TryGetCurrentPattern([TransformPattern]::Pattern, [ref]$pattern)) {
167
+ $newXmlElement.SetAttribute("CanRotate", $pattern.Current.CanRotate)
168
+ $newXmlElement.SetAttribute("CanResize", $pattern.Current.CanResize)
169
+ $newXmlElement.SetAttribute("CanMove", $pattern.Current.CanMove)
170
+ }
171
+
172
+ # TODO: more to be added depending on the available patterns
173
+
174
+ if ($null -eq $xmlElement) {
175
+ $xmlElement = $xmlDoc.AppendChild($newXmlElement)
176
+ } else {
177
+ $xmlElement = $xmlElement.AppendChild($newXmlElement)
178
+ }
179
+
180
+ $elementsToProcess = New-Object System.Collections.Queue
181
+ $element.FindAll([TreeScope]::Children, $cacheRequest.TreeFilter) | ForEach-Object {
182
+ $elementsToProcess.Enqueue($_)
183
+ }
184
+
185
+ while ($elementsToProcess.Count -gt 0) {
186
+ $currentElement = $elementsToProcess.Dequeue()
187
+ Get-PageSource $currentElement $xmlDoc $xmlElement | Out-Null
188
+ }
189
+ } catch {
190
+ # noop
191
+ }
192
+
193
+ return $xmlElement
194
+ }
195
195
  `;
196
196
  //# sourceMappingURL=functions.js.map
@@ -37,11 +37,11 @@ declare const commands: {
37
37
  patternRestore(this: import("../driver").NovaWindows2Driver, element: import("@appium/types").Element): Promise<void>;
38
38
  patternClose(this: import("../driver").NovaWindows2Driver, element: import("@appium/types").Element): Promise<void>;
39
39
  focusElement(this: import("../driver").NovaWindows2Driver, element: import("@appium/types").Element): Promise<void>;
40
- getClipboardBase64(this: import("../driver").NovaWindows2Driver, contentType?: ("image" | "plaintext") | {
41
- contentType?: "image" | "plaintext";
40
+ getClipboardBase64(this: import("../driver").NovaWindows2Driver, contentType?: ("plaintext" | "image") | {
41
+ contentType?: "plaintext" | "image";
42
42
  }): Promise<string>;
43
43
  setClipboardFromBase64(this: import("../driver").NovaWindows2Driver, args: {
44
- contentType?: "image" | "plaintext";
44
+ contentType?: "plaintext" | "image";
45
45
  b64Content: string;
46
46
  }): Promise<string>;
47
47
  executePowerShellScript(this: import("../driver").NovaWindows2Driver, script: string | {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/commands/index.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAoBize,CAAC;;;mBAAurB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;iBAAknH,CAAC;SAAgB,CAAC;SAAgB,CAAC;cAAqB,CAAC;oBAA8B,CAAC;kBAA+G,CAAC;aAAoB,CAAC;yBAAgC,CAAC;;;sBAAgzG,CAAC;cAAqB,CAAC;cAAqB,CAAC;oBAA2B,CAAC;YAAmB,CAAC;YAAmB,CAAC;oBAA2B,CAAC;kBAA4F,CAAC;;;iBAA04H,CAAC;SAAgB,CAAC;SAAgB,CAAC;cAAqB,CAAC;cAAqB,CAAC;oBAA2B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAVt32B,CAAC;AAEF,KAAK,QAAQ,GAAG;KACX,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,GAAG,CAAC;CACvD,CAAC;AAEF,OAAO,QAAQ,WAAW,CAAC;IACvB,UAAU,kBAAmB,SAAQ,QAAQ;KAAI;CACpD;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/commands/index.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAoBg/d,CAAC;;;mBAAwqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkhH,CAAC;SAAe,CAAC;SAAe,CAAC;cAAoB,CAAC;oBAA6B,CAAC;kBAA8G,CAAC;aAAmB,CAAC;yBAA+B,CAAC;;;sBAAmtG,CAAC;cAAoB,CAAC;cAAoB,CAAC;oBAA0B,CAAC;YAAkB,CAAC;YAAkB,CAAC;oBAA0B,CAAC;kBAA2F,CAAC;;;iBAA0yH,CAAC;SAAe,CAAC;SAAe,CAAC;cAAoB,CAAC;cAAoB,CAAC;oBAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAVtv1B,CAAC;AAEF,KAAK,QAAQ,GAAG;KACX,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,GAAG,CAAC;CACvD,CAAC;AAEF,OAAO,QAAQ,WAAW,CAAC;IACvB,UAAU,kBAAmB,SAAQ,QAAQ;KAAI;CACpD;AAED,eAAe,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../lib/commands/powershell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAiJ/C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFpF;AAED,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC9G;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBtG;AAED,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCxF"}
1
+ {"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../../lib/commands/powershell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAwJ/C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFpF;AAED,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC9G;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBtG;AAED,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCxF"}