rautomation 0.12.0 → 0.13.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/Gemfile.lock +1 -1
- data/History.rdoc +11 -1
- data/VERSION +1 -1
- data/ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs +5 -1
- data/ext/UiaDll/RAutomation.UIA/Controls/SelectList.cs +41 -1
- data/ext/UiaDll/RAutomation.UIA/Controls/TableControl.cs +37 -2
- data/ext/UiaDll/RAutomation.UIA/Extensions/Element.cs +48 -1
- data/ext/UiaDll/UiaDll/SelectListMethods.cpp +23 -0
- data/ext/UiaDll/UiaDll/StringHelper.cpp +5 -0
- data/ext/UiaDll/UiaDll/StringHelper.h +1 -0
- data/ext/UiaDll/UiaDll/TableMethods.cpp +23 -5
- data/ext/WindowsForms/WindowsForms/AboutBox.Designer.cs +31 -0
- data/ext/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +13 -0
- data/ext/WindowsForms/WindowsForms/DataEntryForm.cs +5 -0
- data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +32 -22
- data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +30 -1
- data/lib/rautomation/adapter/ms_uia/select_list.rb +8 -8
- data/lib/rautomation/adapter/ms_uia/table.rb +12 -8
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +36 -4
- data/spec/adapter/ms_uia/button_spec.rb +2 -2
- data/spec/adapter/ms_uia/checkbox_spec.rb +2 -2
- data/spec/adapter/ms_uia/listbox_spec.rb +15 -17
- data/spec/adapter/ms_uia/radio_spec.rb +1 -1
- data/spec/adapter/ms_uia/select_list_spec.rb +67 -65
- data/spec/adapter/ms_uia/spinner_spec.rb +1 -1
- data/spec/adapter/ms_uia/tab_control_spec.rb +3 -3
- data/spec/adapter/ms_uia/table_spec.rb +35 -17
- data/spec/adapter/ms_uia/text_field_spec.rb +2 -2
- data/spec/adapter/ms_uia/window_spec.rb +1 -63
- metadata +2 -2
@@ -29,14 +29,14 @@
|
|
29
29
|
private void InitializeComponent()
|
30
30
|
{
|
31
31
|
this.components = new System.ComponentModel.Container();
|
32
|
-
System.Windows.Forms.TreeNode
|
33
|
-
System.Windows.Forms.TreeNode
|
34
|
-
System.Windows.Forms.TreeNode
|
35
|
-
|
36
|
-
System.Windows.Forms.TreeNode
|
37
|
-
|
38
|
-
|
39
|
-
System.Windows.Forms.TreeNode
|
32
|
+
System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Child 1");
|
33
|
+
System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Grandchild 1");
|
34
|
+
System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Child 2", new System.Windows.Forms.TreeNode[] {
|
35
|
+
treeNode2});
|
36
|
+
System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Parent One", new System.Windows.Forms.TreeNode[] {
|
37
|
+
treeNode1,
|
38
|
+
treeNode3});
|
39
|
+
System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Parent Two");
|
40
40
|
this.label1 = new System.Windows.Forms.Label();
|
41
41
|
this.aboutButton = new System.Windows.Forms.Button();
|
42
42
|
this.button1 = new System.Windows.Forms.Button();
|
@@ -72,6 +72,7 @@
|
|
72
72
|
this.buttonDataGridView = new System.Windows.Forms.Button();
|
73
73
|
this.automatableMonthCalendar1 = new System.Windows.Forms.MonthCalendar();
|
74
74
|
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
|
75
|
+
this.addSomeFruitsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
75
76
|
this.groupBox1.SuspendLayout();
|
76
77
|
this.groupBox2.SuspendLayout();
|
77
78
|
this.menuStrip1.SuspendLayout();
|
@@ -356,7 +357,8 @@
|
|
356
357
|
//
|
357
358
|
this.faileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
358
359
|
this.aboutToolStripMenuItem,
|
359
|
-
this.roundaboutWayToolStripMenuItem
|
360
|
+
this.roundaboutWayToolStripMenuItem,
|
361
|
+
this.addSomeFruitsToolStripMenuItem});
|
360
362
|
this.faileToolStripMenuItem.Name = "faileToolStripMenuItem";
|
361
363
|
this.faileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
362
364
|
this.faileToolStripMenuItem.Text = "&File";
|
@@ -395,19 +397,19 @@
|
|
395
397
|
//
|
396
398
|
this.treeView.Location = new System.Drawing.Point(490, 285);
|
397
399
|
this.treeView.Name = "treeView";
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
400
|
+
treeNode1.Name = "Child 1";
|
401
|
+
treeNode1.Text = "Child 1";
|
402
|
+
treeNode2.Name = "Grandchild 1";
|
403
|
+
treeNode2.Text = "Grandchild 1";
|
404
|
+
treeNode3.Name = "Child 2";
|
405
|
+
treeNode3.Text = "Child 2";
|
406
|
+
treeNode4.Name = "Parent One";
|
407
|
+
treeNode4.Text = "Parent One";
|
408
|
+
treeNode5.Name = "Parent Two";
|
409
|
+
treeNode5.Text = "Parent Two";
|
408
410
|
this.treeView.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
|
409
|
-
|
410
|
-
|
411
|
+
treeNode4,
|
412
|
+
treeNode5});
|
411
413
|
this.treeView.Size = new System.Drawing.Size(159, 177);
|
412
414
|
this.treeView.TabIndex = 16;
|
413
415
|
//
|
@@ -435,6 +437,13 @@
|
|
435
437
|
this.automatableMonthCalendar1.Name = "automatableMonthCalendar1";
|
436
438
|
this.automatableMonthCalendar1.TabIndex = 19;
|
437
439
|
//
|
440
|
+
// addSomeFruitsToolStripMenuItem
|
441
|
+
//
|
442
|
+
this.addSomeFruitsToolStripMenuItem.Name = "addSomeFruitsToolStripMenuItem";
|
443
|
+
this.addSomeFruitsToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
|
444
|
+
this.addSomeFruitsToolStripMenuItem.Text = "Add Some Fruits";
|
445
|
+
this.addSomeFruitsToolStripMenuItem.Click += new System.EventHandler(this.addSomeFruitsToolStripMenuItem_Click);
|
446
|
+
//
|
438
447
|
// MainFormWindow
|
439
448
|
//
|
440
449
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
@@ -511,7 +520,8 @@
|
|
511
520
|
private System.Windows.Forms.TextBox multiLineTextField;
|
512
521
|
private System.Windows.Forms.Button buttonDataGridView;
|
513
522
|
private System.Windows.Forms.MonthCalendar automatableMonthCalendar1;
|
514
|
-
private System.Windows.Forms.ToolTip toolTip1;
|
523
|
+
private System.Windows.Forms.ToolTip toolTip1;
|
524
|
+
private System.Windows.Forms.ToolStripMenuItem addSomeFruitsToolStripMenuItem;
|
515
525
|
}
|
516
526
|
}
|
517
527
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
using System;
|
2
|
+
using System.Collections.Generic;
|
3
|
+
using System.Linq;
|
2
4
|
using System.Windows.Forms;
|
3
5
|
using UIA.Extensions;
|
4
6
|
|
@@ -74,7 +76,34 @@ namespace WindowsForms
|
|
74
76
|
|
75
77
|
private void FruitListBox_SelectedIndexChanged(object sender, EventArgs e)
|
76
78
|
{
|
77
|
-
|
79
|
+
var selectedFruits = (FruitListBox.SelectedItems.Cast<object>().Select(item => item.ToString()));
|
80
|
+
fruitsLabel.Text = String.Join(",", selectedFruits);
|
81
|
+
}
|
82
|
+
|
83
|
+
private void addSomeFruitsToolStripMenuItem_Click(object sender, EventArgs e)
|
84
|
+
{
|
85
|
+
10.Times(AddAnotherFruit);
|
86
|
+
}
|
87
|
+
|
88
|
+
private void AddAnotherFruit(int fruitNumber)
|
89
|
+
{
|
90
|
+
FruitListBox.Items.Add("Fruit " + fruitNumber);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
static class EnumerableExtensions
|
95
|
+
{
|
96
|
+
public static void ForEach<T>(this IEnumerable<T> items, Action<T> doIt)
|
97
|
+
{
|
98
|
+
foreach (var item in items)
|
99
|
+
{
|
100
|
+
doIt(item);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
public static void Times(this int howMany, Action<int> doIt)
|
105
|
+
{
|
106
|
+
Enumerable.Range(0, howMany).ForEach(doIt);
|
78
107
|
}
|
79
108
|
}
|
80
109
|
}
|
@@ -24,11 +24,11 @@ module RAutomation
|
|
24
24
|
UiaDll::select_list_select_index @select_list.search_information, @index
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
def clear
|
28
|
+
UiaDll::remove_from_selection @select_list.search_information, @index
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
UiaDll::select_list_select_value(search_information, value)
|
31
|
+
alias_method :set, :select
|
32
32
|
end
|
33
33
|
|
34
34
|
def options(options = {})
|
@@ -50,6 +50,10 @@ module RAutomation
|
|
50
50
|
UiaDll::selection(search_information)
|
51
51
|
end
|
52
52
|
|
53
|
+
def values
|
54
|
+
UiaDll::selections(search_information)
|
55
|
+
end
|
56
|
+
|
53
57
|
def option(options)
|
54
58
|
UiaDll::select_options(search_information).each_with_index do |item, item_no|
|
55
59
|
return SelectListOption.new(self, item, item_no) if options[:text] == item
|
@@ -58,10 +62,6 @@ module RAutomation
|
|
58
62
|
nil
|
59
63
|
end
|
60
64
|
|
61
|
-
def select(index)
|
62
|
-
UiaDll::select_list_select_index search_information, index
|
63
|
-
end
|
64
|
-
|
65
65
|
def exist?
|
66
66
|
super && matches_type?(Constants::UIA_COMBOBOX_CONTROL_TYPE)
|
67
67
|
end
|
@@ -50,6 +50,18 @@ module RAutomation
|
|
50
50
|
@locators[:index] || 0
|
51
51
|
end
|
52
52
|
|
53
|
+
def select
|
54
|
+
UiaDll::table_select search_information, row
|
55
|
+
end
|
56
|
+
|
57
|
+
def selected?
|
58
|
+
UiaDll::table_row_is_selected search_information, row
|
59
|
+
end
|
60
|
+
|
61
|
+
def clear
|
62
|
+
UiaDll::table_remove_from_selection search_information, row
|
63
|
+
end
|
64
|
+
|
53
65
|
def value
|
54
66
|
UiaDll::table_value_at search_information, @locators[:index]
|
55
67
|
end
|
@@ -96,14 +108,6 @@ module RAutomation
|
|
96
108
|
all_strings
|
97
109
|
end
|
98
110
|
|
99
|
-
def select(which_item)
|
100
|
-
UiaDll::table_select search_information, which_item
|
101
|
-
end
|
102
|
-
|
103
|
-
def selected?(which_item)
|
104
|
-
UiaDll::table_row_is_selected search_information, which_item
|
105
|
-
end
|
106
|
-
|
107
111
|
def row_count
|
108
112
|
UiaDll::table_row_count search_information
|
109
113
|
end
|
@@ -185,6 +185,8 @@ module RAutomation
|
|
185
185
|
# Select List methods
|
186
186
|
attach_function :SelectList_Selection,
|
187
187
|
[SearchCriteria.by_ref, :pointer, :int], :void
|
188
|
+
attach_function :SelectList_Selections,
|
189
|
+
[SearchCriteria.by_ref, :pointer], :int
|
188
190
|
attach_function :SelectList_Options,
|
189
191
|
[SearchCriteria.by_ref, :pointer], :int
|
190
192
|
attach_function :select_list_count, :SelectList_Count,
|
@@ -197,6 +199,10 @@ module RAutomation
|
|
197
199
|
[SearchCriteria.by_ref, :int], :bool
|
198
200
|
attach_function :select_list_select_value, :SelectList_SelectValue,
|
199
201
|
[SearchCriteria.by_ref, :pointer], :int
|
202
|
+
attach_function :SelectList_RemoveIndex,
|
203
|
+
[SearchCriteria.by_ref, :int, :pointer, :int], :void
|
204
|
+
attach_function :SelectList_RemoveValue,
|
205
|
+
[SearchCriteria.by_ref, :string, :pointer, :int], :void
|
200
206
|
|
201
207
|
def self.select_options(search_information)
|
202
208
|
strings_from(:SelectList_Options, search_information)
|
@@ -206,6 +212,19 @@ module RAutomation
|
|
206
212
|
string_from(:SelectList_Selection, search_information)
|
207
213
|
end
|
208
214
|
|
215
|
+
def self.selections(search_information)
|
216
|
+
strings_from(:SelectList_Selections, search_information)
|
217
|
+
end
|
218
|
+
|
219
|
+
def self.remove_from_selection(search_information, which_item)
|
220
|
+
case which_item
|
221
|
+
when Fixnum
|
222
|
+
can_throw(:SelectList_RemoveIndex, search_information, which_item)
|
223
|
+
when String
|
224
|
+
can_throw(:SelectList_RemoveValue, search_information, which_item)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
209
228
|
# Spinner methods
|
210
229
|
attach_function :Spinner_GetValue,
|
211
230
|
[SearchCriteria.by_ref, :pointer, :int], :double
|
@@ -290,18 +309,22 @@ module RAutomation
|
|
290
309
|
attach_function :Table_ValueAt,
|
291
310
|
[SearchCriteria.by_ref, :int, :int, :pointer, :int], :void
|
292
311
|
attach_function :Table_SelectByIndex,
|
293
|
-
[SearchCriteria.by_ref, :int], :void
|
312
|
+
[SearchCriteria.by_ref, :int, :pointer, :int], :void
|
294
313
|
attach_function :Table_SelectByValue,
|
295
|
-
[SearchCriteria.by_ref, :string], :void
|
314
|
+
[SearchCriteria.by_ref, :string, :pointer, :int], :void
|
296
315
|
attach_function :table_row_is_selected, :Table_IsSelectedByIndex,
|
297
316
|
[SearchCriteria.by_ref, :int], :bool
|
317
|
+
attach_function :Table_RemoveRowByIndex,
|
318
|
+
[SearchCriteria.by_ref, :int, :pointer, :int], :void
|
319
|
+
attach_function :Table_RemoveRowByValue,
|
320
|
+
[SearchCriteria.by_ref, :string, :pointer, :int], :void
|
298
321
|
|
299
322
|
def self.table_select(search_information, which_item)
|
300
323
|
case which_item
|
301
324
|
when Integer
|
302
|
-
Table_SelectByIndex search_information, which_item
|
325
|
+
can_throw(:Table_SelectByIndex, search_information, which_item)
|
303
326
|
when String
|
304
|
-
Table_SelectByValue search_information, which_item
|
327
|
+
can_throw(:Table_SelectByValue, search_information, which_item)
|
305
328
|
end
|
306
329
|
end
|
307
330
|
|
@@ -321,6 +344,15 @@ module RAutomation
|
|
321
344
|
strings_from :Table_GetValues, search_information
|
322
345
|
end
|
323
346
|
|
347
|
+
def self.table_remove_from_selection(search_information, which_row)
|
348
|
+
case which_row
|
349
|
+
when Fixnum
|
350
|
+
can_throw(:Table_RemoveRowByIndex, search_information, which_row)
|
351
|
+
when String
|
352
|
+
can_throw(:Table_RemoveRowByValue, search_information, which_row)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
324
356
|
# String methods
|
325
357
|
attach_function :clean_up_strings, :String_CleanUp,
|
326
358
|
[:pointer, :int], :void
|
@@ -30,12 +30,12 @@ describe "MsUia::Button", :if => SpecHelper.adapter == :ms_uia do
|
|
30
30
|
|
31
31
|
it "cannot click disabled button" do
|
32
32
|
window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
|
33
|
-
|
33
|
+
expect { window.button(:id => "disabledButton").click }.to raise_error
|
34
34
|
end
|
35
35
|
|
36
36
|
it "cannot set focus to disabled button" do
|
37
37
|
window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
|
38
|
-
|
38
|
+
expect { window.button(:id => "disabledButton").focus }.to raise_error
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -46,9 +46,9 @@ describe "MsUia::Checkbox", :if => SpecHelper.adapter == :ms_uia do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "cannot check a disabled checkbox" do
|
49
|
-
|
49
|
+
expect {
|
50
50
|
RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBoxDisabled").set
|
51
|
-
}.
|
51
|
+
}.to raise_error
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -1,32 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "MsUia::ListBox", :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
let(:window) { RAutomation::Window.new(:title => "MainFormWindow") }
|
5
|
+
let(:label) { window.label(:id => "fruitsLabel") }
|
6
|
+
let(:list_box) { window.list_box(:id => "FruitListBox") }
|
4
7
|
|
5
8
|
it "#exists" do
|
6
|
-
|
9
|
+
list_box.should exist
|
7
10
|
end
|
8
11
|
|
9
12
|
it "checks for ListBox class" do
|
10
|
-
|
11
|
-
|
13
|
+
window.list_box(:id => "textField").should_not exist
|
14
|
+
list_box.should exist
|
12
15
|
end
|
13
16
|
|
14
17
|
it "counts items" do
|
15
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
16
18
|
list_box.count.should == 3
|
17
19
|
end
|
18
20
|
|
19
21
|
it "lists items" do
|
20
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
21
|
-
|
22
22
|
list_box.items[0].value.should == "Apple"
|
23
23
|
list_box.items[1].value.should == "Orange"
|
24
24
|
list_box.items[2].value.should == "Mango"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns a value" do
|
28
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
29
|
-
|
30
28
|
list_box.value.should == ""
|
31
29
|
list_box.select(0)
|
32
30
|
list_box.value.should == "Apple"
|
@@ -37,16 +35,12 @@ describe "MsUia::ListBox", :if => SpecHelper.adapter == :ms_uia do
|
|
37
35
|
end
|
38
36
|
|
39
37
|
it "#selected?" do
|
40
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
41
|
-
|
42
38
|
list_box.selected?(2).should == false
|
43
39
|
list_box.select(2)
|
44
40
|
list_box.selected?(2).should == true
|
45
41
|
end
|
46
42
|
|
47
43
|
it "#select" do
|
48
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
49
|
-
|
50
44
|
list_box.select(1)
|
51
45
|
list_box.selected?(1).should == true
|
52
46
|
|
@@ -58,18 +52,22 @@ describe "MsUia::ListBox", :if => SpecHelper.adapter == :ms_uia do
|
|
58
52
|
end
|
59
53
|
|
60
54
|
it "#strings" do
|
61
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
62
|
-
|
63
55
|
list_box.strings.should == ["Apple", "Orange", "Mango"]
|
64
56
|
end
|
65
57
|
|
66
58
|
it "fires events when the index changes" do
|
67
|
-
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
68
|
-
label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
|
69
|
-
|
70
59
|
['Apple', 'Orange', 'Mango'].each_with_index do |value, index|
|
71
60
|
list_box.select index
|
72
61
|
label.value.should eq(value)
|
73
62
|
end
|
74
63
|
end
|
64
|
+
|
65
|
+
it 'fires events even when the item is not in the current view' do
|
66
|
+
window.menu(text: 'File').menu(text: 'Add Some Fruits').open
|
67
|
+
|
68
|
+
list_box.strings.each_with_index do |value, index|
|
69
|
+
list_box.select index
|
70
|
+
label.value.should eq(value)
|
71
|
+
end
|
72
|
+
end
|
75
73
|
end
|
@@ -34,6 +34,6 @@ describe "MsUia::RadioButton", :if => SpecHelper.adapter == :ms_uia do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "cannot set a disabled radio button" do
|
37
|
-
|
37
|
+
expect { RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").set }.to raise_error
|
38
38
|
end
|
39
39
|
end
|
@@ -1,101 +1,103 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
3
|
+
describe 'MsUia::SelectList', :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
let(:window) { RAutomation::Window.new(:title => 'MainFormWindow') }
|
5
|
+
let(:fruits_combo) { window.select_list(:id => 'FruitsComboBox') }
|
6
|
+
let(:fruits_list) { window.select_list(:id => 'FruitListBox') }
|
7
|
+
let(:fruit_label) { window.label(:id => 'fruitsLabel') }
|
8
|
+
let(:disabled_combo) { window.select_list(:id => 'comboBoxDisabled') }
|
9
|
+
let(:about) do
|
10
|
+
window.button(:value => 'About').click { true }
|
11
|
+
about = RAutomation::Window.new(:title => 'About')
|
12
|
+
end
|
13
|
+
let(:multi_fruits) do
|
14
|
+
about.tab_control(:id => 'tabControl').set 'Multi-Select ListBox'
|
15
|
+
about.select_list(:id => 'multiFruitListBox')
|
16
|
+
end
|
17
|
+
|
18
|
+
it '#fruits_combo' do
|
19
|
+
fruits_combo.should exist
|
6
20
|
|
7
21
|
RAutomation::Window.wait_timeout = 0.1
|
8
|
-
expect {RAutomation::Window.new(:title =>
|
22
|
+
expect {RAutomation::Window.new(:title => 'non-existent-window').
|
9
23
|
select_list(:class => /COMBOBOX/i)}.
|
10
24
|
to raise_exception(RAutomation::UnknownWindowException)
|
11
25
|
end
|
12
26
|
|
13
|
-
it
|
14
|
-
|
15
|
-
|
27
|
+
it 'check for select list class' do
|
28
|
+
window.select_list(:id => 'textField').should_not exist
|
29
|
+
fruits_combo.should exist
|
16
30
|
end
|
17
31
|
|
18
|
-
it
|
19
|
-
|
20
|
-
select_list.options.size.should == 5
|
21
|
-
|
22
|
-
expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
|
23
|
-
select_list.options.map {|option| option.text}.should == expected_options
|
24
|
-
end
|
32
|
+
it '#options' do
|
33
|
+
fruits_combo.options.size.should == 5
|
25
34
|
|
26
|
-
|
27
|
-
|
28
|
-
select_list.options(:text => "Apple")[0].should_not be_selected
|
29
|
-
select_list.options(:text => "Apple")[0].select.should be_true
|
30
|
-
select_list.options(:text => "Apple")[0].should be_selected
|
35
|
+
expected_options = ['Apple', 'Caimito', 'Coconut', 'Orange', 'Passion Fruit']
|
36
|
+
fruits_combo.options.map {|option| option.text}.should == expected_options
|
31
37
|
end
|
32
38
|
|
33
|
-
it
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
select_list.options(:text => "Apple")[0].should be_selected
|
39
|
+
it '#selected? & #select' do
|
40
|
+
fruits_combo.options(:text => 'Apple')[0].should_not be_selected
|
41
|
+
fruits_combo.options(:text => 'Apple')[0].select.should be_true
|
42
|
+
fruits_combo.options(:text => 'Apple')[0].should be_selected
|
38
43
|
end
|
39
44
|
|
40
|
-
it
|
41
|
-
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
45
|
+
it '#value' do
|
42
46
|
|
43
47
|
#default empty state
|
44
|
-
|
48
|
+
fruits_combo.value.should == ''
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
fruits_combo.options(:text => 'Apple')[0].select
|
51
|
+
fruits_combo.value.should == 'Apple'
|
48
52
|
|
49
|
-
|
50
|
-
|
53
|
+
fruits_combo.options(:text => 'Caimito')[0].select
|
54
|
+
fruits_combo.value.should == 'Caimito'
|
51
55
|
end
|
52
56
|
|
53
|
-
it
|
54
|
-
|
55
|
-
|
57
|
+
it 'enabled/disabled' do
|
58
|
+
fruits_combo.should be_enabled
|
59
|
+
fruits_combo.should_not be_disabled
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
disabled_combo.should_not be_enabled
|
62
|
+
disabled_combo.should be_disabled
|
59
63
|
end
|
60
64
|
|
61
|
-
it
|
62
|
-
|
65
|
+
it '#values' do
|
66
|
+
multi_fruits.values.should eq([]) # => empty state
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
['Apple', 'Mango'].each do |value|
|
69
|
+
multi_fruits.option(:text => value).select
|
70
|
+
end
|
71
|
+
multi_fruits.values.should eq(['Apple', 'Mango'])
|
67
72
|
end
|
68
73
|
|
69
|
-
it
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
it '#option' do
|
75
|
+
fruits_combo.option(:text => 'Apple').should_not be_selected
|
76
|
+
fruits_combo.option(:text => 'Apple').set
|
77
|
+
fruits_combo.option(:text => 'Apple').should be_selected
|
73
78
|
end
|
74
79
|
|
75
|
-
it
|
76
|
-
|
77
|
-
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
78
|
-
|
79
|
-
select_list.option(:text => "Apple").should_not be_selected
|
80
|
-
select_list.set("Apple")
|
81
|
-
select_list.option(:text => "Apple").should be_selected
|
82
|
-
|
83
|
-
label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
|
84
|
-
RAutomation::WaitHelper.wait_until { label.exist? }
|
85
|
-
label.value.should == "Apple"
|
80
|
+
it 'cannot select anything on a disabled select list' do
|
81
|
+
expect { disabled_combo.option(:text => 'Apple').set }.to raise_error
|
86
82
|
end
|
87
83
|
|
88
|
-
it
|
84
|
+
it 'fires change event when the value is set' do
|
85
|
+
apple_option = fruits_combo.option(:text => 'Apple')
|
86
|
+
apple_option.should_not be_selected
|
87
|
+
apple_option.select
|
88
|
+
apple_option.should be_selected
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
RAutomation::WaitHelper.wait_until { fruit_label.exist? }
|
91
|
+
fruit_label.value.should == 'Apple'
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
it 'fires change event when the index changes' do
|
95
|
+
fruits_combo.options[4].select
|
96
|
+
fruits_combo.option(:text => 'Passion Fruit').should be_selected
|
97
|
+
fruit_label.value.should == 'Passion Fruit'
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
fruits_combo.options[3].select
|
100
|
+
fruits_combo.option(:text => 'Orange').should be_selected
|
101
|
+
fruit_label.value.should == 'Orange'
|
100
102
|
end
|
101
103
|
end
|