appium-novawindows2-driver 0.1.13 → 0.2.1

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,38 +13,38 @@ 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
- $dummy = [xml]'<DummyRoot></DummyRoot>'
21
- return $dummy.OuterXml
22
- }
23
-
24
- Get-PageSource $el |
25
- ForEach-Object { $_.OuterXml }
16
+ const GET_PAGE_SOURCE_COMMAND = (0, powershell_1.pwsh$ /* ps1 */) `
17
+ $el = ${0}
18
+
19
+ if ($el -eq $null) {
20
+ $dummy = [xml]'<DummyRoot></DummyRoot>'
21
+ return $dummy.OuterXml
22
+ }
23
+
24
+ Get-PageSource $el |
25
+ ForEach-Object { $_.OuterXml }
26
26
  `;
27
- const GET_SCREENSHOT_COMMAND = (0, powershell_1.pwsh /* ps1 */) `
28
- if ($rootElement -eq $null) {
29
- $bitmap = New-Object Drawing.Bitmap 1,1
30
- $stream = New-Object IO.MemoryStream
31
- $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
32
- $bitmap.Dispose()
33
- return [Convert]::ToBase64String($stream.ToArray())
34
- }
35
-
36
- $rect = $rootElement.Current.BoundingRectangle
37
- $bitmap = New-Object Drawing.Bitmap([int32]$rect.Width, [int32]$rect.Height)
38
-
39
- $graphics = [Drawing.Graphics]::FromImage($bitmap)
40
- $graphics.CopyFromScreen([int32]$rect.Left, [int32]$rect.Top, 0, 0, $bitmap.Size)
41
- $graphics.Dispose()
42
-
43
- $stream = New-Object IO.MemoryStream
44
- $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
45
- $bitmap.Dispose()
46
-
47
- [Convert]::ToBase64String($stream.ToArray())
27
+ const GET_SCREENSHOT_COMMAND = (0, powershell_1.pwsh /* ps1 */) `
28
+ if ($rootElement -eq $null) {
29
+ $bitmap = New-Object Drawing.Bitmap 1,1
30
+ $stream = New-Object IO.MemoryStream
31
+ $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
32
+ $bitmap.Dispose()
33
+ return [Convert]::ToBase64String($stream.ToArray())
34
+ }
35
+
36
+ $rect = $rootElement.Current.BoundingRectangle
37
+ $bitmap = New-Object Drawing.Bitmap([int32]$rect.Width, [int32]$rect.Height)
38
+
39
+ $graphics = [Drawing.Graphics]::FromImage($bitmap)
40
+ $graphics.CopyFromScreen([int32]$rect.Left, [int32]$rect.Top, 0, 0, $bitmap.Size)
41
+ $graphics.Dispose()
42
+
43
+ $stream = New-Object IO.MemoryStream
44
+ $bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
45
+ $bitmap.Dispose()
46
+
47
+ [Convert]::ToBase64String($stream.ToArray())
48
48
  `;
49
49
  async function getPageSource() {
50
50
  return await this.sendPowerShellCommand(GET_PAGE_SOURCE_COMMAND.format(powershell_1.AutomationElement.automationRoot));
@@ -76,20 +76,20 @@ const AUTOMATION_ELEMENT_MODE = (0, util_1.$ /* ps1 */) `$cacheRequest.Pop(); $c
76
76
  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`;
77
77
  const GET_PLAINTEXT_CLIPBOARD_BASE64 = /* ps1 */ `$str = Get-Clipboard | Out-String; if ($null -eq $str) { $str = '' }; [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($str))`;
78
78
  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()`;
