vapir-firefox 1.7.2 → 1.8.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.
- data/lib/vapir-firefox/{firefox.rb → browser.rb} +358 -145
- data/lib/vapir-firefox/clear_tracks.rb +50 -0
- data/lib/vapir-firefox/config.rb +17 -0
- data/lib/vapir-firefox/container.rb +67 -1
- data/lib/vapir-firefox/element.rb +62 -38
- data/lib/vapir-firefox/jssh_socket.rb +527 -206
- data/lib/vapir-firefox/page_container.rb +44 -19
- data/lib/vapir-firefox/version.rb +1 -1
- data/lib/vapir-firefox/window.rb +2 -2
- data/lib/vapir-firefox.rb +2 -5
- metadata +11 -32
@@ -5,32 +5,56 @@ module Vapir
|
|
5
5
|
module Firefox::PageContainer
|
6
6
|
include Vapir::PageContainer
|
7
7
|
include Firefox::Container
|
8
|
-
|
9
|
-
# document_object.parentWindow
|
10
|
-
#end
|
8
|
+
|
11
9
|
def text
|
12
10
|
document_element.textContent
|
13
11
|
end
|
14
12
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
13
|
+
# evaluates a given javascript string in the context of the browser's content window. anything
|
14
|
+
# that is a top-level variable on the window will be seen as a top-level variable in the
|
15
|
+
# evaluated script.
|
16
|
+
#
|
17
|
+
# returns the last evaluated expression.
|
18
|
+
#
|
19
|
+
# raises an error if the given javascript errors.
|
20
|
+
#
|
21
|
+
# you may specify a hash of other variables that will be available in your script. for example:
|
22
|
+
#
|
23
|
+
# >> browser.execute_script("element.tagName + ' ' + foo", :element => browser.buttons.first.element_object, :foo => "baz")
|
24
|
+
# => "BUTTON baz"
|
25
|
+
#
|
26
|
+
# note, however, that if the name of the variable that you use is the same as a variable on the
|
27
|
+
# window, the window's variable is what will be in scope. for example:
|
28
|
+
#
|
29
|
+
# >> browser.execute_script("typeof document", :document => "a string")
|
30
|
+
# => "object"
|
31
|
+
#
|
32
|
+
# the type is 'object' (not 'string') because window.document is what is seen in the scope.
|
33
|
+
#
|
34
|
+
# this function is most useful if you need to execute javascript that is only allowed to run in
|
35
|
+
# the context of the content window. one example of this is Flash objects - if you try to access
|
36
|
+
# their methods from the top-level context, you get an exception:
|
37
|
+
#
|
38
|
+
# >> browser.element(:tag_name => 'embed').element_object.PercentLoaded()
|
39
|
+
# JsshError::Error: NPMethod called on non-NPObject wrapped JSObject!
|
40
|
+
#
|
41
|
+
# but, this method executes script in the context of the content window, so the following works:
|
42
|
+
#
|
43
|
+
# >> browser.execute_script('element.PercentLoaded()', :element => browser.element(:tag_name => 'embed').element_object)
|
44
|
+
# => 100
|
45
|
+
def execute_script(javascript, other_variables={})
|
46
|
+
sandbox=jssh_socket.Components.utils.Sandbox(content_window_object)
|
47
|
+
sandbox.window=content_window_object.window
|
48
|
+
other_variables.each do |name, var|
|
49
|
+
sandbox[name]=var
|
50
|
+
end
|
51
|
+
return jssh_socket.Components.utils.evalInSandbox('with(window) { '+javascript+' }', sandbox)
|
28
52
|
end
|
29
53
|
|
30
54
|
# Returns the html of the document
|
31
55
|
def outer_html
|
32
|
-
jssh_socket.
|
33
|
-
|
56
|
+
jssh_socket.call_function(:document => document_object) do %Q(
|
57
|
+
var temp_el=document.createElement('div');
|
34
58
|
for(var i in document.childNodes)
|
35
59
|
{ try
|
36
60
|
{ temp_el.appendChild(document.childNodes[i].cloneNode(true));
|
@@ -39,7 +63,8 @@ module Vapir
|
|
39
63
|
{}
|
40
64
|
}
|
41
65
|
return temp_el.innerHTML;
|
42
|
-
|
66
|
+
)
|
67
|
+
end
|
43
68
|
end
|
44
69
|
alias html outer_html
|
45
70
|
end
|
data/lib/vapir-firefox/window.rb
CHANGED
@@ -11,7 +11,7 @@ module Vapir
|
|
11
11
|
# returns an instance of WinWindow representing this window.
|
12
12
|
# (MS Windows only)
|
13
13
|
def win_window
|
14
|
-
|
14
|
+
Vapir.require_winwindow
|
15
15
|
@win_window||=begin
|
16
16
|
orig_browser_window_title=browser_window_object.document.title
|
17
17
|
browser_window_object.document.title=orig_browser_window_title+(rand(36**16).to_s(36))
|
@@ -32,7 +32,7 @@ module Vapir
|
|
32
32
|
end
|
33
33
|
# sets this window as the foreground window (MS Windows only)
|
34
34
|
def bring_to_front
|
35
|
-
win_window.
|
35
|
+
win_window.really_set_foreground!
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/vapir-firefox.rb
CHANGED
@@ -6,10 +6,7 @@ module Vapir
|
|
6
6
|
Firefox = Class.new(Vapir::Browser)
|
7
7
|
end
|
8
8
|
|
9
|
-
require 'vapir-firefox/
|
9
|
+
require 'vapir-firefox/config'
|
10
|
+
require 'vapir-firefox/browser'
|
10
11
|
require 'vapir-firefox/elements'
|
11
12
|
require 'vapir-firefox/version'
|
12
|
-
|
13
|
-
# this only has an effect if firewatir is required before anyone invokes
|
14
|
-
# Browser.new. Thus it has no effect when Browser.new itself autoloads this library.
|
15
|
-
Vapir::Browser.default = 'firefox'
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vapir-firefox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 15
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
7
|
+
- 8
|
8
|
+
- 0
|
9
|
+
version: 1.8.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Ethan
|
@@ -15,53 +14,35 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-
|
17
|
+
date: 2011-04-19 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: vapir-common
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - "="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 15
|
30
27
|
segments:
|
31
28
|
- 1
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version: 1.
|
29
|
+
- 8
|
30
|
+
- 0
|
31
|
+
version: 1.8.0
|
35
32
|
type: :runtime
|
36
33
|
version_requirements: *id001
|
37
34
|
- !ruby/object:Gem::Dependency
|
38
35
|
name: json
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ">="
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
41
|
segments:
|
47
42
|
- 0
|
48
43
|
version: "0"
|
49
44
|
type: :runtime
|
50
45
|
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: activesupport
|
53
|
-
prerelease: false
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
63
|
-
type: :runtime
|
64
|
-
version_requirements: *id003
|
65
46
|
description: " Vapir-Firefox is a library to programatically drive the Firefox\n browser over the JSSH Firefox extension, exposing a simple-to-use \n and powerful API to make automated testing a simple and joyous affair. \n Forked from the Watir library. \n"
|
66
47
|
email: vapir@googlegroups.com
|
67
48
|
executables: []
|
@@ -78,7 +59,8 @@ files:
|
|
78
59
|
- lib/vapir/firefox.rb
|
79
60
|
- lib/vapir/ff.rb
|
80
61
|
- lib/vapir-firefox/version.rb
|
81
|
-
- lib/vapir-firefox/
|
62
|
+
- lib/vapir-firefox/config.rb
|
63
|
+
- lib/vapir-firefox/browser.rb
|
82
64
|
- lib/vapir-firefox/container.rb
|
83
65
|
- lib/vapir-firefox/page_container.rb
|
84
66
|
- lib/vapir-firefox/window.rb
|
@@ -101,6 +83,7 @@ files:
|
|
101
83
|
- lib/vapir-firefox/elements/table_row.rb
|
102
84
|
- lib/vapir-firefox/elements/text_field.rb
|
103
85
|
- lib/vapir-firefox/elements.rb
|
86
|
+
- lib/vapir-firefox/clear_tracks.rb
|
104
87
|
- lib/vapir-firefox/jssh_socket.rb
|
105
88
|
- lib/vapir-firefox/prototype.functional.js
|
106
89
|
has_rdoc: true
|
@@ -118,27 +101,23 @@ rdoc_options:
|
|
118
101
|
require_paths:
|
119
102
|
- lib
|
120
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
104
|
requirements:
|
123
105
|
- - ">="
|
124
106
|
- !ruby/object:Gem::Version
|
125
|
-
hash: 3
|
126
107
|
segments:
|
127
108
|
- 0
|
128
109
|
version: "0"
|
129
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
111
|
requirements:
|
132
112
|
- - ">="
|
133
113
|
- !ruby/object:Gem::Version
|
134
|
-
hash: 3
|
135
114
|
segments:
|
136
115
|
- 0
|
137
116
|
version: "0"
|
138
117
|
requirements:
|
139
118
|
- Firefox browser with JSSH extension installed
|
140
119
|
rubyforge_project:
|
141
|
-
rubygems_version: 1.3.
|
120
|
+
rubygems_version: 1.3.6
|
142
121
|
signing_key:
|
143
122
|
specification_version: 3
|
144
123
|
summary: Library for automating the Firefox browser in Ruby
|