bewildr 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,107 @@
1
+ =bewildr
2
+ Test WPF apps in (iron) ruby!
3
+
4
+ Written by Nat Ritmeyer (http://www.natontesting.com)
5
+
6
+ ==Intro
7
+ <b>This is pre-alpha software - it has a way to go before being complete...</b>
8
+
9
+ Documentation is on the way; until then, take a look at the tests or read the API overview below.
10
+
11
+ ==Getting started
12
+ ===Installation
13
+
14
+ Install the latest ironruby (http://www.ironruby.net/), and for your own sanity install it in c:\\\\ironruby instead of the default location.
15
+
16
+ <tt>
17
+ gem install bewildr
18
+ </tt>
19
+
20
+ You'll need at least rubygems version 1.3.6 (gem update --system)
21
+
22
+ ===API Overview
23
+
24
+ <b>Start an app</b>
25
+
26
+ <tt>@app = Bewildr::Application.start('notepad')</tt>
27
+
28
+ <tt>@app = Bewildr::Application.start('c:/windows/notepad.exe')</tt>
29
+
30
+ <b>Start an app and wait for a particular window:</b>
31
+
32
+ <tt>@app, @window = Bewildr::Application.start_app_and_wait_for_window('notepad', 'Untitled - Notepad')</tt>
33
+
34
+ or (taking a regex for the window title instead of a string - tests become more robust):
35
+
36
+ <tt>@app, @window = Bewildr::Application.start_app_and_wait_for_window('c:/windows/notepad.exe', /.* - Notepad/)</tt>
37
+
38
+ <b>kill an app</b>
39
+
40
+
41
+ <tt>@app.kill</tt>
42
+
43
+ <tt>@app.running? == false</tt>
44
+
45
+ <tt>@app.should_not be_running</tt>
46
+
47
+ <b>Get application windows:</b>
48
+
49
+ All windows belonging to an app:
50
+
51
+ <tt>@all_windows_for_my_app = @app.get_windows</tt>
52
+
53
+ Window with a particular name:
54
+
55
+ <tt>@main_window = @app.get_window('My App 1.0')</tt>
56
+
57
+ Window with a particular name (find window using regex instead of string):
58
+
59
+ <tt>@main_window = @app.get_window(/My App .*/)</tt>
60
+
61
+ <b>Find an element by its automation id:</b>
62
+
63
+ <tt>my_button = @window.get(:id => 'my_button')</tt>
64
+
65
+ <b>Find an element by its type:</b>
66
+
67
+ <tt>@all_buttons = @window.get(:type => :button)</tt>
68
+
69
+ <b>Find an element by its name:</b>
70
+
71
+ <tt>my_button = @window.get(:name => 'Click Here')</tt>
72
+
73
+ <b>Find an element by a combination of criteria:</b>
74
+
75
+ <tt>@main_window.get(:type => :hyperlink, :name => "Link Text")</tt>
76
+
77
+ <b>Click a button:</b>
78
+
79
+ <tt>@window.get(:id => 'my_button').click</tt>
80
+
81
+ <b>Check for existence/enabled state of an element:</b>
82
+
83
+ <tt>@window.get(:id => 'some_element').exists?</tt>
84
+
85
+ <tt>@window.get(:id => 'some_element').enabled?</tt>
86
+
87
+ ...which allows for some nice idiomatic test code if you're using rspec:
88
+
89
+ <tt>@window.get(:id => 'some_element').should_not exist</tt>
90
+
91
+ <tt>@window.get(:id => 'some_element').should be_enabled</tt>
92
+
93
+ ==Background story
94
+ I've recently been testing a WPF app using ironruby and the White automation library
95
+ (see http://www.natontesting.com/2010/02/17/how-to-test-a-wpf-app-using-ironruby-and-white/
96
+ for an example of my adventures). White proved to be buggy, painful and worst of all, slow.
97
+ The whole time I was writing the framework and the tests, I wanted a replacement for white -
98
+ something written in ruby, something that talked directly to MS Automation, something that
99
+ had a simple architecture (trying to figure out what's going in in white is not trivial) and
100
+ something that could be used to write idiomatic tests (using rspec matchers).
101
+
102
+ Thus, Bewildr. "Scratch your own itch", and all that.
103
+
104
+ Why 'bewildr'? Quite simply, I have been bewildrd for the whole journey. Bewildrd by white,
105
+ bewildrd by Microsoft's automation architecture (which turns out, in fact, to be very well
106
+ thought out - it just required a mind-shift, that's all) and bewildrd as a result of the
107
+ recent late nights writing bewildr.
data/Rakefile CHANGED
@@ -10,15 +10,15 @@ require 'cucumber/rake/task'
10
10
 
11
11
  spec = Gem::Specification.new do |s|
12
12
  s.name = 'bewildr'
13
- s.version = '0.1'
13
+ s.version = '0.1.1'
14
14
  s.has_rdoc = true
15
- s.extra_rdoc_files = ['README', 'LICENSE']
15
+ s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
16
16
  s.summary = 'Test your WPF apps with (iron) ruby!'
17
17
  s.description = s.summary
18
18
  s.author = 'Nat Ritmeyer'
19
19
  s.email = 'nat@natontesting.com'
20
20
  s.homepage = 'http://github.com/natritmeyer/bewildr'
21
- s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib}/**/*")
21
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{bin,lib}/**/*")
22
22
  s.require_path = "lib"
23
23
  s.bindir = "bin"
24
24
  end
@@ -30,9 +30,9 @@ Rake::GemPackageTask.new(spec) do |p|
30
30
  end
31
31
 
32
32
  Rake::RDocTask.new do |rdoc|
33
- files =['README', 'LICENSE', 'lib/**/*.rb']
33
+ files =['README.rdoc', 'LICENSE', 'lib/**/*.rb']
34
34
  rdoc.rdoc_files.add(files)
35
- rdoc.main = "README" # page to start on
35
+ rdoc.main = "README.rdoc" # page to start on
36
36
  rdoc.title = "bewildr Docs"
37
37
  rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
38
38
  rdoc.options << '--line-numbers'
@@ -21,7 +21,7 @@ module Bewildr
21
21
  @automation_element.current.name.to_s
22
22
  end
23
23
 
24
- def id
24
+ def automation_id
25
25
  existence_check
26
26
  @automation_element.current.automation_id.to_s
27
27
  end
@@ -52,6 +52,19 @@ module Bewildr
52
52
  @automation_element.current.is_enabled
53
53
  end
54
54
 
55
+ def wait_for_existence_of(condition_hash)
56
+ Timeout.timeout(30) do
57
+ sleep 0.1 until contains?(condition_hash)
58
+ end
59
+ get(condition_hash)
60
+ end
61
+
62
+ def wait_for_non_existence_of(condition_hash)
63
+ Timeout.timeout(30) do
64
+ sleep 0.1 unless contains?(condition_hash)
65
+ end
66
+ end
67
+
55
68
  #:id => "id"
56
69
  #:name => "bob"
57
70
  #:type => :button
Binary file
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- version: "0.1"
8
+ - 1
9
+ version: 0.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Nat Ritmeyer
@@ -13,7 +14,7 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-04-20 00:00:00 +01:00
17
+ date: 2010-04-29 00:00:00 +01:00
17
18
  default_executable:
18
19
  dependencies: []
19
20
 
@@ -24,11 +25,11 @@ executables: []
24
25
  extensions: []
25
26
 
26
27
  extra_rdoc_files:
27
- - README
28
+ - README.rdoc
28
29
  - LICENSE
29
30
  files:
30
31
  - LICENSE
31
- - README
32
+ - README.rdoc
32
33
  - Rakefile
33
34
  - lib/bewildr/application.rb
34
35
  - lib/bewildr/bewildr_helpers.rb
data/README DELETED
@@ -1,8 +0,0 @@
1
- == bewildr
2
- Test WPF apps in (iron) ruby!
3
-
4
- This is pre-alpha software - it has a way to go before being useable...
5
-
6
- Documentation is on the way...
7
-
8
- Nat Ritmeyer