watir-webdriver 0.2.3 → 0.2.4
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/{README.rdoc → README.md} +28 -17
- data/lib/watir-webdriver/atoms/fireEvent.js +15 -0
- data/lib/watir-webdriver/atoms/getOuterHtml.js +4 -0
- data/lib/watir-webdriver/container.rb +7 -6
- data/lib/watir-webdriver/elements/element.rb +14 -5
- data/lib/watir-webdriver/elements/frame.rb +18 -0
- data/lib/watir-webdriver/elements/select.rb +4 -2
- data/lib/watir-webdriver/locators/element_locator.rb +2 -13
- data/lib/watir-webdriver/version.rb +1 -1
- data/lib/watir-webdriver/xpath_support.rb +10 -0
- data/watir-webdriver.gemspec +1 -1
- metadata +7 -7
- data/lib/watir-webdriver/browserbot.js +0 -57
data/{README.rdoc → README.md}
RENAMED
@@ -1,46 +1,56 @@
|
|
1
|
-
|
1
|
+
watir-webdriver
|
2
|
+
===============
|
2
3
|
|
3
4
|
Watir implementation built on WebDriver's Ruby bindings.
|
4
5
|
See http://rubyforge.org/pipermail/wtr-development/2009-October/001313.html.
|
5
6
|
|
6
|
-
|
7
|
+
API docs
|
8
|
+
--------
|
7
9
|
|
8
10
|
http://jarib.github.com/watir-webdriver/doc/
|
9
11
|
|
10
|
-
|
12
|
+
Example
|
13
|
+
-------
|
14
|
+
```ruby
|
11
15
|
|
12
|
-
|
16
|
+
require 'watir-webdriver'
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
browser = Watir::Browser.new :firefox
|
19
|
+
browser.goto "http://google.com"
|
20
|
+
browser.text_field(:name => 'q').set("WebDriver rocks!")
|
21
|
+
browser.button(:name => 'btnG').click
|
22
|
+
puts browser.url
|
23
|
+
browser.close
|
24
|
+
```
|
20
25
|
|
21
|
-
|
26
|
+
Description
|
27
|
+
-----------
|
22
28
|
|
23
29
|
The file in lib/watir/elements/generated.rb is autogenerated from the HTML5 spec. This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem (link below).
|
24
30
|
|
25
|
-
|
31
|
+
Specs
|
32
|
+
-----
|
26
33
|
|
27
34
|
watir-webdriver uses the watir2 branch of watirspec for testing. After cloning, you should fetch the submodule:
|
28
35
|
|
29
|
-
|
36
|
+
git submodule init && git submodule update
|
30
37
|
|
31
38
|
Specs specific to watir-webdriver are found in spec/*_spec.rb, with watirspec in spec/watirspec.
|
32
39
|
|
33
|
-
|
40
|
+
See also
|
41
|
+
--------
|
34
42
|
|
35
43
|
* http://github.com/jarib/webidl
|
36
44
|
* http://github.com/jarib/watirspec/tree/watir2
|
37
45
|
* http://selenium.googlecode.com
|
38
46
|
|
39
|
-
|
47
|
+
Dependencies
|
48
|
+
------------
|
40
49
|
|
41
50
|
* selenium-webdriver
|
42
51
|
|
43
|
-
|
52
|
+
Note on Patches/Pull Requests
|
53
|
+
-----------------------------
|
44
54
|
|
45
55
|
* Fork the project.
|
46
56
|
* Make your feature addition or bug fix.
|
@@ -50,6 +60,7 @@ Specs specific to watir-webdriver are found in spec/*_spec.rb, with watirspec in
|
|
50
60
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
51
61
|
* Send me a pull request. Bonus points for topic branches.
|
52
62
|
|
53
|
-
|
63
|
+
Copyright
|
64
|
+
---------
|
54
65
|
|
55
66
|
Copyright (c) 2009-2011 Jari Bakken. See LICENSE for details.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function(){return function(){var l=this;
|
2
|
+
function m(a){var c=typeof a;if(c=="object")if(a){if(a instanceof Array)return"array";else if(a instanceof Object)return c;var b=Object.prototype.toString.call(a);if(b=="[object Window]")return"object";if(b=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(b=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if(c==
|
3
|
+
"function"&&typeof a.call=="undefined")return"object";return c}function n(a,c){function b(){}b.prototype=c.prototype;a.i=c.prototype;a.prototype=new b};function o(a){this.stack=Error().stack||"";if(a)this.message=String(a)}n(o,Error);function aa(a){for(var c=1;c<arguments.length;c++){var b=String(arguments[c]).replace(/\$/g,"$$$$");a=a.replace(/\%s/,b)}return a}
|
4
|
+
function p(a,c){var b=0,d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),f=String(c).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),k=Math.max(d.length,f.length);for(var j=0;b==0&&j<k;j++){var e=d[j]||"",g=f[j]||"",q=RegExp("(\\d*)(\\D*)","g"),s=RegExp("(\\d*)(\\D*)","g");do{var h=q.exec(e)||["","",""],i=s.exec(g)||["","",""];if(h[0].length==0&&i[0].length==0)break;b=r(h[1].length==0?0:parseInt(h[1],10),i[1].length==0?0:parseInt(i[1],10))||r(h[2].length==0,i[2].length==0)||r(h[2],i[2])}while(b==
|
5
|
+
0)}return b}function r(a,c){if(a<c)return-1;else if(a>c)return 1;return 0};function t(a,c){c.unshift(a);o.call(this,aa.apply(null,c));c.shift();this.l=a}n(t,o);function ba(a,c){if(!a){var b=Array.prototype.slice.call(arguments,2),d="Assertion failed";if(c){d+=": "+c;var f=b}throw new t(""+d,f||[]);}return a};var u=Array.prototype,ca=u.indexOf?function(a,c,b){ba(a.length!=null);return u.indexOf.call(a,c,b)}:function(a,c,b){b=b==null?0:b<0?Math.max(0,a.length+b):b;if(typeof a=="string"){if(typeof c!="string"||c.length!=1)return-1;return a.indexOf(c,b)}for(b=b;b<a.length;b++)if(b in a&&a[b]===c)return b;return-1};var v,w,x,y;function z(){return l.navigator?l.navigator.userAgent:null}y=x=w=v=false;var A;if(A=z()){var da=l.navigator;v=A.indexOf("Opera")==0;w=!v&&A.indexOf("MSIE")!=-1;x=!v&&A.indexOf("WebKit")!=-1;y=!v&&!x&&da.product=="Gecko"}var B=v,C=w,D=y,E=x,F;
|
6
|
+
a:{var G="",H;if(B&&l.opera){var I=l.opera.version;G=typeof I=="function"?I():I}else{if(D)H=/rv\:([^\);]+)(\)|;)/;else if(C)H=/MSIE\s+([^\);]+)(\)|;)/;else if(E)H=/WebKit\/(\S+)/;if(H){var J=H.exec(z());G=J?J[1]:""}}if(C){var K,L=l.document;K=L?L.documentMode:undefined;if(K>parseFloat(G)){F=String(K);break a}}F=G}var M={};var ea;!C||M["9"]||(M["9"]=p(F,"9")>=0);C&&(M["9"]||(M["9"]=p(F,"9")>=0));function N(a,c){this.x=a!==undefined?a:0;this.y=c!==undefined?c:0}N.prototype.toString=function(){return"("+this.x+", "+this.y+")"};function O(a){return a?new fa(P(a)):ea||(ea=new fa)}function P(a){return a.nodeType==9?a:a.ownerDocument||a.document}function fa(a){this.e=a||l.document||document}function ga(a){a=!E&&a.e.compatMode=="CSS1Compat"?a.e.documentElement:a.e.body;return new N(a.scrollLeft,a.scrollTop)};var Q="StopIteration"in l?l.StopIteration:Error("StopIteration");function ha(){}ha.prototype.next=function(){throw Q;};function R(a,c,b,d,f){this.a=!!c;a&&S(this,a,d);this.d=f!=undefined?f:this.c||0;if(this.a)this.d*=-1;this.h=!b}n(R,ha);R.prototype.b=null;R.prototype.c=0;R.prototype.g=false;function S(a,c,b,d){if(a.b=c)a.c=typeof b=="number"?b:a.b.nodeType!=1?0:a.a?-1:1;if(typeof d=="number")a.d=d}
|
7
|
+
R.prototype.next=function(){var a;if(this.g){if(!this.b||this.h&&this.d==0)throw Q;a=this.b;var c=this.a?-1:1;if(this.c==c){var b=this.a?a.lastChild:a.firstChild;b?S(this,b):S(this,a,c*-1)}else(b=this.a?a.previousSibling:a.nextSibling)?S(this,b):S(this,a.parentNode,c*-1);this.d+=this.c*(this.a?-1:1)}else this.g=true;a=this.b;if(!this.b)throw Q;return a};
|
8
|
+
R.prototype.splice=function(){var a=this.b,c=this.a?1:-1;if(this.c==c){this.c=c*-1;this.d+=this.c*(this.a?-1:1)}this.a=!this.a;R.prototype.next.call(this);this.a=!this.a;c=arguments[0];var b=m(c);c=b=="array"||b=="object"&&typeof c.length=="number"?arguments[0]:arguments;for(b=c.length-1;b>=0;b--)a.parentNode&&a.parentNode.insertBefore(c[b],a.nextSibling);a&&a.parentNode&&a.parentNode.removeChild(a)};function T(a,c,b,d){R.call(this,a,c,b,null,d)}n(T,R);T.prototype.next=function(){do T.i.next.call(this);while(this.c==-1);return this.b};function U(a,c){var b;a:{b=P(a);if(b.defaultView&&b.defaultView.getComputedStyle)if(b=b.defaultView.getComputedStyle(a,null)){b=b[c]||b.getPropertyValue(c);break a}b=""}return b||(a.currentStyle?a.currentStyle[c]:null)||a.style[c]}function ia(a){var c=a.getBoundingClientRect();if(C){a=a.ownerDocument;c.left-=a.documentElement.clientLeft+a.body.clientLeft;c.top-=a.documentElement.clientTop+a.body.clientTop}return c}
|
9
|
+
function ja(a){if(C)return a.offsetParent;var c=P(a),b=U(a,"position"),d=b=="fixed"||b=="absolute";for(a=a.parentNode;a&&a!=c;a=a.parentNode){b=U(a,"position");d=d&&b=="static"&&a!=c.documentElement&&a!=c.body;if(!d&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight||b=="fixed"||b=="absolute"))return a}return null};String.fromCharCode(160);var ka=C?1:0,la=["dragstart","dragexit","mouseover","mouseout"];
|
10
|
+
function V(a,c,b){var d=P(a),f=d?d.parentWindow||d.defaultView:window,k=new N;if(a.nodeType==1)if(a.getBoundingClientRect){var j=ia(a);k.x=j.left;k.y=j.top}else{j=ga(O(a));var e,g=P(a),q=U(a,"position"),s=D&&g.getBoxObjectFor&&!a.getBoundingClientRect&&q=="absolute"&&(e=g.getBoxObjectFor(a))&&(e.screenX<0||e.screenY<0),h=new N(0,0),i;e=g?g.nodeType==9?g:P(g):document;if(i=C)i=O(e).e.compatMode!="CSS1Compat";i=i?e.body:e.documentElement;if(a!=i)if(a.getBoundingClientRect){e=ia(a);g=ga(O(g));h.x=e.left+
|
11
|
+
g.x;h.y=e.top+g.y}else if(g.getBoxObjectFor&&!s){e=g.getBoxObjectFor(a);g=g.getBoxObjectFor(i);h.x=e.screenX-g.screenX;h.y=e.screenY-g.screenY}else{e=a;do{h.x+=e.offsetLeft;h.y+=e.offsetTop;if(e!=a){h.x+=e.clientLeft||0;h.y+=e.clientTop||0}if(E&&U(e,"position")=="fixed"){h.x+=g.body.scrollLeft;h.y+=g.body.scrollTop;break}e=e.offsetParent}while(e&&e!=a);if(B||E&&q=="absolute")h.y-=g.body.offsetTop;for(e=a;(e=ja(e))&&e!=g.body&&e!=i;){h.x-=e.scrollLeft;if(!B||e.tagName!="TR")h.y-=e.scrollTop}}k.x=h.x-
|
12
|
+
j.x;k.y=h.y-j.y}else{j=m(a.f)=="function";h=a;if(a.targetTouches)h=a.targetTouches[0];else if(j&&a.f().targetTouches)h=a.f().targetTouches[0];k.x=h.clientX;k.y=h.clientY}i=b||{};b=(i.x||0)+k.x;k=(i.y||0)+k.y;j=i.button||ka;h=i.bubble||true;g=null;if(ca(la,c)>=0)g=i.related||null;q=!!i.alt;e=!!i.control;s=!!i.shift;i=!!i.meta;if(a.fireEvent&&d&&d.createEventObject){a=d.createEventObject();a.altKey=q;a.j=e;a.metaKey=i;a.shiftKey=s;a.clientX=b;a.clientY=k;a.button=j;a.relatedTarget=g}else{a=d.createEvent("MouseEvents");
|
13
|
+
if(a.initMouseEvent)a.initMouseEvent(c,h,true,f,1,0,0,b,k,e,q,s,i,j,g);else{a.initEvent(c,h,true);a.shiftKey=s;a.metaKey=i;a.altKey=q;a.ctrlKey=e;a.button=j}}return a}
|
14
|
+
function W(a,c,b){var d=P(a);a=d?d.parentWindow||d.defaultView:window;var f=b||{};b=f.keyCode||0;var k=f.charCode||0,j=!!f.alt,e=!!f.ctrl,g=!!f.shift;f=!!f.meta;if(D){d=d.createEvent("KeyboardEvent");d.initKeyEvent(c,true,true,a,e,j,g,f,b,k)}else{if(C)d=d.createEventObject();else{d=d.createEvent("Events");d.initEvent(c,true,true);d.charCode=k}d.keyCode=b;d.altKey=j;d.ctrlKey=e;d.metaKey=f;d.shiftKey=g}return d}
|
15
|
+
function ma(a,c,b){var d=P(a),f=b||{};b=f.bubble!==false;var k=!!f.alt,j=!!f.control,e=!!f.shift;f=!!f.meta;if(a.fireEvent&&d&&d.createEventObject){a=d.createEventObject();a.altKey=k;a.k=j;a.metaKey=f;a.shiftKey=e}else{a=d.createEvent("HTMLEvents");a.initEvent(c,b,true);a.shiftKey=e;a.metaKey=f;a.altKey=k;a.ctrlKey=j}return a}var X={};X.click=V;X.keydown=W;X.keypress=W;X.keyup=W;X.mousedown=V;X.mousemove=V;X.mouseout=V;X.mouseover=V;X.mouseup=V;function na(a,c,b){b=(X[c]||ma)(a,c,b);var d;if(!(d=m(a.fireEvent)=="function")){d=m(a.fireEvent);d=d=="object"||d=="array"||d=="function"}if(d){try{(P(a)?P(a).parentWindow||P(a).defaultView:window).event=b}catch(f){}a=a.fireEvent("on"+c,b)}else a=a.dispatchEvent(b);return a}var Y="_".split("."),Z=l;!(Y[0]in Z)&&Z.execScript&&Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)if(!Y.length&&na!==undefined)Z[$]=na;else Z=Z[$]?Z[$]:Z[$]={};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null}, arguments);}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
function(){return function(){var d=this;function e(a,b){function c(){}c.prototype=b.prototype;a.b=b.prototype;a.prototype=new c};function f(a){this.stack=Error().stack||"";if(a)this.message=String(a)}e(f,Error);function i(a){for(var b=1;b<arguments.length;b++){var c=String(arguments[b]).replace(/\$/g,"$$$$");a=a.replace(/\%s/,c)}return a}
|
2
|
+
function j(a,b){var c=0,A=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),B=String(b).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),H=Math.max(A.length,B.length);for(var l=0;c==0&&l<H;l++){var I=A[l]||"",J=B[l]||"",K=RegExp("(\\d*)(\\D*)","g"),L=RegExp("(\\d*)(\\D*)","g");do{var g=K.exec(I)||["","",""],h=L.exec(J)||["","",""];if(g[0].length==0&&h[0].length==0)break;c=k(g[1].length==0?0:parseInt(g[1],10),h[1].length==0?0:parseInt(h[1],10))||k(g[2].length==0,h[2].length==0)||k(g[2],h[2])}while(c==
|
3
|
+
0)}return c}function k(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};e(function(a,b){b.unshift(a);f.call(this,i.apply(null,b));b.shift();this.a=a},f);var m,n,o,p;function q(){return d.navigator?d.navigator.userAgent:null}p=o=n=m=false;var r;if(r=q()){var s=d.navigator;m=r.indexOf("Opera")==0;n=!m&&r.indexOf("MSIE")!=-1;o=!m&&r.indexOf("WebKit")!=-1;p=!m&&!o&&s.product=="Gecko"}var t=n,u=p,v=o,w;
|
4
|
+
a:{var x="",y;if(m&&d.opera){var z=d.opera.version;x=typeof z=="function"?z():z}else{if(u)y=/rv\:([^\);]+)(\)|;)/;else if(t)y=/MSIE\s+([^\);]+)(\)|;)/;else if(v)y=/WebKit\/(\S+)/;if(y){var C=y.exec(q());x=C?C[1]:""}}if(t){var D,E=d.document;D=E?E.documentMode:undefined;if(D>parseFloat(x)){w=String(D);break a}}w=x}var F={};!t||F["9"]||(F["9"]=j(w,"9")>=0);t&&(F["9"]||(F["9"]=j(w,"9")>=0));function G(a){if("outerHTML"in a)return a.outerHTML;else{var b=(a.nodeType==9?a:a.ownerDocument||a.document).createElement("div");b.appendChild(a.cloneNode(true));return b.innerHTML}}var M="_".split("."),N=d;!(M[0]in N)&&N.execScript&&N.execScript("var "+M[0]);for(var O;M.length&&(O=M.shift());)if(!M.length&&G!==undefined)N[O]=G;else N=N[O]?N[O]:N[O]={};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null}, arguments);}
|
@@ -13,13 +13,14 @@ module Watir
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
ATOMS = {
|
17
|
+
:fireEvent => File.read(File.expand_path("../atoms/fireEvent.js", __FILE__)),
|
18
|
+
:getOuterHtml => File.read(File.expand_path("../atoms/getOuterHtml.js", __FILE__))
|
19
|
+
}
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def execute_atom(function_name, *arguments)
|
22
|
+
script = "return (%s).apply(null, arguments)" % ATOMS.fetch(function_name)
|
23
|
+
driver.execute_script(script, *arguments)
|
23
24
|
end
|
24
25
|
|
25
26
|
def extract_selector(selectors)
|
@@ -114,7 +114,7 @@ module Watir
|
|
114
114
|
|
115
115
|
def html
|
116
116
|
assert_exists
|
117
|
-
|
117
|
+
execute_atom(:getOuterHtml, @element).strip
|
118
118
|
end
|
119
119
|
|
120
120
|
def send_keys(*args)
|
@@ -133,16 +133,25 @@ module Watir
|
|
133
133
|
driver.execute_script "return arguments[0].focus()", @element
|
134
134
|
end
|
135
135
|
|
136
|
-
def fire_event(event_name
|
136
|
+
def fire_event(event_name)
|
137
137
|
assert_exists
|
138
|
-
event_name = event_name.to_s.sub(/^on/, '')
|
139
|
-
|
138
|
+
event_name = event_name.to_s.sub(/^on/, '').downcase
|
139
|
+
execute_atom(:fireEvent, @element, event_name)
|
140
140
|
end
|
141
141
|
|
142
142
|
def parent
|
143
143
|
assert_exists
|
144
144
|
|
145
|
-
|
145
|
+
# TODO: atom?
|
146
|
+
script = <<-JS
|
147
|
+
var element = arguments[0].parentNode;
|
148
|
+
if(element.nodeType != Node.ELEMENT_NODE)
|
149
|
+
return null;
|
150
|
+
|
151
|
+
return element;
|
152
|
+
JS
|
153
|
+
|
154
|
+
e = driver.execute_script(script, @element)
|
146
155
|
|
147
156
|
if e.kind_of?(WebDriver::Element)
|
148
157
|
Watir.element_class_for(e.tag_name.downcase).new(@parent, :element => e)
|
@@ -20,6 +20,14 @@ module Watir
|
|
20
20
|
super
|
21
21
|
end
|
22
22
|
|
23
|
+
def html
|
24
|
+
assert_exists
|
25
|
+
|
26
|
+
# this will actually give us the innerHTML instead of the outerHTML of the <frame>,
|
27
|
+
# but given the choice this seems more useful
|
28
|
+
execute_atom(:getOuterHtml, @element.find_element(:tag_name => "html")).strip
|
29
|
+
end
|
30
|
+
|
23
31
|
def execute_script(*args)
|
24
32
|
browser.execute_script(*args)
|
25
33
|
end
|
@@ -55,6 +63,16 @@ module Watir
|
|
55
63
|
def frames(*args)
|
56
64
|
FrameCollection.new(self, extract_selector(args).merge(:tag_name => /^(iframe|frame)$/)) # hack
|
57
65
|
end
|
66
|
+
|
67
|
+
def iframe(*args)
|
68
|
+
warn "Watir::Container#iframe is replaced by Watir::Container#frame"
|
69
|
+
frame(*args)
|
70
|
+
end
|
71
|
+
|
72
|
+
def iframes(*args)
|
73
|
+
warn "Watir::Container#iframes is replaced by Watir::Container#frames"
|
74
|
+
frame(*args)
|
75
|
+
end
|
58
76
|
end
|
59
77
|
|
60
78
|
class FrameCollection < ElementCollection
|
@@ -181,11 +181,13 @@ module Watir
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def option_xpath_for(how, string)
|
184
|
+
string = XpathSupport.escape string
|
185
|
+
|
184
186
|
case how
|
185
187
|
when :text
|
186
|
-
".//option[normalize-space()
|
188
|
+
".//option[normalize-space()=#{string} or @label=#{string}]"
|
187
189
|
when :value
|
188
|
-
".//option[@value
|
190
|
+
".//option[@value=#{string}]"
|
189
191
|
else
|
190
192
|
raise Error, "unknown how: #{how.inspect}"
|
191
193
|
end
|
@@ -297,9 +297,9 @@ module Watir
|
|
297
297
|
def equal_pair(key, value)
|
298
298
|
# we assume :label means a corresponding label element, not the attribute
|
299
299
|
if key == :label && should_use_label_element?
|
300
|
-
"@id=//label[normalize-space()=#{
|
300
|
+
"@id=//label[normalize-space()=#{XpathSupport.escape value}]/@for"
|
301
301
|
else
|
302
|
-
"#{lhs_for(key)}=#{
|
302
|
+
"#{lhs_for(key)}=#{XpathSupport.escape value}"
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
@@ -350,16 +350,5 @@ module Watir
|
|
350
350
|
false
|
351
351
|
end
|
352
352
|
|
353
|
-
def xpath_string(value)
|
354
|
-
if value.include? "'"
|
355
|
-
parts = value.split("'", -1).map { |part| "'#{part}'" }
|
356
|
-
string = parts.join(%{,"'",})
|
357
|
-
|
358
|
-
"concat(#{string})"
|
359
|
-
else
|
360
|
-
"'#{value}'"
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
353
|
end # ElementLocator
|
365
354
|
end # Watir
|
@@ -23,6 +23,16 @@ module Watir
|
|
23
23
|
Watir.element_class_for(e.tag_name.downcase).new(self, :element => e)
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
def self.escape(value)
|
28
|
+
if value.include? "'"
|
29
|
+
parts = value.split("'", -1).map { |part| "'#{part}'" }
|
30
|
+
string = parts.join(%{,"'",})
|
26
31
|
|
32
|
+
"concat(#{string})"
|
33
|
+
else
|
34
|
+
"'#{value}'"
|
35
|
+
end
|
36
|
+
end
|
27
37
|
end # XpathSupport
|
28
38
|
end # Watir
|
data/watir-webdriver.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "selenium-webdriver", '>= 0.2.
|
22
|
+
s.add_dependency "selenium-webdriver", '>= 0.2.1'
|
23
23
|
|
24
24
|
s.add_development_dependency "rspec", "~> 2.3.0"
|
25
25
|
s.add_development_dependency "yard", "~> 0.6"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: watir-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jari Bakken
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-01 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: selenium-webdriver
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.2.
|
23
|
+
version: 0.2.1
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -104,12 +104,13 @@ files:
|
|
104
104
|
- .gitmodules
|
105
105
|
- Gemfile
|
106
106
|
- LICENSE
|
107
|
-
- README.
|
107
|
+
- README.md
|
108
108
|
- Rakefile
|
109
109
|
- lib/watir-webdriver.rb
|
110
|
+
- lib/watir-webdriver/atoms/fireEvent.js
|
111
|
+
- lib/watir-webdriver/atoms/getOuterHtml.js
|
110
112
|
- lib/watir-webdriver/attribute_helper.rb
|
111
113
|
- lib/watir-webdriver/browser.rb
|
112
|
-
- lib/watir-webdriver/browserbot.js
|
113
114
|
- lib/watir-webdriver/cell_container.rb
|
114
115
|
- lib/watir-webdriver/container.rb
|
115
116
|
- lib/watir-webdriver/element_collection.rb
|
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
194
|
requirements: []
|
194
195
|
|
195
196
|
rubyforge_project: watir-webdriver
|
196
|
-
rubygems_version: 1.
|
197
|
+
rubygems_version: 1.8.2
|
197
198
|
signing_key:
|
198
199
|
specification_version: 3
|
199
200
|
summary: Watir on WebDriver
|
@@ -213,4 +214,3 @@ test_files:
|
|
213
214
|
- spec/spec_helper.rb
|
214
215
|
- spec/special_chars_spec.rb
|
215
216
|
- spec/wait_spec.rb
|
216
|
-
has_rdoc:
|
@@ -1,57 +0,0 @@
|
|
1
|
-
// stolen from injectableSelenium.js in WebDriver
|
2
|
-
var browserbot = {
|
3
|
-
createEventObject : function(element, controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown) {
|
4
|
-
var evt = element.ownerDocument.createEventObject();
|
5
|
-
evt.shiftKey = shiftKeyDown;
|
6
|
-
evt.metaKey = metaKeyDown;
|
7
|
-
evt.altKey = altKeyDown;
|
8
|
-
evt.ctrlKey = controlKeyDown;
|
9
|
-
return evt;
|
10
|
-
},
|
11
|
-
|
12
|
-
triggerEvent: function(element, eventType, canBubble, controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown) {
|
13
|
-
canBubble = (typeof(canBubble) == undefined) ? true: canBubble;
|
14
|
-
if (element.fireEvent && element.ownerDocument && element.ownerDocument.createEventObject) {
|
15
|
-
// IE
|
16
|
-
var evt = this.createEventObject(element, controlKeyDown, altKeyDown, shiftKeyDown, metaKeyDown);
|
17
|
-
element.fireEvent('on' + eventType, evt);
|
18
|
-
} else {
|
19
|
-
var evt = document.createEvent('HTMLEvents');
|
20
|
-
|
21
|
-
try {
|
22
|
-
evt.shiftKey = shiftKeyDown;
|
23
|
-
evt.metaKey = metaKeyDown;
|
24
|
-
evt.altKey = altKeyDown;
|
25
|
-
evt.ctrlKey = controlKeyDown;
|
26
|
-
} catch(e) {
|
27
|
-
// Nothing sane to do
|
28
|
-
}
|
29
|
-
|
30
|
-
evt.initEvent(eventType, canBubble, true);
|
31
|
-
return element.dispatchEvent(evt);
|
32
|
-
}
|
33
|
-
},
|
34
|
-
|
35
|
-
getVisibleText: function() {
|
36
|
-
var selection = getSelection();
|
37
|
-
var range = document.createRange();
|
38
|
-
range.selectNodeContents(document.documentElement);
|
39
|
-
selection.addRange(range);
|
40
|
-
var string = selection.toString();
|
41
|
-
selection.removeAllRanges();
|
42
|
-
|
43
|
-
return string;
|
44
|
-
},
|
45
|
-
|
46
|
-
getOuterHTML: function(element) {
|
47
|
-
if (element.outerHTML) {
|
48
|
-
return element.outerHTML;
|
49
|
-
} else if (typeof(XMLSerializer) != undefined) {
|
50
|
-
return new XMLSerializer().serializeToString(element);
|
51
|
-
} else {
|
52
|
-
throw "can't get outerHTML in this browser";
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
};
|