79
- const GET_IMAGE_CLIPBOARD_BASE64 = (0, powershell_1.pwsh /* ps1 */) `
80
- [Windows.Clipboard]::GetImage() | ForEach-Object {
81
- if ($_ -ne $null) {
82
- $stream = New-Object IO.MemoryStream
83
- $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
84
- $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($_))
85
- $encoder.Save($stream)
86
- $stream.Position = 0
87
- $bytes = $stream.ToArray()
88
- $base64String = [Convert]::ToBase64String($bytes)
89
- $stream.Close()
90
- Write-Output $base64String
91
- }
92
- }
79
+ const GET_IMAGE_CLIPBOARD_BASE64 = (0, powershell_1.pwsh /* ps1 */) `
80
+ [Windows.Clipboard]::GetImage() | ForEach-Object {
81
+ if ($_ -ne $null) {
82
+ $stream = New-Object IO.MemoryStream
83
+ $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
84
+ $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($_))
85
+ $encoder.Save($stream)
86
+ $stream.Position = 0
87
+ $bytes = $stream.ToArray()
88
+ $base64String = [Convert]::ToBase64String($bytes)
89
+ $stream.Close()
90
+ Write-Output $base64String
91
+ }
92
+ }
93
93
  `;
94
94
  async function execute(script, args) {
95
95
  if (script.startsWith(PLATFORM_COMMAND_PREFIX)) {
@@ -179,18 +179,18 @@ async function patternScrollIntoView(element) {
179
179
  try {
180
180
  // Manual repair using FindFirst with strict PS types to avoid marshalling issues
181
181
  const idParts = elementId.split('.').join(',');
182
- const repairScript = `
183
- $targetIdArray = [int32[]]@(${idParts});
184
- $cond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::RuntimeIdProperty, $targetIdArray);
185
- $found = [System.Windows.Automation.AutomationElement]::RootElement.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond);
186
-
187
- if ($null -ne $found) {
188
- $runtimeId = $found.GetRuntimeId() -join '.';
189
- if (-not $elementTable.ContainsKey($runtimeId)) {
190
- $elementTable.Add($runtimeId, $found)
191
- };
192
- $runtimeId
193
- }
182
+ const repairScript = `
183
+ $targetIdArray = [int32[]]@(${idParts});
184
+ $cond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::RuntimeIdProperty, $targetIdArray);
185
+ $found = [System.Windows.Automation.AutomationElement]::RootElement.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond);
186
+
187
+ if ($null -ne $found) {
188
+ $runtimeId = $found.GetRuntimeId() -join '.';
189
+ if (-not $elementTable.ContainsKey($runtimeId)) {
190
+ $elementTable.Add($runtimeId, $found)
191
+ };
192
+ $runtimeId
193
+ }
194
194
  `;
195
195
  const repairedId = await this.sendPowerShellCommand(repairScript);
196
196
  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", $windowPattern.Current.CanMaximize)
159
- $newXmlElement.SetAttribute("CanMinimize", $windowPattern.Current.CanMinimize)
160
- $newXmlElement.SetAttribute("IsModal", $windowPattern.Current.IsModal)
161
- $newXmlElement.SetAttribute("WindowVisualState", $windowPattern.Current.WindowVisualState)
162
- $newXmlElement.SetAttribute("WindowInteractionState", $windowPattern.Current.WindowInteractionState)
163
- $newXmlElement.SetAttribute("IsTopmost", $windowPattern.Current.IsTopmost)
164
- }
165
-
166
- if ($element.TryGetCurrentPattern([TransformPattern]::Pattern, [ref]$pattern)) {
167
- $newXmlElement.SetAttribute("CanRotate", $windowPattern.Current.CanRotate)
168
- $newXmlElement.SetAttribute("CanResize", $windowPattern.Current.CanResize)
169
- $newXmlElement.SetAttribute("CanMove", $windowPattern.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", $windowPattern.Current.CanMaximize)
159
+ $newXmlElement.SetAttribute("CanMinimize", $windowPattern.Current.CanMinimize)
160
+ $newXmlElement.SetAttribute("IsModal", $windowPattern.Current.IsModal)
161
+ $newXmlElement.SetAttribute("WindowVisualState", $windowPattern.Current.WindowVisualState)
162
+ $newXmlElement.SetAttribute("WindowInteractionState", $windowPattern.Current.WindowInteractionState)
163
+ $newXmlElement.SetAttribute("IsTopmost", $windowPattern.Current.IsTopmost)
164
+ }
165
+
166
+ if ($element.TryGetCurrentPattern([TransformPattern]::Pattern, [ref]$pattern)) {
167
+ $newXmlElement.SetAttribute("CanRotate", $windowPattern.Current.CanRotate)
168
+ $newXmlElement.SetAttribute("CanResize", $windowPattern.Current.CanResize)
169
+ $newXmlElement.SetAttribute("CanMove", $windowPattern.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?: ("plaintext" | "image") | {
41
- contentType?: "plaintext" | "image";
40
+ getClipboardBase64(this: import("../driver").NovaWindows2Driver, contentType?: ("image" | "plaintext") | {
41
+ contentType?: "image" | "plaintext";
42
42
  }): Promise<string>;
43
43
  setClipboardFromBase64(this: import("../driver").NovaWindows2Driver, args: {
44
- contentType?: "plaintext" | "image";
44
+ contentType?: "image" | "plaintext";
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAoBoxe,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAVz12B,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAoBo9d,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAV1t1B,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"}