uia 0.8 → 1.0
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.
- checksums.yaml +4 -4
- data/ext/UiaDll/Release/UIA.Helper.dll +0 -0
- data/ext/UiaDll/Release/UiaDll.dll +0 -0
- data/ext/UiaDll/UIA.Helper/Element.cs +5 -0
- data/ext/UiaDll/UIA.Helper/UIA.Helper.csproj +5 -3
- data/ext/UiaDll/UiaDll/ComboBoxMethods.cpp +89 -0
- data/ext/UiaDll/UiaDll/MenuItemMethods.cpp +32 -2
- data/ext/UiaDll/UiaDll/SelectionMethods.cpp +37 -4
- data/ext/UiaDll/UiaDll/TableMethods.cpp +10 -4
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj +2 -1
- data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +3 -0
- data/ext/UiaDll/UiaDll.Test/UiaDll.Test.vcxproj +1 -1
- data/lib/uia/control_types/combo_box.rb +25 -0
- data/lib/uia/library.rb +5 -0
- data/lib/uia/version.rb +1 -1
- data/spec/app/WindowsForms.exe +0 -0
- data/spec/app/WindowsForms.exe.config +6 -0
- data/spec/uia/control_types/combo_box_spec.rb +21 -0
- data/spec/uia/element_spec.rb +9 -9
- data/spec/uia/keys_spec.rb +1 -1
- data/spec/uia/patterns/selection_spec.rb +10 -2
- data/spec/uia_spec.rb +5 -4
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c2b4d015985e4d591a9896fa2cee66e60b5eb29a6f774accc23094d4ec1429
|
4
|
+
data.tar.gz: '08f1ae75dcf5b10a3e59f077c8ead8bb9e81834f61b1eebf4838606569c006ad'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da1e59adbead52a98088604751feb2ae5aa2c0fe64ddb1dc02a9794427992a0e0cbb52fa6adddc59cb3a15a57047fe0c1f8b22dc8882b7ff8aa09f76e31bd057
|
7
|
+
data.tar.gz: ac970d4aeb30e37182311295d4a70ce7f9c161422eae8b7c7078a98b6ecefcc37df913d8be65307bf6e790854960ff9c44cf1310d358ef1fb3a27c4e32069f28
|
Binary file
|
Binary file
|
@@ -179,6 +179,11 @@ namespace UIA.Helper
|
|
179
179
|
return FindFirst(TreeScope.Subtree, new AndCondition(name.NameCondition(), ControlType.MenuItem.Condition()));
|
180
180
|
}
|
181
181
|
|
182
|
+
public Element FirstMenuItem()
|
183
|
+
{
|
184
|
+
return FindFirst(TreeScope.Subtree, new AndCondition(Condition.TrueCondition, ControlType.MenuItem.Condition()));
|
185
|
+
}
|
186
|
+
|
182
187
|
public static Element ByRuntimeId(int[] runtimeId)
|
183
188
|
{
|
184
189
|
var condition = new PropertyCondition(AutomationElement.RuntimeIdProperty, runtimeId);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<Project ToolsVersion="
|
2
|
+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3
3
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
4
4
|
<PropertyGroup>
|
5
5
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
10
10
|
<RootNamespace>UIA.Helper</RootNamespace>
|
11
11
|
<AssemblyName>UIA.Helper</AssemblyName>
|
12
|
-
<TargetFrameworkVersion>v4.
|
12
|
+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
13
13
|
<FileAlignment>512</FileAlignment>
|
14
14
|
<TargetFrameworkProfile />
|
15
15
|
</PropertyGroup>
|
@@ -21,6 +21,7 @@
|
|
21
21
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
22
22
|
<ErrorReport>prompt</ErrorReport>
|
23
23
|
<WarningLevel>4</WarningLevel>
|
24
|
+
<Prefer32Bit>false</Prefer32Bit>
|
24
25
|
</PropertyGroup>
|
25
26
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
26
27
|
<DebugType>pdbonly</DebugType>
|
@@ -29,6 +30,7 @@
|
|
29
30
|
<DefineConstants>TRACE</DefineConstants>
|
30
31
|
<ErrorReport>prompt</ErrorReport>
|
31
32
|
<WarningLevel>4</WarningLevel>
|
33
|
+
<Prefer32Bit>false</Prefer32Bit>
|
32
34
|
</PropertyGroup>
|
33
35
|
<ItemGroup>
|
34
36
|
<Reference Include="System" />
|
@@ -60,4 +62,4 @@
|
|
60
62
|
<Target Name="AfterBuild">
|
61
63
|
</Target>
|
62
64
|
-->
|
63
|
-
</Project>
|
65
|
+
</Project>
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#include "Stdafx.h"
|
2
|
+
|
3
|
+
extern "C"
|
4
|
+
{
|
5
|
+
__declspec(dllexport) int ComboBox_GetItems(ElementInformationPtr element, ElementInformation** items, char* errorInfo, const int errorInfoLength)
|
6
|
+
{
|
7
|
+
try {
|
8
|
+
int count = 0;
|
9
|
+
|
10
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Expand();
|
11
|
+
|
12
|
+
if ("ComboLBox" == Element::Windows[0]->ClassName)
|
13
|
+
{
|
14
|
+
auto childElements = Element::Windows[0]->Children;
|
15
|
+
*items = ElementInformation::From(childElements);
|
16
|
+
count = childElements->Length;
|
17
|
+
}
|
18
|
+
else
|
19
|
+
{
|
20
|
+
StringHelper::CopyToUnmanagedString("Unable to find list control associated with combo box", errorInfo, errorInfoLength);
|
21
|
+
}
|
22
|
+
|
23
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Collapse();
|
24
|
+
|
25
|
+
return count;
|
26
|
+
}
|
27
|
+
catch (Exception^ e) {
|
28
|
+
StringHelper::CopyToUnmanagedString(e, errorInfo, errorInfoLength);
|
29
|
+
return 0;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
__declspec(dllexport) void ComboBox_SetItemByIndex(ElementInformationPtr element, const int itemIndex, char* errorInfo, const int errorInfoLength)
|
34
|
+
{
|
35
|
+
try {
|
36
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Expand();
|
37
|
+
|
38
|
+
if ("ComboLBox" == Element::Windows[0]->ClassName)
|
39
|
+
{
|
40
|
+
auto childElements = Element::Windows[0]->Children;
|
41
|
+
if (childElements->Length > itemIndex && itemIndex > -1)
|
42
|
+
{
|
43
|
+
childElements[itemIndex]->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Select();
|
44
|
+
}
|
45
|
+
else
|
46
|
+
{
|
47
|
+
StringHelper::CopyToUnmanagedString("Specified index was not found in combo box list", errorInfo, errorInfoLength);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
else
|
51
|
+
{
|
52
|
+
StringHelper::CopyToUnmanagedString("Unable to find list control associated with combo box", errorInfo, errorInfoLength);
|
53
|
+
}
|
54
|
+
|
55
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Collapse();
|
56
|
+
}
|
57
|
+
catch (Exception^ e) {
|
58
|
+
StringHelper::CopyToUnmanagedString(e, errorInfo, errorInfoLength);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
__declspec(dllexport) void ComboBox_SetItemByValue(ElementInformationPtr element, const char* itemValue, char* errorInfo, const int errorInfoLength)
|
63
|
+
{
|
64
|
+
try {
|
65
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Expand();
|
66
|
+
|
67
|
+
if ("ComboLBox" == Element::Windows[0]->ClassName)
|
68
|
+
{
|
69
|
+
auto childElements = Element::Windows[0]->Children;
|
70
|
+
for each (auto item in childElements)
|
71
|
+
{
|
72
|
+
if (strcmp(StringHelper::ToUnmanaged(item->Name), itemValue) == 0)
|
73
|
+
{
|
74
|
+
item->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Select();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
else
|
79
|
+
{
|
80
|
+
StringHelper::CopyToUnmanagedString("Unable to find list control associated with combo box", errorInfo, errorInfoLength);
|
81
|
+
}
|
82
|
+
|
83
|
+
ElementFrom(element)->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern)->Collapse();
|
84
|
+
}
|
85
|
+
catch (Exception^ e) {
|
86
|
+
StringHelper::CopyToUnmanagedString(e, errorInfo, errorInfoLength);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
@@ -39,17 +39,47 @@ extern "C" {
|
|
39
39
|
}
|
40
40
|
}
|
41
41
|
|
42
|
+
void OpenMenuToCreateChildControls(ElementInformationPtr element)
|
43
|
+
{
|
44
|
+
auto firstItem = ElementFrom(element)->FirstMenuItem();
|
45
|
+
if (nullptr != firstItem)
|
46
|
+
{
|
47
|
+
try
|
48
|
+
{
|
49
|
+
auto asExpand = firstItem->As<ExpandCollapsePattern^>(ExpandCollapsePattern::Pattern);
|
50
|
+
if (asExpand->Current.ExpandCollapseState == ExpandCollapseState::Collapsed)
|
51
|
+
{
|
52
|
+
asExpand->Expand();
|
53
|
+
}
|
54
|
+
}
|
55
|
+
catch (Exception^)
|
56
|
+
{}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
42
60
|
Element^ MenuItemPath(ElementInformationPtr element, list<const char*>& items) {
|
43
61
|
auto current = ElementFrom(element);
|
62
|
+
bool foundAtleastOneItem = false;
|
44
63
|
|
45
64
|
for(auto item = items.begin(); item != items.end(); ++item) {
|
46
65
|
auto name = gcnew String(*item);
|
47
66
|
|
48
67
|
current = current->MenuItem(name);
|
49
|
-
|
68
|
+
|
69
|
+
if (nullptr == current && !foundAtleastOneItem)
|
70
|
+
{
|
71
|
+
OpenMenuToCreateChildControls(element);
|
72
|
+
|
73
|
+
current = ElementFrom(element)->MenuItem(name);
|
74
|
+
}
|
75
|
+
|
76
|
+
if (nullptr == current)
|
77
|
+
{
|
50
78
|
throw gcnew MenuItemNotFound(String::Format("the menu item \"{0}\" was not found", name));
|
51
79
|
}
|
52
80
|
|
81
|
+
foundAtleastOneItem = true;
|
82
|
+
|
53
83
|
if( *item != items.back() ) {
|
54
84
|
current->As<InvokePattern^>(InvokePattern::Pattern)->Invoke();
|
55
85
|
}
|
@@ -57,4 +87,4 @@ extern "C" {
|
|
57
87
|
|
58
88
|
return current;
|
59
89
|
}
|
60
|
-
}
|
90
|
+
}
|
@@ -16,12 +16,45 @@ extern "C" {
|
|
16
16
|
|
17
17
|
__declspec(dllexport) int Selection_Selections(ElementInformationPtr element, ElementInformation** selections, char* errorInfo, const int errorInfoLength) {
|
18
18
|
try {
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
int selectedItemCount = 0;
|
20
|
+
|
21
|
+
auto selectedElements = ElementFrom(element)->Find(TreeScope::Descendants, gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::ListItem));
|
22
|
+
if (selectedElements->Length == 0)
|
23
|
+
{
|
24
|
+
selectedElements = ElementFrom(element)->Find(TreeScope::Descendants, gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::TreeItem));
|
25
|
+
}
|
26
|
+
|
27
|
+
if (selectedElements->Length > 0)
|
28
|
+
{
|
29
|
+
for each (auto item in selectedElements)
|
30
|
+
{
|
31
|
+
if (item->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Current.IsSelected)
|
32
|
+
{
|
33
|
+
selectedItemCount++;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
auto selectedItems = new _ElementInformation[selectedItemCount];
|
38
|
+
int i = 0;
|
39
|
+
for each (auto item in selectedElements)
|
40
|
+
{
|
41
|
+
if (item->As<SelectionItemPattern^>(SelectionItemPattern::Pattern)->Current.IsSelected)
|
42
|
+
{
|
43
|
+
selectedItems[i].Refresh(item);
|
44
|
+
i++;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
*selections = selectedItems;
|
48
|
+
}
|
49
|
+
else
|
50
|
+
{
|
51
|
+
*selections = nullptr;
|
52
|
+
}
|
53
|
+
|
54
|
+
return selectedItemCount;
|
22
55
|
} catch(Exception^ e) {
|
23
56
|
StringHelper::CopyToUnmanagedString(e, errorInfo, errorInfoLength);
|
24
57
|
return 0;
|
25
58
|
}
|
26
59
|
}
|
27
|
-
}
|
60
|
+
}
|
@@ -16,9 +16,15 @@ extern "C" {
|
|
16
16
|
|
17
17
|
__declspec(dllexport) int Table_Headers(ElementInformationPtr element, ElementInformation** headers, char* errorInfo, const int errorInfoLength) {
|
18
18
|
try {
|
19
|
-
auto
|
20
|
-
|
21
|
-
|
19
|
+
auto headerParent = ElementFrom(element)->Find(TreeScope::Children, gcnew PropertyCondition(AutomationElement::ControlTypeProperty, ControlType::Header));
|
20
|
+
if (headerParent->Length > 0)
|
21
|
+
{
|
22
|
+
auto headerElements = headerParent[0]->Children;
|
23
|
+
*headers = ElementInformation::From(headerElements);
|
24
|
+
return headerElements->Length;
|
25
|
+
}
|
26
|
+
*headers = nullptr;
|
27
|
+
return 0;
|
22
28
|
} catch(Exception^ e) {
|
23
29
|
StringHelper::CopyToUnmanagedString(e, errorInfo, errorInfoLength);
|
24
30
|
return 0;
|
@@ -34,4 +40,4 @@ extern "C" {
|
|
34
40
|
return NULL;
|
35
41
|
}
|
36
42
|
}
|
37
|
-
}
|
43
|
+
}
|
@@ -12,7 +12,7 @@
|
|
12
12
|
</ItemGroup>
|
13
13
|
<PropertyGroup Label="Globals">
|
14
14
|
<ProjectGuid>{16531A20-39FB-4BDB-8F1C-E2D619BBCF58}</ProjectGuid>
|
15
|
-
<TargetFrameworkVersion>v4.
|
15
|
+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
16
16
|
<Keyword>ManagedCProj</Keyword>
|
17
17
|
<RootNamespace>UiaDll</RootNamespace>
|
18
18
|
</PropertyGroup>
|
@@ -90,6 +90,7 @@
|
|
90
90
|
</ItemGroup>
|
91
91
|
<ItemGroup>
|
92
92
|
<ClCompile Include="AssemblyInfo.cpp" />
|
93
|
+
<ClCompile Include="ComboBoxMethods.cpp" />
|
93
94
|
<ClCompile Include="ConditionMethods.cpp" />
|
94
95
|
<ClCompile Include="DynamicAssemblyResolver.cpp" />
|
95
96
|
<ClCompile Include="ElementMethods.cpp" />
|
@@ -12,7 +12,7 @@
|
|
12
12
|
</ItemGroup>
|
13
13
|
<PropertyGroup Label="Globals">
|
14
14
|
<ProjectGuid>{E83CF3F7-74C6-4333-89E3-36C6297F0A06}</ProjectGuid>
|
15
|
-
<TargetFrameworkVersion>v4.
|
15
|
+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
16
16
|
<Keyword>ManagedCProj</Keyword>
|
17
17
|
<RootNamespace>UiaDllTest</RootNamespace>
|
18
18
|
</PropertyGroup>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Uia
|
2
|
+
module ControlTypes
|
3
|
+
module ComboBox
|
4
|
+
|
5
|
+
def items
|
6
|
+
Library.combo_box_items @element
|
7
|
+
end
|
8
|
+
|
9
|
+
def set(value)
|
10
|
+
case value
|
11
|
+
when String
|
12
|
+
Library.combo_box_set_item_by_value @element, value
|
13
|
+
when Regexp
|
14
|
+
found_item = items.find { |e| e.name =~ value }
|
15
|
+
if found_item
|
16
|
+
Library.combo_box_set_item_by_value @element, found_item.name
|
17
|
+
end
|
18
|
+
when Fixnum
|
19
|
+
Library.combo_box_set_item_by_index @element, value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/uia/library.rb
CHANGED
@@ -144,6 +144,11 @@ module Uia
|
|
144
144
|
# TextPattern methods
|
145
145
|
attach_function :Text_GetText, [:pointer, :pointer, :int, :pointer, :int], :int
|
146
146
|
|
147
|
+
# ComboBox methods
|
148
|
+
elements_from :combo_box_items, :ComboBox_GetItems, [:pointer]
|
149
|
+
attach_throwable_function :combo_box_set_item_by_value, :ComboBox_SetItemByValue, [:pointer, :pointer], :void
|
150
|
+
attach_throwable_function :combo_box_set_item_by_index, :ComboBox_SetItemByIndex, [:pointer, :int], :void
|
151
|
+
|
147
152
|
def self.get_text(element)
|
148
153
|
length = can_throw(:Text_GetText, element, nil, 0) + 1
|
149
154
|
p = FFI::MemoryPointer.new :pointer, length
|
data/lib/uia/version.rb
CHANGED
data/spec/app/WindowsForms.exe
CHANGED
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Uia::ControlTypes::ComboBox do
|
4
|
+
let(:main) { Uia.find_element(id: 'MainFormWindow') }
|
5
|
+
Given(:combo_box) { main.find(id: 'FruitsComboBox').as(:value).with(:combo_box) }
|
6
|
+
|
7
|
+
context '#items' do
|
8
|
+
Then { combo_box.items.map(&:name) == ['Apple', 'Caimito', 'Coconut', 'Orange', 'Passion Fruit'] }
|
9
|
+
end
|
10
|
+
|
11
|
+
context '#set' do
|
12
|
+
context 'by index' do
|
13
|
+
When { combo_box.set 1 }
|
14
|
+
Then { combo_box.value == 'Caimito' }
|
15
|
+
end
|
16
|
+
context 'by value' do
|
17
|
+
When { combo_box.set 'Orange' }
|
18
|
+
Then { combo_box.value == 'Orange' }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/uia/element_spec.rb
CHANGED
@@ -76,7 +76,7 @@ describe Uia::Element do
|
|
76
76
|
|
77
77
|
context '#as' do
|
78
78
|
When(:cast) { element.as :toggle }
|
79
|
-
Then {
|
79
|
+
Then { cast == Failure(UnsupportedPattern, "Pattern toggle not found in [:window, :transform]") }
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -133,7 +133,7 @@ describe Uia::Element do
|
|
133
133
|
|
134
134
|
context 'combinations' do
|
135
135
|
Then { element.find(control_type: :list, name: 'linkLabel1').id == 'FruitListBox' }
|
136
|
-
Then { element.find(control_type: :button, name: 'Forward', scope: :
|
136
|
+
Then { element.find(control_type: :button, name: 'Forward', scope: :element) == nil }
|
137
137
|
Then { element.find(pattern: :invoke, name: 'About').id == 'aboutButton' }
|
138
138
|
Then { element.find(control_type: :custom, id: 'automatableMonthCalendar1').name == 'linkLabel1' }
|
139
139
|
Then { element.find(value: 'linkLabel1', id: 'automatableMonthCalendar1').control_type == :custom }
|
@@ -141,7 +141,7 @@ describe Uia::Element do
|
|
141
141
|
|
142
142
|
context 'invalid' do
|
143
143
|
When(:bad_locator) { element.find(bad_locator: 123) }
|
144
|
-
Then {
|
144
|
+
Then { bad_locator == Failure(BadLocator, "{:bad_locator=>123} is not a valid locator") }
|
145
145
|
end
|
146
146
|
|
147
147
|
context 'limiting scope' do
|
@@ -164,7 +164,7 @@ describe Uia::Element do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
context 'pattern' do
|
167
|
-
Then { element.filter(pattern: :value).count ==
|
167
|
+
Then { element.filter(pattern: :value).count == 6 }
|
168
168
|
end
|
169
169
|
|
170
170
|
context 'combinations' do
|
@@ -172,11 +172,11 @@ describe Uia::Element do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
context 'multiple' do
|
175
|
-
When(:
|
176
|
-
Then { expect(
|
175
|
+
When(:radio_or_text) { element.filter(control_type: [:radio_button, :text]) }
|
176
|
+
Then { expect(radio_or_text.count).to eq(10) }
|
177
177
|
|
178
|
-
When(:
|
179
|
-
Then { expect(
|
178
|
+
When(:value_or_text) { element.filter(pattern: [:value, :text]) }
|
179
|
+
Then { expect(value_or_text.count).to eq(7) }
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -192,7 +192,7 @@ describe Uia::Element do
|
|
192
192
|
end
|
193
193
|
|
194
194
|
context '#children' do
|
195
|
-
Then { element.children.count ==
|
195
|
+
Then { element.children.count == 30 }
|
196
196
|
Then { element.children.all? { |c| c.instance_of? Uia::Element } }
|
197
197
|
end
|
198
198
|
|
data/spec/uia/keys_spec.rb
CHANGED
@@ -25,6 +25,6 @@ describe Uia::Keys do
|
|
25
25
|
|
26
26
|
context 'invalid' do
|
27
27
|
When(:bad_keys) { encode('something', :bad_key) }
|
28
|
-
Then {
|
28
|
+
Then { bad_keys == Failure(InvalidKey, "#{:bad_key} is not a valid key") }
|
29
29
|
end
|
30
30
|
end
|
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe Uia::Patterns::Selection do
|
4
4
|
let(:main) { Uia.find_element id: 'MainFormWindow' }
|
5
5
|
Given(:select_list) { main.find(id: 'FruitListBox').as :selection }
|
6
|
-
Given(:combo_box) { main.find(id: 'FruitsComboBox').as :selection }
|
7
6
|
|
8
7
|
context 'properties' do
|
9
8
|
context '#multi_select?' do
|
@@ -17,7 +16,6 @@ describe Uia::Patterns::Selection do
|
|
17
16
|
context '#selection_items' do
|
18
17
|
let(:respond_to_selections) { lambda { |e| e.respond_to? :add_to_selection } }
|
19
18
|
|
20
|
-
Then { combo_box.selection_items.map(&:name) == ['Apple', 'Caimito', 'Coconut', 'Orange', 'Passion Fruit'] }
|
21
19
|
Then { select_list.selection_items.all?(&respond_to_selections) == true }
|
22
20
|
|
23
21
|
context 'multiple levels of #selection_items' do
|
@@ -26,6 +24,16 @@ describe Uia::Patterns::Selection do
|
|
26
24
|
When { tree_view.selection_items.first.as(:expand_collapse).expand }
|
27
25
|
Then { tree_view.selection_items.map(&:name) == ['Parent One', 'Child 1', 'Child 2', 'Parent Two'] }
|
28
26
|
end
|
27
|
+
|
28
|
+
context 'can select tree view items' do
|
29
|
+
Given(:tree_view) { main.find(id: 'treeView').as :selection }
|
30
|
+
When do
|
31
|
+
tree_view.selection_items[0].as(:expand_collapse).expand
|
32
|
+
tree_view.selection_items[2].as(:expand_collapse).expand
|
33
|
+
tree_view.selection_items[3].select
|
34
|
+
end
|
35
|
+
Then { tree_view.selected_items.map(&:name) == ['Grandchild 1']}
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
39
|
context '#selected_items' do
|
data/spec/uia_spec.rb
CHANGED
@@ -30,8 +30,9 @@ describe Uia do
|
|
30
30
|
Then { expect(Uia.find_element(runtime_id: main_window.runtime_id)).to be_instance_of(Element) }
|
31
31
|
|
32
32
|
context 'can search descendants' do
|
33
|
-
Given(:element_with_no_handle) { Uia.find_element(id: 'MainFormWindow').find(name: 'Parent Two') }
|
34
|
-
|
33
|
+
Given(:element_with_no_handle) { Uia.find_element(id: 'MainFormWindow').find(name: 'Parent Two').as(:selection_item) }
|
34
|
+
When { element_with_no_handle.select }
|
35
|
+
Then { expect(element_with_no_handle.selected?).to be true }
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -48,7 +49,7 @@ describe Uia do
|
|
48
49
|
|
49
50
|
context 'invalid locators' do
|
50
51
|
When(:bad_input) { Uia.find_element(bad: 123) }
|
51
|
-
Then {
|
52
|
+
Then { bad_input == Failure(Uia::BadLocator, '{:bad=>123} is not a valid locator') }
|
52
53
|
end
|
53
54
|
end
|
54
|
-
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Levi Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- ext/UiaDll/UiaDll.sln
|
153
153
|
- ext/UiaDll/UiaDll/ArrayHelper.h
|
154
154
|
- ext/UiaDll/UiaDll/AssemblyInfo.cpp
|
155
|
+
- ext/UiaDll/UiaDll/ComboBoxMethods.cpp
|
155
156
|
- ext/UiaDll/UiaDll/ConditionHelper.h
|
156
157
|
- ext/UiaDll/UiaDll/ConditionMethods.cpp
|
157
158
|
- ext/UiaDll/UiaDll/DynamicAssemblyResolver.cpp
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- lib/core_ext/string.rb
|
188
189
|
- lib/core_ext/symbol.rb
|
189
190
|
- lib/uia.rb
|
191
|
+
- lib/uia/control_types/combo_box.rb
|
190
192
|
- lib/uia/control_types/menu_item.rb
|
191
193
|
- lib/uia/element.rb
|
192
194
|
- lib/uia/finder.rb
|
@@ -214,8 +216,10 @@ files:
|
|
214
216
|
- spec/app/FizzWare.NBuilder.dll
|
215
217
|
- spec/app/UIA.Extensions.dll
|
216
218
|
- spec/app/WindowsForms.exe
|
219
|
+
- spec/app/WindowsForms.exe.config
|
217
220
|
- spec/core_ext/symbol_spec.rb
|
218
221
|
- spec/spec_helper.rb
|
222
|
+
- spec/uia/control_types/combo_box_spec.rb
|
219
223
|
- spec/uia/control_types/menu_item_spec.rb
|
220
224
|
- spec/uia/element_spec.rb
|
221
225
|
- spec/uia/keys_spec.rb
|
@@ -252,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
256
|
- !ruby/object:Gem::Version
|
253
257
|
version: '0'
|
254
258
|
requirements: []
|
255
|
-
rubygems_version: 3.2.
|
259
|
+
rubygems_version: 3.2.32
|
256
260
|
signing_key:
|
257
261
|
specification_version: 4
|
258
262
|
summary: A low-level wrapper around Microsoft UI Automation for ruby
|
@@ -260,8 +264,10 @@ test_files:
|
|
260
264
|
- spec/app/FizzWare.NBuilder.dll
|
261
265
|
- spec/app/UIA.Extensions.dll
|
262
266
|
- spec/app/WindowsForms.exe
|
267
|
+
- spec/app/WindowsForms.exe.config
|
263
268
|
- spec/core_ext/symbol_spec.rb
|
264
269
|
- spec/spec_helper.rb
|
270
|
+
- spec/uia/control_types/combo_box_spec.rb
|
265
271
|
- spec/uia/control_types/menu_item_spec.rb
|
266
272
|
- spec/uia/element_spec.rb
|
267
273
|
- spec/uia/keys_spec.rb
|