selenium-webdriver 0.0.1

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.
Files changed (86) hide show
  1. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  2. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  3. data/chrome/src/extension/background.html +9 -0
  4. data/chrome/src/extension/background.js +933 -0
  5. data/chrome/src/extension/content_script.js +1286 -0
  6. data/chrome/src/extension/manifest-nonwin.json +15 -0
  7. data/chrome/src/extension/manifest-win.json +16 -0
  8. data/chrome/src/extension/toolstrip.html +28 -0
  9. data/chrome/src/extension/utils.js +196 -0
  10. data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
  11. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +324 -0
  12. data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +70 -0
  13. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +119 -0
  14. data/common/src/js/abstractcommandprocessor.js +161 -0
  15. data/common/src/js/asserts.js +296 -0
  16. data/common/src/js/by.js +147 -0
  17. data/common/src/js/command.js +274 -0
  18. data/common/src/js/context.js +58 -0
  19. data/common/src/js/extension/README +2 -0
  20. data/common/src/js/extension/dommessenger.js +152 -0
  21. data/common/src/js/factory.js +55 -0
  22. data/common/src/js/future.js +118 -0
  23. data/common/src/js/key.js +117 -0
  24. data/common/src/js/localcommandprocessor.js +181 -0
  25. data/common/src/js/logging.js +249 -0
  26. data/common/src/js/testrunner.js +605 -0
  27. data/common/src/js/timing.js +89 -0
  28. data/common/src/js/wait.js +199 -0
  29. data/common/src/js/webdriver.js +853 -0
  30. data/common/src/js/webelement.js +683 -0
  31. data/common/src/rb/lib/selenium-webdriver.rb +1 -0
  32. data/common/src/rb/lib/selenium/webdriver.rb +52 -0
  33. data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +88 -0
  34. data/common/src/rb/lib/selenium/webdriver/child_process.rb +85 -0
  35. data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
  36. data/common/src/rb/lib/selenium/webdriver/driver.rb +128 -0
  37. data/common/src/rb/lib/selenium/webdriver/element.rb +126 -0
  38. data/common/src/rb/lib/selenium/webdriver/error.rb +68 -0
  39. data/common/src/rb/lib/selenium/webdriver/find.rb +69 -0
  40. data/common/src/rb/lib/selenium/webdriver/navigation.rb +23 -0
  41. data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
  42. data/common/src/rb/lib/selenium/webdriver/platform.rb +82 -0
  43. data/common/src/rb/lib/selenium/webdriver/target_locator.rb +23 -0
  44. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  45. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  46. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  47. data/firefox/src/extension/chrome.manifest +3 -0
  48. data/firefox/src/extension/components/context.js +37 -0
  49. data/firefox/src/extension/components/driver-component.js +127 -0
  50. data/firefox/src/extension/components/firefoxDriver.js +706 -0
  51. data/firefox/src/extension/components/json2.js +273 -0
  52. data/firefox/src/extension/components/keytest.html +554 -0
  53. data/firefox/src/extension/components/nsCommandProcessor.js +586 -0
  54. data/firefox/src/extension/components/screenshooter.js +70 -0
  55. data/firefox/src/extension/components/socketListener.js +185 -0
  56. data/firefox/src/extension/components/utils.js +1200 -0
  57. data/firefox/src/extension/components/webLoadingListener.js +57 -0
  58. data/firefox/src/extension/components/webdriverserver.js +101 -0
  59. data/firefox/src/extension/components/wrappedElement.js +609 -0
  60. data/firefox/src/extension/content/fxdriver.xul +30 -0
  61. data/firefox/src/extension/content/server.js +95 -0
  62. data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
  63. data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
  64. data/firefox/src/extension/install.rdf +29 -0
  65. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +21 -0
  66. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +86 -0
  67. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +426 -0
  68. data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +82 -0
  69. data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +132 -0
  70. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +174 -0
  71. data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +60 -0
  72. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
  73. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  74. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  75. data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
  76. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +552 -0
  77. data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +94 -0
  78. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
  79. data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
  80. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +374 -0
  81. data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
  82. data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
  83. data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
  84. data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +43 -0
  85. data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
  86. metadata +182 -0
