qa_robusta 0.1.5 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,9 @@
1
- === 0.1.4 / 2011-10-01
1
+ === 0.1.6 / 2011-10-01
2
+ * Element now has calls for: in_viewable_area? and scroll_to.
3
+ in_viewable_area? returns true if the element is in the viewable area
4
+ of the browser
5
+ scroll_to scrolls to the element
6
+ === 0.1.5 / 2011-10-01
2
7
  * Cleanup qa_obsever/lib/watir.rb
3
8
  === 0.1.4 / 2011-10-01
4
9
  * Remove common/lib/gem_helpers.rb and add to localized_gems
@@ -18,6 +18,7 @@ remote_unix/lib/ssh.rb
18
18
  remote_unix/lib/postfix_info.rb
19
19
  remote_unix/lib/requires.rb
20
20
  demo/public/javascripts/jquery-1.6.2.min.js
21
+ demo/public/style.css
21
22
  demo/demo_site.rb
22
23
  demo/views/index.erb
23
24
  mechanize_interface/conf/app.yaml
@@ -30,6 +31,7 @@ mechanize_interface/test/lib/mech_unit_test.rb
30
31
  qa_observer/script/generate
31
32
  qa_observer/script/destroy
32
33
  qa_observer/sites/demo/test_cases/home_page.rb
34
+ qa_observer/sites/demo/test_cases/test_element_scroll_to.rb
33
35
  qa_observer/sites/demo/elements/demo_elements.rb
34
36
  qa_observer/sites/demo/conf/base_urls.yaml
35
37
  qa_observer/sites/demo/conf/users_list.yaml
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/cache
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/doc
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/gems
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/cache
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/doc
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/gems
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/specifications
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -1,7 +1,7 @@
1
1
  10
2
2
 
3
3
  dir
4
- 414
4
+ 420
5
5
  file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/specifications
6
6
  file:///home/cliff/l_bkup/svn/repos
7
7
 
@@ -0,0 +1,4 @@
1
+ div#skip_page {
2
+ border: solid 1px;
3
+ height: 800px;
4
+ }
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>Demo Test Page for QA Robusta</title>
5
5
  <script type="text/javascript" src="/javascripts/jquery-1.6.2.min.js"></script>
6
+ <link href="/style.css" rel="stylesheet" type="text/css" />
6
7
  <script type="text/javascript">