@@ -0,0 +1,68 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Error
4
+ class WebDriverError < StandardError; end
5
+
6
+
7
+ class IndexOutOfBoundsError < WebDriverError; end # 1
8
+ class NoCollectionError < WebDriverError; end # 2
9
+ class NoStringError < WebDriverError; end # 3
10
+ class NoStringLengthError < WebDriverError; end # 4
11
+ class NoStringWrapperError < WebDriverError; end # 5
12
+ class NoSuchDriverError < WebDriverError; end # 6
13
+ class NoSuchElementError < WebDriverError; end # 7
14
+ class NoSuchFrameError < WebDriverError; end # 8
15
+ # NotImplementedError # 9 - just use Ruby's
16
+ class ObsoleteElementError < WebDriverError; end # 10
17
+ class ElementNotDisplayedError < WebDriverError; end # 11
18
+ class ElementNotEnabledError < WebDriverError; end # 12
19
+ class UnhandledError < WebDriverError; end # 13
20
+ class ExpectedError < WebDriverError; end # 14
21
+ class ElementNotSelectedError < WebDriverError; end # 15
22
+ class NoSuchDocumentError < WebDriverError; end # 16
23
+ class UnexpectedJavascriptError < WebDriverError; end # 17
24
+ class NoScriptResultError < WebDriverError; end # 18
25
+ class UnknownScriptResultError < WebDriverError; end # 19
26
+ class NoSuchCollectionError < WebDriverError; end # 20
27
+ class TimeOutError < WebDriverError; end # 21
28
+ class NullPointerError < WebDriverError; end # 22
29
+ class NoSuchWindowError < WebDriverError; end # 23
30
+ class UnsupportedOperationError < WebDriverError; end
31
+
32
+ Errors = [
33
+ IndexOutOfBoundsError,
34
+ NoCollectionError,
35
+ NoStringError,
36
+ NoStringLengthError,
37
+ NoStringWrapperError,
38
+ NoSuchDriverError,
39
+ NoSuchElementError,
40
+ NoSuchFrameError,
41
+ NotImplementedError,
42
+ ObsoleteElementError,
43
+ ElementNotDisplayedError,
44
+ ElementNotEnabledError,
45
+ UnhandledError,
46
+ ExpectedError,
47
+ ElementNotSelectedError,
48
+ NoSuchDocumentError,
49
+ UnexpectedJavascriptError,
50
+ NoScriptResultError,
51
+ UnknownScriptResultError,
52
+ NoSuchCollectionError,
53
+ TimeOutError,
54
+ NullPointerError,
55
+ NoSuchWindowError
56
+ ]
57
+
58
+ class << self
59
+ def for_code(code)
60
+ return if code == 0
61
+
62
+ Errors[code - 1] || WebDriverError
63
+ end
64
+ end
65
+
66
+ end # Error
67
+ end # WebDriver
68
+ end # Selenium
@@ -0,0 +1,69 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Find
4
+
5
+ FINDERS = {
6
+ :class => 'ByClassName',
7
+ :class_name => 'ByClassName',
8
+ :id => 'ById',
9
+ :link_text => 'ByLinkText',
10
+ :link => 'ByLinkText',
11
+ :partial_link_text => 'ByPartialLinkText',
12
+ :name => 'ByName',
13
+ :tag_name => 'ByTagName',
14
+ :xpath => 'ByXpath',
15
+ }
16
+
17
+
18
+ def find_element(*args)
19
+ how, what = extract_args(args)
20
+
21
+ unless by = FINDERS[how.to_sym]
22
+ raise Error::UnsupportedOperationError, "Cannot find element by #{how.inspect}"
23
+ end
24
+
25
+ meth = "findElement#{by}"
26
+ what = what.to_s
27
+
28
+ bridge.send meth, ref, what
29
+ end
30
+
31
+ def find_elements(*args)
32
+ how, what = extract_args(args)
33
+
34
+ unless by = FINDERS[how.to_sym]
35
+ raise Error::UnsupportedOperationError, "Cannot find elements by #{how.inspect}"
36
+ end
37
+
38
+ meth = "findElements#{by}"
39
+ what = what.to_s
40
+
41
+ bridge.send meth, ref, what
42
+ end
43
+
44
+ private
45
+
46
+ def extract_args(args)
47
+ case args.size
48
+ when 2
49
+ args
50
+ when 1
51
+ arg = args.first
52
+ unless arg.respond_to?(:shift)
53
+ raise ArgumentError, "expected #{arg.inspect}:#{arg.class} to respond to #shift"
54
+ end
55
+
56
+ arr = arg.shift
57
+ unless arr.size == 2
58
+ raise ArgumentError, "expected #{arr.inspect} to have 2 elements"
59
+ end
60
+
61
+ arr
62
+ else
63
+ raise ArgumentError, "wrong number of arguments (#{args.size} for 2)"
64
+ end
65
+ end
66
+
67
+ end # Find
68
+ end # WebDriver
69
+ end # Selenium
@@ -0,0 +1,23 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Navigation
4
+
5
+ def initialize(driver)
6
+ @driver = driver
7
+ end
8
+
9
+ def to(url)
10
+ @driver.bridge.get url
11
+ end
12
+
13
+ def back
14
+ @driver.bridge.goBack
15
+ end
16
+
17
+ def forward
18
+ @driver.bridge.goForward
19
+ end
20
+
21
+ end # Navigation
22
+ end # WebDriver
23
+ end # Selenium
@@ -0,0 +1,50 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Options
4
+
5
+ def initialize(driver)
6
+ @bridge = driver.bridge
7
+ end
8
+
9
+ def add_cookie(opts = {})
10
+ raise ArgumentError, "name is required" unless opts[:name]
11
+ raise ArgumentError, "value is required" unless opts[:value]
12
+
13
+ opts[:path] ||= "/"
14
+ opts[:secure] ||= false
15
+
16
+ @bridge.addCookie opts
17
+ end
18
+
19
+ def delete_cookie(name)
20
+ @bridge.deleteCookie name
21
+ end
22
+
23
+ def delete_all_cookies
24
+ @bridge.deleteAllCookies
25
+ end
26
+
27
+ def all_cookies
28
+ @bridge.getAllCookies.map do |cookie|
29
+ {
30
+ :name => cookie["name"],
31
+ :value => cookie["value"],
32
+ :path => cookie["path"],
33
+ :domain => cookie["domain"],
34
+ :expires => cookie["expires"],
35
+ :secure => cookie["secure"]
36
+ }
37
+ end
38
+ end
39
+
40
+ def speed
41
+ @bridge.getSpeed.downcase.to_sym
42
+ end
43
+
44
+ def speed=(speed)
45
+ @bridge.setSpeed(speed.to_s.upcase)
46
+ end
47
+
48
+ end # Options
49
+ end # WebDriver
50
+ end # Selenium
@@ -0,0 +1,82 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Platform
4
+
5
+ module_function
6
+
7
+ def home
8
+ # jruby has an issue with ENV['HOME'] on Windows
9
+ @home ||= Platform.jruby? ? java.lang.System.getProperty('user.home') : ENV['HOME']
10
+ end
11
+
12
+ def platform
13
+ @platform ||= case RUBY_PLATFORM
14
+ when /java/
15
+ :java
16
+ when /mswin|msys|mingw32/
17
+ :windows
18
+ when /darwin/
19
+ :macosx
20
+ when /linux|solaris|bsd/
21
+ :unix
22
+ else
23
+ RUBY_PLATFORM
24
+ end
25
+ end
26
+
27
+ def os
28
+ @os ||= begin
29
+ os = platform()
30
+
31
+ if os == :java
32
+ require "java"
33
+ os_name = java.lang.System.getProperty("os.name")
34
+ os = case os_name
35
+ when /windows/i then :windows
36
+ when /mac os/i then :macosx
37
+ when /linux/i then :unix
38
+ else os_name
39
+ end
40
+ end
41
+
42
+ os
43
+ end
44
+ end
45
+
46
+ def jruby?
47
+ platform == :java
48
+ end
49
+
50
+ def ruby187?
51
+ !!(RUBY_VERSION =~ /^1\.8\.7/)
52
+ end
53
+
54
+ def ruby19?
55
+ !!(RUBY_VERSION =~ /^1\.9/)
56
+ end
57
+
58
+ def win?
59
+ os == :windows
60
+ end
61
+
62
+ def wrap_in_quotes_if_necessary(str)
63
+ win? ? %{"#{str}"} : str
64
+ end
65
+
66
+ def make_writable(file)
67
+ File.chmod 0766, file
68
+ end
69
+
70
+ end # Platform
71
+ end # WebDriver
72
+ end # Selenium
73
+
74
+ if __FILE__ == $0
75
+ p :platform => WebDriver::Platform.platform,
76
+ :os => WebDriver::Platform.os,
77
+ :ruby187? => WebDriver::Platform.ruby187?,
78
+ :ruby19? => WebDriver::Platform.ruby19?,
79
+ :jruby? => WebDriver::Platform.jruby?,
80
+ :win? => WebDriver::Platform.win?,
81
+ :home => WebDriver::Platform.home
82
+ end
@@ -0,0 +1,23 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class TargetLocator
4
+
5
+ def initialize(driver)
6
+ @bridge = driver.bridge
7
+ end
8
+
9
+ def frame(id)
10
+ @bridge.switchToFrame id
11
+ end
12
+
13
+ def window(id)
14
+ @bridge.switchToWindow id
15
+ end
16
+
17
+ def active_element
18
+ @bridge.switchToActiveElement
19
+ end
20
+
21
+ end # TargetLocator
22
+ end # WebDriver
23
+ end # Selenium
@@ -0,0 +1,3 @@
1
+ content fxdriver content/ xpcnativewrappers=yes
2
+
3
+ overlay chrome://browser/content/browser.xul chrome://fxdriver/content/fxdriver.xul
@@ -0,0 +1,37 @@
1
+ /*
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 Google Inc.
4
+ Portions copyright 2007 ThoughtWorks, Inc
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ function Context(windowId, frameId) {
20
+ this.windowId = windowId;
21
+
22
+ if (typeof frameId == 'number' || (typeof frameId == 'string' && frameId)) {
23
+ this.frameId = frameId;
24
+ }
25
+ }
26
+
27
+
28
+ Context.fromString = function(text) {
29
+ var bits = text.split(" ");
30
+ return new Context(bits[0], bits[1]);
31
+ };
32
+
33
+
34
+ Context.prototype.toString = function() {
35
+ return this.windowId + " " +
36
+ (this.frameId !== undefined ? this.frameId.toString() : "");
37
+ };
@@ -0,0 +1,127 @@
1
+ /*
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 Google Inc.
4
+ Portions copyright 2007 ThoughtWorks, Inc
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ // constants
20
+ const nsISupports = Components.interfaces.nsISupports;
21
+ const CLASS_ID = Components.ID("{1C0E8D86-B661-40d0-AE3D-CA012FADF170}");
22
+ const CLASS_NAME = "Firefox WebDriver";
23
+ const CONTRACT_ID = "@googlecode.com/webdriver/fxdriver;1";
24
+
25
+ // The following code is derived from https://addons.mozilla.org/en-US/firefox/files/browse/3682/
26
+ // Its copyrights belong to its original author.
27
+
28
+ var ExternalScripts = [
29
+ "context.js",
30
+ "firefoxDriver.js",
31
+ "socketListener.js",
32
+ "utils.js",
33
+ "webdriverserver.js",
34
+ "webLoadingListener.js",
35
+ "wrappedElement.js",
36
+ "screenshooter.js"
37
+ ];
38
+
39
+
40
+ (function() {
41
+ var self;
42
+ var fileProtocolHandler = Components.
43
+ classes['@mozilla.org/network/protocol;1?name=file'].
44
+ createInstance(Components.interfaces.nsIFileProtocolHandler);
45
+ self = __LOCATION__;
46
+
47
+ var parent = self.parent;
48
+ // the directory this file is in
49
+ var loader = Components.classes['@mozilla.org/moz/jssubscript-loader;1'].
50
+ createInstance(Components.interfaces.mozIJSSubScriptLoader);
51
+
52
+ // Firefox 3.5+ has native JSON support; prefer that over our script from
53
+ // www.json.org, which may be slower.
54
+ var appInfo = Components.classes['@mozilla.org/xre/app-info;1'].
55
+ getService(Components.interfaces.nsIXULAppInfo);
56
+ var versionChecker = Components.classes['@mozilla.org/xpcom/version-comparator;1'].
57
+ getService(Components.interfaces.nsIVersionComparator);
58
+ if (versionChecker.compare(appInfo.version, '3.5') < 0) {
59
+ ExternalScripts.push('json2.js');
60
+ }
61
+
62
+ for (var index in ExternalScripts) {
63
+ var child = parent.clone();
64
+ child.append(ExternalScripts[index]);
65
+ // child is a nsILocalFile of the file we want to load
66
+ var childname = fileProtocolHandler.getURLSpecFromFile(child);
67
+ loader.loadSubScript(childname);
68
+ }
69
+ })();
70
+
71
+
72
+ // This code has been derived from the example code at
73
+ // http://developer-stage.mozilla.org/en/docs/How_to_Build_an_XPCOM_Component_in_Javascript
74
+ // Its copyrights belong to the original author
75
+
76
+ var ServerFactory = {
77
+ createInstance: function (aOuter, aIID) {
78
+ if (aOuter != null)
79
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
80
+ if (!this.server)
81
+ this.server = new WebDriverServer();
82
+ return (this.server).QueryInterface(aIID);
83
+ }
84
+ };
85
+
86
+
87
+ //module definition (xpcom registration)
88
+ var ServerModule = {
89
+ _firstTime: true,
90
+
91
+ registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
92
+ if (this._firstTime) {
93
+ this._firstTime = false;
94
+ throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
95
+ }
96
+ aCompMgr =
97
+ aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
98
+ aCompMgr.registerFactoryLocation(
99
+ CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
100
+ },
101
+
102
+ unregisterSelf: function(aCompMgr, aLocation, aType) {
103
+ aCompMgr =
104
+ aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
105
+ aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
106
+ },
107
+
108
+ getClassObject: function(aCompMgr, aCID, aIID) {
109
+ if (!aIID.equals(Components.interfaces.nsIFactory))
110
+ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
111
+
112
+ if (aCID.equals(CLASS_ID))
113
+ return ServerFactory;
114
+
115
+ throw Components.results.NS_ERROR_NO_INTERFACE;
116
+ },
117
+
118
+ canUnload: function(aCompMgr) {
119
+ return true;
120
+ }
121
+ };
122
+
123
+
124
+ //module initialization
125
+ function NSGetModule(aCompMgr, aFileSpec) {
126
+ return ServerModule;
127
+ }