7
8
  $(function() {
8
9
  $('input#create_file').click(function() {
@@ -29,7 +30,11 @@
29
30
  <body>
30
31
  <div id='create_file_status'></div>
31
32
  <input type='text' id='create_file_name'>
32
- <input type='button' id='create_file' value='Create Tmp File'>
33
-
33
+ <input type='button' id='create_file' value='Create Tmp File'><br><br>
34
+ <div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div>
35
+ <a href='with_id' id='link_with_id_and_no_name'>with id and no name</a>
36
+ <div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div>
37
+ <a href='with_name' name='link_with_no_id_but_has_name'>with name and no id</a>
38
+ <div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div><div id='skip_page'></div>
34
39
  </body>
35
40
  </html>
@@ -1,3 +1,3 @@
1
1
  class QaRobusta
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -1,15 +1,87 @@
1
- module ImageWrap
1
+ module WatirExtention
2
2
  def self.included(klass)
3
+ image_wrap(klass)
4
+ add_scroll_to(klass)
5
+ add_in_viewable_area?(klass)
6
+ end
7
+
8
+ def self.image_wrap(klass)
3
9
  method = 'click'
4
- klass.class_eval do
10
+ klass.class_eval {
5
11
  original_method = instance_method(method)
6
- define_method(method) do |*args, &block|
12
+ define_method(method) { |*args, &block|
7
13
  TestExtention.screen_shot($current_test_method, 'pre')
8
14
  result = original_method.bind(self).call(*args, &block)
9
15
  TestExtention.screen_shot($current_test_method, 'post')
10
16
  result
11
- end
12
- end
17
+ }
18
+ }
19
+ end
20
+
21
+ def self.add_in_viewable_area?(klass)
22
+ klass.class_eval {
23
+ define_method('in_viewable_area?') { |*args, &block|
24
+ if exists?
25
+ element_location = wd.location
26
+
27
+ # JS borrowed from
28
+ # http://www.geekdaily.net/2007/07/04/javascript-cross-browser-window-size-and-centering/
29
+ script=<<-EOF
30
+ var w = 0;
31
+ var h = 0;
32
+ if(!window.innerWidth) {
33
+ w = window.pageXOffset;h = window.pageYOffset;
34
+ /*
35
+ if(!(document.documentElement.clientWidth == 0)) {
36
+ w = document.documentElement.clientWidth + document.body.scrollLeft;
37
+ h = document.documentElement.clientHeight + document.body.scrollTop;
38
+ //w = document.documentElement.clientWidth + document.body.scrollLeft;
39
+ //h = document.documentElement.clientHeight + document.body.scrollTop;
40
+ } else {
41
+ w = window.pageXOffset;
42
+ h = window.pageYOffset;
43
+ // w = document.body.clientWidth + window.pageXOffset;
44
+ // h = document.body.clientHeight + window.pageYOffset;
45
+ }
46
+ */
47
+ } else { w = window.pageXOffset; h = window.pageYOffset; }
48
+ return {x: h, y: w}
49
+ EOF
50
+ d = driver.execute_script(script)
51
+ element_location.x >= d['y'] && element_location.y <= d['x']
52
+ else
53
+ return false
54
+ end
55
+ }
56
+ }
57
+ end
58
+
59
+ def self.add_scroll_to(klass)
60
+ klass.class_eval {
61
+ define_method('scroll_to') { |*args, &block|
62
+
63
+ if self.id == '' && self.name != ''
64
+ element = "element = document.getElementsByName(\"#{self.name}\")[0];"
65
+ elsif self.id != '' && self.name == ''
66
+ element = "element = document.getElementById(\"#{self.id}\");"
67
+ end
68
+
69
+ if element
70
+ # javascript borrowed from:
71
+ # http://radio.javaranch.com/pascarello/2005/01/09/1105293729000.html
72
+ script=<<-EOF
73
+ function ScrollToElementByID(id){
74
+ #{element} var selectedPosX = 0; var selectedPosY = 0;
75
+ while(element != null) { selectedPosX += element.offsetLeft; selectedPosY += element.offsetTop; element = element.offsetParent; }
76
+ window.scrollTo(selectedPosX,selectedPosY);
77
+ }
78
+ ScrollToElementByID("#{self.id}");
79
+ EOF
80
+ driver.execute_script(script)
81
+ end
82
+ }
83
+ }
84
+
13
85
  end
14
86
  end
15
87
 
@@ -27,7 +99,7 @@ module Watir
27
99
  end
28
100
  end
29
101
  class Element
30
- include ImageWrap
102
+ include WatirExtention
31
103
  end
32
104
  end
33
105
 
@@ -4,6 +4,8 @@ module Demo
4
4
  element(:file_status) {$browser.div(:id, 'create_file_status')}
5
5
  element(:create_file_text_field) {$browser.text_field(:id, 'create_file_name')}
6
6
  element(:submit_create_file) {$browser.button(:id, 'create_file')}
7
+ element(:link_with_id) {$browser.link(:id, 'link_with_id_and_no_name')}
8
+ element(:link_with_name) {$browser.link(:name, 'link_with_no_id_but_has_name')}
7
9
  end
8
10
  end
9
11
  end
@@ -0,0 +1,69 @@
1
+ base = File.expand_path(File.dirname(__FILE__))
2
+
3
+ # If the user is executing the test case stand alone
4
+ # without an agent we need to set a reference to
5
+ # for where to find the qa_observer_client as well as let
6
+ # the qa_observer_client know where the test case directory is
7
+ # URGENT: DO NOT MODIFY
8
+ unless $qa_observer_client
9
+ TEST_CASE_DIR = "#{base}"
10
+ $qa_observer_client = File.expand_path("#{base}/../../..")
11
+ end
12
+ # END OF DO NOT MODIFY
13
+
14
+ require "#{$qa_observer_client}/lib/system_test"
15
+ require "#{$qa_observer_client}/lib/env_details.rb"
16
+
17
+ class TestElementScrollTo < SystemTest
18
+ def setup
19
+ # if the user hasn't provided the environment as an input
20
+ # parameter to the interpreter default to :test
21
+ $test_environment ||= :test
22
+ super
23
+ @demo_flows = DemoFlows.new
24
+ @demo_flows.home
25
+ end
26
+
27
+ def teardown
28
+ # NOTE: Place all items you wish to do at after each test method
29
+ # in the unless @skip section before the $browser.close. DO NOT
30
+ # remove this section as it's critical if the test class is executed
31
+ # by an agent.
32
+ unless @skip
33
+ $browser.close if $browser
34
+ end
35
+
36
+ super
37
+ end
38
+
39
+ =begin rdoc
40
+ Test Purpose: Ensure QA Robusta provides a means to scroll to an element
41
+
42
+ Steps:
43
+ 1. Verify that an element accessed by a name tag is not in the viewable area within the browser
44
+ 2. Scroll to the element from step 1
45
+ 3. Verify that the element is now in the viewable area of the browser
46
+ =end
47
+ def test_scroll_to_element_with_no_id_but_with_name
48
+ assert !@demo_flows.home_page.link_with_name.in_viewable_area?
49
+ @demo_flows.home_page.link_with_name.scroll_to
50
+ assert @demo_flows.home_page.link_with_name.in_viewable_area?
51
+ TestExtention.screen_shot($current_test_method, 'pre')
52
+ end
53
+
54
+ =begin rdoc
55
+ Test Purpose: Ensure QA Robusta provides a means to scroll to an element
56
+
57
+ Steps:
58
+ 1. Verify that an element accessed by an id tag is not in the viewable area within the browser
59
+ 2. Scroll to the element from step 1
60
+ 3. Verify that the element is now in the viewable area of the browser
61
+ =end
62
+ def test_scroll_to_element_with_id_but_no_name
63
+ assert !@demo_flows.home_page.link_with_id.in_viewable_area?
64
+ @demo_flows.home_page.link_with_id.scroll_to
65
+ assert @demo_flows.home_page.link_with_id.in_viewable_area?
66
+ TestExtention.screen_shot($current_test_method, 'pre')
67
+ end
68
+
69
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: qa_robusta
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.5
5
+ version: 0.1.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cliff Cyphers
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-10-04 00:00:00 Z
13
+ date: 2011-10-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: platform_helpers
@@ -115,6 +115,7 @@ files:
115
115
  - remote_unix/lib/postfix_info.rb
116
116
  - remote_unix/lib/requires.rb
117
117
  - demo/public/javascripts/jquery-1.6.2.min.js
118
+ - demo/public/style.css
118
119
  - demo/demo_site.rb
119
120
  - demo/views/index.erb
120
121
  - mechanize_interface/conf/app.yaml
@@ -127,6 +128,7 @@ files:
127
128
  - qa_observer/script/generate
128
129
  - qa_observer/script/destroy
129
130
  - qa_observer/sites/demo/test_cases/home_page.rb
131
+ - qa_observer/sites/demo/test_cases/test_element_scroll_to.rb
130
132
  - qa_observer/sites/demo/elements/demo_elements.rb
131
133
  - qa_observer/sites/demo/conf/base_urls.yaml
132
134
  - qa_observer/sites/demo/conf/users_list.yaml