selenium-webdriver 2.18.0 → 2.19.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/selenium/client/base.rb +31 -17
- data/lib/selenium/client/driver.rb +1 -1
- data/lib/selenium/client/errors.rb +3 -3
- data/lib/selenium/client/extensions.rb +17 -17
- data/lib/selenium/client/idiomatic.rb +45 -45
- data/lib/selenium/client/javascript_expression_builder.rb +8 -8
- data/lib/selenium/client/legacy_driver.rb +155 -155
- data/lib/selenium/client/selenium_helper.rb +8 -8
- data/lib/selenium/webdriver/android/bridge.rb +2 -1
- data/lib/selenium/webdriver/chrome/service.rb +1 -1
- data/lib/selenium/webdriver/common.rb +3 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +19 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +2 -1
- data/lib/selenium/webdriver/common/keyboard.rb +3 -0
- data/lib/selenium/webdriver/common/mouse.rb +4 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +64 -0
- data/lib/selenium/webdriver/common/touch_screen.rb +105 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/ie/native/win32/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/IEDriver.dll +0 -0
- data/lib/selenium/webdriver/remote/bridge.rb +46 -0
- metadata +8 -5
@@ -3,17 +3,17 @@ module Selenium
|
|
3
3
|
|
4
4
|
class JavascriptExpressionBuilder
|
5
5
|
attr_reader :script
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(javascript_framework_name=nil)
|
8
|
-
@framework = javascript_framework_for(javascript_framework_name) if javascript_framework_name
|
8
|
+
@framework = javascript_framework_for(javascript_framework_name) if javascript_framework_name
|
9
9
|
@script = ""
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def append(text)
|
13
13
|
@script << text
|
14
14
|
self
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def no_pending_ajax_requests
|
18
18
|
append window_script("#{@framework.ajax_request_tracker} == 0")
|
19
19
|
end
|
@@ -29,7 +29,7 @@ module Selenium
|
|
29
29
|
def not_visible(locator)
|
30
30
|
append "!selenium.isVisible('#{quote_escaped(locator)}')"
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def find_element(locator)
|
34
34
|
append <<-EOS
|
35
35
|
var element;
|
@@ -41,7 +41,7 @@ module Selenium
|
|
41
41
|
}
|
42
42
|
EOS
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def element_value_is(expected_value)
|
46
46
|
append "(element != null && element.value == '#{quote_escaped(expected_value)}')"
|
47
47
|
end
|
@@ -71,7 +71,7 @@ module Selenium
|
|
71
71
|
var text_match;
|
72
72
|
text_match = (null != selenium.browserbot.getCurrentWindow().document.body.innerHTML.match(#{js_regexp}));
|
73
73
|
EOS
|
74
|
-
|
74
|
+
|
75
75
|
end
|
76
76
|
|
77
77
|
def find_text_in_element(pattern, options)
|
@@ -80,7 +80,7 @@ module Selenium
|
|
80
80
|
var text_match;
|
81
81
|
text_match = (element != null && #{text_match(pattern)});
|
82
82
|
EOS
|
83
|
-
|
83
|
+
|
84
84
|
self
|
85
85
|
end
|
86
86
|
|
@@ -20,14 +20,14 @@
|
|
20
20
|
# -----------------
|
21
21
|
|
22
22
|
# Defines an object that runs Selenium commands.
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# ===Element Locators
|
25
25
|
# Element Locators tell Selenium which HTML element a command refers to.
|
26
26
|
# The format of a locator is:
|
27
27
|
# <em>locatorType</em><b>=</b><em>argument</em>
|
28
28
|
# We support the following strategies for locating elements:
|
29
|
-
#
|
30
|
-
# * <b>identifier</b>=<em>id</em>:
|
29
|
+
#
|
30
|
+
# * <b>identifier</b>=<em>id</em>:
|
31
31
|
# Select the element with the specified @id attribute. If no match is
|
32
32
|
# found, select the first element whose @name attribute is <em>id</em>.
|
33
33
|
# (This is normally the default; see below.)
|
@@ -37,21 +37,21 @@
|
|
37
37
|
# Select the first element with the specified @name attribute.
|
38
38
|
# * username
|
39
39
|
# * name=username
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# The name may optionally be followed by one or more <em>element-filters</em>, separated from the name by whitespace. If the <em>filterType</em> is not specified, <b>value</b> is assumed.
|
42
42
|
# * name=flavour value=chocolate
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# * <b>dom</b>=<em>javascriptExpression</em>:
|
46
|
-
#
|
43
|
+
#
|
44
|
+
#
|
45
|
+
# * <b>dom</b>=<em>javascriptExpression</em>:
|
46
|
+
#
|
47
47
|
# Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object
|
48
48
|
# Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.
|
49
49
|
# * dom=document.forms['myForm'].myDropdown
|
50
50
|
# * dom=document.images[56]
|
51
51
|
# * dom=function foo() { return document.links[1]; }; foo();
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# * <b>xpath</b>=<em>xpathExpression</em>:
|
52
|
+
#
|
53
|
+
#
|
54
|
+
# * <b>xpath</b>=<em>xpathExpression</em>:
|
55
55
|
# Locate an element using an XPath expression.
|
56
56
|
# * xpath=//img[@alt='The image alt text']
|
57
57
|
# * xpath=//table[@id='table1']//tr[4]/td[2]
|
@@ -60,47 +60,47 @@
|
|
60
60
|
# * xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td
|
61
61
|
# * xpath=//input[@name='name2' and @value='yes']
|
62
62
|
# * xpath=//*[text()="right"]
|
63
|
-
#
|
64
|
-
#
|
63
|
+
#
|
64
|
+
#
|
65
65
|
# * <b>link</b>=<em>textPattern</em>:
|
66
66
|
# Select the link (anchor) element which contains text matching the
|
67
67
|
# specified <em>pattern</em>.
|
68
68
|
# * link=The link text
|
69
|
-
#
|
70
|
-
#
|
69
|
+
#
|
70
|
+
#
|
71
71
|
# * <b>css</b>=<em>cssSelectorSyntax</em>:
|
72
72
|
# Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
|
73
73
|
# * css=a[href="#id3"]
|
74
74
|
# * css=span#firstChild + span
|
75
|
-
#
|
76
|
-
# Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).
|
77
|
-
#
|
75
|
+
#
|
76
|
+
# Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, :only-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).
|
77
|
+
#
|
78
78
|
# * <b>ui</b>=<em>uiSpecifierString</em>:
|
79
79
|
# Locate an element by resolving the UI specifier string to another locator, and evaluating it. See the Selenium UI-Element Reference for more details.
|
80
80
|
# * ui=loginPages::loginButton()
|
81
81
|
# * ui=settingsPages::toggle(label=Hide Email)
|
82
82
|
# * ui=forumPages::postBody(index=2)//a[2]
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
83
|
+
#
|
84
|
+
#
|
85
|
+
#
|
86
|
+
#
|
87
87
|
# Without an explicit locator prefix, Selenium uses the following default
|
88
88
|
# strategies:
|
89
|
-
#
|
89
|
+
#
|
90
90
|
# * <b>dom</b>, for locators starting with "document."
|
91
91
|
# * <b>xpath</b>, for locators starting with "//"
|
92
92
|
# * <b>identifier</b>, otherwise
|
93
|
-
#
|
93
|
+
#
|
94
94
|
# ===Element FiltersElement filters can be used with a locator to refine a list of candidate elements. They are currently used only in the 'name' element-locator.
|
95
95
|
# Filters look much like locators, ie.
|
96
96
|
# <em>filterType</em><b>=</b><em>argument</em>Supported element-filters are:
|
97
97
|
# <b>value=</b><em>valuePattern</em>
|
98
|
-
#
|
98
|
+
#
|
99
99
|
# Matches elements based on their values. This is particularly useful for refining a list of similarly-named toggle-buttons.<b>index=</b><em>index</em>
|
100
|
-
#
|
100
|
+
#
|
101
101
|
# Selects a single element based on its position in the list (offset from zero).===String-match Patterns
|
102
102
|
# Various Pattern syntaxes are available for matching string values:
|
103
|
-
#
|
103
|
+
#
|
104
104
|
# * <b>glob:</b><em>pattern</em>:
|
105
105
|
# Match a string against a "glob" (aka "wildmat") pattern. "Glob" is a
|
106
106
|
# kind of limited regular-expression syntax typically used in command-line
|
@@ -113,23 +113,23 @@
|
|
113
113
|
# * <b>regexpi:</b><em>regexpi</em>:
|
114
114
|
# Match a string using a case-insensitive regular-expression.
|
115
115
|
# * <b>exact:</b><em>string</em>:
|
116
|
-
#
|
116
|
+
#
|
117
117
|
# Match a string exactly, verbatim, without any of that fancy wildcard
|
118
118
|
# stuff.
|
119
|
-
#
|
120
|
-
#
|
119
|
+
#
|
120
|
+
#
|
121
121
|
# If no pattern prefix is specified, Selenium assumes that it's a "glob"
|
122
122
|
# pattern.
|
123
|
-
#
|
124
|
-
#
|
123
|
+
#
|
124
|
+
#
|
125
125
|
# For commands that return multiple values (such as verifySelectOptions),
|
126
126
|
# the string being matched is a comma-separated list of the return values,
|
127
127
|
# where both commas and backslashes in the values are backslash-escaped.
|
128
128
|
# When providing a pattern, the optional matching syntax (i.e. glob,
|
129
129
|
# regexp, etc.) is specified once, as usual, at the beginning of the
|
130
130
|
# pattern.
|
131
|
-
#
|
132
|
-
#
|
131
|
+
#
|
132
|
+
#
|
133
133
|
module Selenium
|
134
134
|
module Client
|
135
135
|
module GeneratedDriver
|
@@ -408,10 +408,10 @@ module Selenium
|
|
408
408
|
|
409
409
|
|
410
410
|
# Sets the value of an input field, as though you typed it in.
|
411
|
-
#
|
411
|
+
#
|
412
412
|
# Can also be used to set the value of combo boxes, check boxes, etc. In these cases,
|
413
413
|
# value should be the value of the option selected, not the visible text.
|
414
|
-
#
|
414
|
+
#
|
415
415
|
#
|
416
416
|
# 'locator' is an element locator
|
417
417
|
# 'value' is the value to type
|
@@ -421,7 +421,7 @@ module Selenium
|
|
421
421
|
|
422
422
|
|
423
423
|
# Simulates keystroke events on the specified element, as though you typed the value key-by-key.
|
424
|
-
#
|
424
|
+
#
|
425
425
|
# This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
|
426
426
|
# this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
|
427
427
|
# Unlike the simple "type" command, which forces the specified value into the page directly, this command
|
@@ -430,7 +430,7 @@ module Selenium
|
|
430
430
|
# the field.
|
431
431
|
# In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
|
432
432
|
# send the keystroke events corresponding to what you just typed.
|
433
|
-
#
|
433
|
+
#
|
434
434
|
#
|
435
435
|
# 'locator' is an element locator
|
436
436
|
# 'value' is the value to type
|
@@ -450,7 +450,7 @@ module Selenium
|
|
450
450
|
|
451
451
|
# Get execution speed (i.e., get the millisecond length of the delay following each selenium operation). By default, there is no such delay, i.e.,
|
452
452
|
# the delay is 0 milliseconds.
|
453
|
-
#
|
453
|
+
#
|
454
454
|
# See also setSpeed.
|
455
455
|
#
|
456
456
|
def get_speed()
|
@@ -475,40 +475,40 @@ module Selenium
|
|
475
475
|
|
476
476
|
|
477
477
|
# Select an option from a drop-down using an option locator.
|
478
|
-
#
|
479
|
-
#
|
478
|
+
#
|
479
|
+
#
|
480
480
|
# Option locators provide different ways of specifying options of an HTML
|
481
481
|
# Select element (e.g. for selecting a specific option, or for asserting
|
482
482
|
# that the selected option satisfies a specification). There are several
|
483
483
|
# forms of Select Option Locator.
|
484
|
-
#
|
484
|
+
#
|
485
485
|
# * <b>label</b>=<em>labelPattern</em>:
|
486
486
|
# matches options based on their labels, i.e. the visible text. (This
|
487
487
|
# is the default.)
|
488
488
|
# * label=regexp:^[Oo]ther
|
489
|
-
#
|
490
|
-
#
|
489
|
+
#
|
490
|
+
#
|
491
491
|
# * <b>value</b>=<em>valuePattern</em>:
|
492
492
|
# matches options based on their values.
|
493
493
|
# * value=other
|
494
|
-
#
|
495
|
-
#
|
494
|
+
#
|
495
|
+
#
|
496
496
|
# * <b>id</b>=<em>id</em>:
|
497
|
-
#
|
497
|
+
#
|
498
498
|
# matches options based on their ids.
|
499
499
|
# * id=option1
|
500
|
-
#
|
501
|
-
#
|
500
|
+
#
|
501
|
+
#
|
502
502
|
# * <b>index</b>=<em>index</em>:
|
503
503
|
# matches an option based on its index (offset from zero).
|
504
504
|
# * index=2
|
505
|
-
#
|
506
|
-
#
|
507
|
-
#
|
508
|
-
#
|
505
|
+
#
|
506
|
+
#
|
507
|
+
#
|
508
|
+
#
|
509
509
|
# If no option locator prefix is provided, the default behaviour is to match on <b>label</b>.
|
510
|
-
#
|
511
|
-
#
|
510
|
+
#
|
511
|
+
#
|
512
512
|
#
|
513
513
|
# 'selectLocator' is an element locator identifying a drop-down menu
|
514
514
|
# 'optionLocator' is an option locator (a label by default)
|
@@ -518,7 +518,7 @@ module Selenium
|
|
518
518
|
|
519
519
|
|
520
520
|
# Add a selection to the set of selected options in a multi-select element using an option locator.
|
521
|
-
#
|
521
|
+
#
|
522
522
|
# @see #doSelect for details of option locators
|
523
523
|
#
|
524
524
|
# 'locator' is an element locator identifying a multi-select box
|
@@ -529,7 +529,7 @@ module Selenium
|
|
529
529
|
|
530
530
|
|
531
531
|
# Remove a selection from the set of selected options in a multi-select element using an option locator.
|
532
|
-
#
|
532
|
+
#
|
533
533
|
# @see #doSelect for details of option locators
|
534
534
|
#
|
535
535
|
# 'locator' is an element locator identifying a multi-select box
|
@@ -558,10 +558,10 @@ module Selenium
|
|
558
558
|
|
559
559
|
# Opens an URL in the test frame. This accepts both relative and absolute
|
560
560
|
# URLs.
|
561
|
-
#
|
561
|
+
#
|
562
562
|
# The "open" command waits for the page to load before proceeding,
|
563
563
|
# ie. the "AndWait" suffix is implicit.
|
564
|
-
#
|
564
|
+
#
|
565
565
|
# <em>Note</em>: The URL must be on the same domain as the runner HTML
|
566
566
|
# due to security restrictions in the browser (Same Origin Policy). If you
|
567
567
|
# need to open an URL on another domain, use the Selenium Server to start a
|
@@ -576,11 +576,11 @@ module Selenium
|
|
576
576
|
# Opens a popup window (if a window with that ID isn't already open).
|
577
577
|
# After opening the window, you'll need to select it using the selectWindow
|
578
578
|
# command.
|
579
|
-
#
|
579
|
+
#
|
580
580
|
# This command can also be a useful workaround for bug SEL-339. In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
|
581
581
|
# In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
|
582
582
|
# an empty (blank) url, like this: openWindow("", "myFunnyWindow").
|
583
|
-
#
|
583
|
+
#
|
584
584
|
#
|
585
585
|
# 'url' is the URL to open, which can be blank
|
586
586
|
# 'windowID' is the JavaScript window ID of the window to select
|
@@ -592,29 +592,29 @@ module Selenium
|
|
592
592
|
# Selects a popup window using a window locator; once a popup window has been selected, all
|
593
593
|
# commands go to that window. To select the main window again, use null
|
594
594
|
# as the target.
|
595
|
-
#
|
596
|
-
#
|
597
|
-
#
|
595
|
+
#
|
596
|
+
#
|
597
|
+
#
|
598
598
|
# Window locators provide different ways of specifying the window object:
|
599
599
|
# by title, by internal JavaScript "name," or by JavaScript variable.
|
600
|
-
#
|
600
|
+
#
|
601
601
|
# * <b>title</b>=<em>My Special Window</em>:
|
602
602
|
# Finds the window using the text that appears in the title bar. Be careful;
|
603
603
|
# two windows can share the same title. If that happens, this locator will
|
604
604
|
# just pick one.
|
605
|
-
#
|
605
|
+
#
|
606
606
|
# * <b>name</b>=<em>myWindow</em>:
|
607
|
-
# Finds the window using its internal JavaScript "name" property. This is the second
|
607
|
+
# Finds the window using its internal JavaScript "name" property. This is the second
|
608
608
|
# parameter "windowName" passed to the JavaScript method window.open(url, windowName, windowFeatures, replaceFlag)
|
609
609
|
# (which Selenium intercepts).
|
610
|
-
#
|
610
|
+
#
|
611
611
|
# * <b>var</b>=<em>variableName</em>:
|
612
612
|
# Some pop-up windows are unnamed (anonymous), but are associated with a JavaScript variable name in the current
|
613
613
|
# application window, e.g. "window.foo = window.open(url);". In those cases, you can open the window using
|
614
614
|
# "var=foo".
|
615
|
-
#
|
616
|
-
#
|
617
|
-
#
|
615
|
+
#
|
616
|
+
#
|
617
|
+
#
|
618
618
|
# If no window locator prefix is provided, we'll try to guess what you mean like this:
|
619
619
|
# 1.) if windowID is null, (or the string "null") then it is assumed the user is referring to the original window instantiated by the browser).
|
620
620
|
# 2.) if the value of the "windowID" parameter is a JavaScript variable name in the current application window, then it is assumed
|
@@ -629,7 +629,7 @@ module Selenium
|
|
629
629
|
# In some cases, Selenium will be unable to intercept a call to window.open (if the call occurs during or before the "onLoad" event, for example).
|
630
630
|
# (This is bug SEL-339.) In those cases, you can force Selenium to notice the open window's name by using the Selenium openWindow command, using
|
631
631
|
# an empty (blank) url, like this: openWindow("", "myFunnyWindow").
|
632
|
-
#
|
632
|
+
#
|
633
633
|
#
|
634
634
|
# 'windowID' is the JavaScript window ID of the window to select
|
635
635
|
def select_window(windowID)
|
@@ -650,8 +650,8 @@ module Selenium
|
|
650
650
|
# variable which is a reference to a window; and 3) the title of the
|
651
651
|
# window. This is the same ordered lookup performed by
|
652
652
|
# <tt>selectWindow</tt> .
|
653
|
-
#
|
654
|
-
#
|
653
|
+
#
|
654
|
+
#
|
655
655
|
#
|
656
656
|
# 'windowID' is an identifier for the popup window, which can take on a number of different meanings
|
657
657
|
def select_pop_up(windowID)
|
@@ -673,10 +673,10 @@ module Selenium
|
|
673
673
|
# "relative=parent" as a locator; to select the top frame, use "relative=top".
|
674
674
|
# You can also select a frame by its 0-based index number; select the first frame with
|
675
675
|
# "index=0", or the third frame with "index=2".
|
676
|
-
#
|
676
|
+
#
|
677
677
|
# You may also use a DOM expression to identify the frame you want directly,
|
678
678
|
# like this: <tt>dom=frames["main"].frames["subframe"]</tt>
|
679
|
-
#
|
679
|
+
#
|
680
680
|
#
|
681
681
|
# 'locator' is an element locator identifying a frame or iframe
|
682
682
|
def select_frame(locator)
|
@@ -685,13 +685,13 @@ module Selenium
|
|
685
685
|
|
686
686
|
|
687
687
|
# Determine whether current/locator identify the frame containing this running code.
|
688
|
-
#
|
688
|
+
#
|
689
689
|
# This is useful in proxy injection mode, where this code runs in every
|
690
690
|
# browser frame and window, and sometimes the selenium server needs to identify
|
691
691
|
# the "current" frame. In this case, when the test calls selectFrame, this
|
692
692
|
# routine is called for each frame to figure out which one has been selected.
|
693
693
|
# The selected frame will return true, while all others will return false.
|
694
|
-
#
|
694
|
+
#
|
695
695
|
#
|
696
696
|
# 'currentFrameString' is starting frame
|
697
697
|
# 'target' is new frame (which might be relative to the current one)
|
@@ -701,13 +701,13 @@ module Selenium
|
|
701
701
|
|
702
702
|
|
703
703
|
# Determine whether currentWindowString plus target identify the window containing this running code.
|
704
|
-
#
|
704
|
+
#
|
705
705
|
# This is useful in proxy injection mode, where this code runs in every
|
706
706
|
# browser frame and window, and sometimes the selenium server needs to identify
|
707
707
|
# the "current" window. In this case, when the test calls selectWindow, this
|
708
708
|
# routine is called for each window to figure out which one has been selected.
|
709
709
|
# The selected window will return true, while all others will return false.
|
710
|
-
#
|
710
|
+
#
|
711
711
|
#
|
712
712
|
# 'currentWindowString' is starting window
|
713
713
|
# 'target' is new window (which might be relative to the current one, e.g., "_parent")
|
@@ -725,43 +725,43 @@ module Selenium
|
|
725
725
|
end
|
726
726
|
|
727
727
|
|
728
|
-
#
|
728
|
+
#
|
729
729
|
# By default, Selenium's overridden window.confirm() function will
|
730
730
|
# return true, as if the user had manually clicked OK; after running
|
731
731
|
# this command, the next call to confirm() will return false, as if
|
732
732
|
# the user had clicked Cancel. Selenium will then resume using the
|
733
|
-
# default behavior for future confirmations, automatically returning
|
733
|
+
# default behavior for future confirmations, automatically returning
|
734
734
|
# true (OK) unless/until you explicitly call this command for each
|
735
735
|
# confirmation.
|
736
|
-
#
|
737
|
-
#
|
736
|
+
#
|
737
|
+
#
|
738
738
|
# Take note - every time a confirmation comes up, you must
|
739
739
|
# consume it with a corresponding getConfirmation, or else
|
740
740
|
# the next selenium operation will fail.
|
741
|
-
#
|
742
|
-
#
|
741
|
+
#
|
742
|
+
#
|
743
743
|
#
|
744
744
|
def choose_cancel_on_next_confirmation()
|
745
745
|
remote_control_command("chooseCancelOnNextConfirmation", [])
|
746
746
|
end
|
747
747
|
|
748
748
|
|
749
|
-
#
|
749
|
+
#
|
750
750
|
# Undo the effect of calling chooseCancelOnNextConfirmation. Note
|
751
751
|
# that Selenium's overridden window.confirm() function will normally automatically
|
752
752
|
# return true, as if the user had manually clicked OK, so you shouldn't
|
753
753
|
# need to use this command unless for some reason you need to change
|
754
754
|
# your mind prior to the next confirmation. After any confirmation, Selenium will resume using the
|
755
|
-
# default behavior for future confirmations, automatically returning
|
755
|
+
# default behavior for future confirmations, automatically returning
|
756
756
|
# true (OK) unless/until you explicitly call chooseCancelOnNextConfirmation for each
|
757
757
|
# confirmation.
|
758
|
-
#
|
759
|
-
#
|
758
|
+
#
|
759
|
+
#
|
760
760
|
# Take note - every time a confirmation comes up, you must
|
761
761
|
# consume it with a corresponding getConfirmation, or else
|
762
762
|
# the next selenium operation will fail.
|
763
|
-
#
|
764
|
-
#
|
763
|
+
#
|
764
|
+
#
|
765
765
|
#
|
766
766
|
def choose_ok_on_next_confirmation()
|
767
767
|
remote_control_command("chooseOkOnNextConfirmation", [])
|
@@ -800,11 +800,11 @@ module Selenium
|
|
800
800
|
|
801
801
|
|
802
802
|
# Has an alert occurred?
|
803
|
-
#
|
804
|
-
#
|
803
|
+
#
|
804
|
+
#
|
805
805
|
# This function never throws an exception
|
806
|
-
#
|
807
|
-
#
|
806
|
+
#
|
807
|
+
#
|
808
808
|
#
|
809
809
|
def is_alert_present()
|
810
810
|
return boolean_command("isAlertPresent", [])
|
@@ -812,11 +812,11 @@ module Selenium
|
|
812
812
|
|
813
813
|
|
814
814
|
# Has a prompt occurred?
|
815
|
-
#
|
816
|
-
#
|
815
|
+
#
|
816
|
+
#
|
817
817
|
# This function never throws an exception
|
818
|
-
#
|
819
|
-
#
|
818
|
+
#
|
819
|
+
#
|
820
820
|
#
|
821
821
|
def is_prompt_present()
|
822
822
|
return boolean_command("isPromptPresent", [])
|
@@ -824,11 +824,11 @@ module Selenium
|
|
824
824
|
|
825
825
|
|
826
826
|
# Has confirm() been called?
|
827
|
-
#
|
828
|
-
#
|
827
|
+
#
|
828
|
+
#
|
829
829
|
# This function never throws an exception
|
830
|
-
#
|
831
|
-
#
|
830
|
+
#
|
831
|
+
#
|
832
832
|
#
|
833
833
|
def is_confirmation_present()
|
834
834
|
return boolean_command("isConfirmationPresent", [])
|
@@ -836,7 +836,7 @@ module Selenium
|
|
836
836
|
|
837
837
|
|
838
838
|
# Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts.
|
839
|
-
#
|
839
|
+
#
|
840
840
|
# Getting an alert has the same effect as manually clicking OK. If an
|
841
841
|
# alert is generated but you do not consume it with getAlert, the next Selenium action
|
842
842
|
# will fail.
|
@@ -845,7 +845,7 @@ module Selenium
|
|
845
845
|
# Selenium does NOT support JavaScript alerts that are generated in a
|
846
846
|
# page's onload() event handler. In this case a visible dialog WILL be
|
847
847
|
# generated and Selenium will hang until someone manually clicks OK.
|
848
|
-
#
|
848
|
+
#
|
849
849
|
#
|
850
850
|
def get_alert()
|
851
851
|
return string_command("getAlert", [])
|
@@ -854,27 +854,27 @@ module Selenium
|
|
854
854
|
|
855
855
|
# Retrieves the message of a JavaScript confirmation dialog generated during
|
856
856
|
# the previous action.
|
857
|
-
#
|
858
|
-
#
|
857
|
+
#
|
858
|
+
#
|
859
859
|
# By default, the confirm function will return true, having the same effect
|
860
860
|
# as manually clicking OK. This can be changed by prior execution of the
|
861
|
-
# chooseCancelOnNextConfirmation command.
|
862
|
-
#
|
863
|
-
#
|
861
|
+
# chooseCancelOnNextConfirmation command.
|
862
|
+
#
|
863
|
+
#
|
864
864
|
# If an confirmation is generated but you do not consume it with getConfirmation,
|
865
865
|
# the next Selenium action will fail.
|
866
|
-
#
|
867
|
-
#
|
866
|
+
#
|
867
|
+
#
|
868
868
|
# NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible
|
869
869
|
# dialog.
|
870
|
-
#
|
871
|
-
#
|
870
|
+
#
|
871
|
+
#
|
872
872
|
# NOTE: Selenium does NOT support JavaScript confirmations that are
|
873
873
|
# generated in a page's onload() event handler. In this case a visible
|
874
874
|
# dialog WILL be generated and Selenium will hang until you manually click
|
875
875
|
# OK.
|
876
|
-
#
|
877
|
-
#
|
876
|
+
#
|
877
|
+
#
|
878
878
|
#
|
879
879
|
def get_confirmation()
|
880
880
|
return string_command("getConfirmation", [])
|
@@ -883,7 +883,7 @@ module Selenium
|
|
883
883
|
|
884
884
|
# Retrieves the message of a JavaScript question prompt dialog generated during
|
885
885
|
# the previous action.
|
886
|
-
#
|
886
|
+
#
|
887
887
|
# Successful handling of the prompt requires prior execution of the
|
888
888
|
# answerOnNextPrompt command. If a prompt is generated but you
|
889
889
|
# do not get/verify it, the next Selenium action will fail.
|
@@ -892,7 +892,7 @@ module Selenium
|
|
892
892
|
# NOTE: Selenium does NOT support JavaScript prompts that are generated in a
|
893
893
|
# page's onload() event handler. In this case a visible dialog WILL be
|
894
894
|
# generated and Selenium will hang until someone manually clicks OK.
|
895
|
-
#
|
895
|
+
#
|
896
896
|
#
|
897
897
|
def get_prompt()
|
898
898
|
return string_command("getPrompt", [])
|
@@ -951,14 +951,14 @@ module Selenium
|
|
951
951
|
|
952
952
|
# Gets the result of evaluating the specified JavaScript snippet. The snippet may
|
953
953
|
# have multiple lines, but only the result of the last line will be returned.
|
954
|
-
#
|
954
|
+
#
|
955
955
|
# Note that, by default, the snippet will run in the context of the "selenium"
|
956
956
|
# object itself, so <tt>this</tt> will refer to the Selenium object. Use <tt>window</tt> to
|
957
957
|
# refer to the window of your application, e.g. <tt>window.document.getElementById('foo')</tt>
|
958
958
|
# If you need to use
|
959
959
|
# a locator to refer to a single element in your application page, you can
|
960
960
|
# use <tt>this.browserbot.findElement("id=foo")</tt> where "id=foo" is your locator.
|
961
|
-
#
|
961
|
+
#
|
962
962
|
#
|
963
963
|
# 'script' is the JavaScript snippet to run
|
964
964
|
def get_eval(script)
|
@@ -1111,9 +1111,9 @@ module Selenium
|
|
1111
1111
|
|
1112
1112
|
|
1113
1113
|
# Returns the IDs of all buttons on the page.
|
1114
|
-
#
|
1114
|
+
#
|
1115
1115
|
# If a given button has no ID, it will appear as "" in this array.
|
1116
|
-
#
|
1116
|
+
#
|
1117
1117
|
#
|
1118
1118
|
def get_all_buttons()
|
1119
1119
|
return string_array_command("getAllButtons", [])
|
@@ -1121,9 +1121,9 @@ module Selenium
|
|
1121
1121
|
|
1122
1122
|
|
1123
1123
|
# Returns the IDs of all links on the page.
|
1124
|
-
#
|
1124
|
+
#
|
1125
1125
|
# If a given link has no ID, it will appear as "" in this array.
|
1126
|
-
#
|
1126
|
+
#
|
1127
1127
|
#
|
1128
1128
|
def get_all_links()
|
1129
1129
|
return string_array_command("getAllLinks", [])
|
@@ -1131,9 +1131,9 @@ module Selenium
|
|
1131
1131
|
|
1132
1132
|
|
1133
1133
|
# Returns the IDs of all input fields on the page.
|
1134
|
-
#
|
1134
|
+
#
|
1135
1135
|
# If a given field has no ID, it will appear as "" in this array.
|
1136
|
-
#
|
1136
|
+
#
|
1137
1137
|
#
|
1138
1138
|
def get_all_fields()
|
1139
1139
|
return string_array_command("getAllFields", [])
|
@@ -1163,7 +1163,7 @@ module Selenium
|
|
1163
1163
|
# cause some browsers to force the JavaScript to timeout.
|
1164
1164
|
# If the mouse speed is greater than the distance between the two dragged objects, we'll
|
1165
1165
|
# just send one "mousemove" at the start location and then one final one at the end location.
|
1166
|
-
#
|
1166
|
+
#
|
1167
1167
|
#
|
1168
1168
|
# 'pixels' is the number of pixels between "mousemove" events
|
1169
1169
|
def set_mouse_speed(pixels)
|
@@ -1301,10 +1301,10 @@ module Selenium
|
|
1301
1301
|
|
1302
1302
|
|
1303
1303
|
# Retrieves the text cursor position in the given input element or textarea; beware, this may not work perfectly on all browsers.
|
1304
|
-
#
|
1304
|
+
#
|
1305
1305
|
# Specifically, if the cursor/selection has been cleared by JavaScript, this command will tend to
|
1306
1306
|
# return the position of the last location of the cursor, even though the cursor is now gone from the page. This is filed as SEL-243.
|
1307
|
-
#
|
1307
|
+
#
|
1308
1308
|
# This method will fail if the specified element isn't an input element or textarea, or there is no cursor in the element.
|
1309
1309
|
#
|
1310
1310
|
# 'locator' is an element locator pointing to an input element or textarea
|
@@ -1314,10 +1314,10 @@ module Selenium
|
|
1314
1314
|
|
1315
1315
|
|
1316
1316
|
# Returns the specified expression.
|
1317
|
-
#
|
1317
|
+
#
|
1318
1318
|
# This is useful because of JavaScript preprocessing.
|
1319
1319
|
# It is used to generate commands like assertExpression and waitForExpression.
|
1320
|
-
#
|
1320
|
+
#
|
1321
1321
|
#
|
1322
1322
|
# 'expression' is the value to return
|
1323
1323
|
def get_expression(expression)
|
@@ -1372,7 +1372,7 @@ module Selenium
|
|
1372
1372
|
# evaluation engine. You'd want to do this for performance reasons in IE.
|
1373
1373
|
# However, this could break certain xpaths, for example an xpath that looks
|
1374
1374
|
# for an attribute whose value is NOT the empty string.
|
1375
|
-
#
|
1375
|
+
#
|
1376
1376
|
# The hope is that such xpaths are relatively rare, but the user should
|
1377
1377
|
# have the option of using them. Note that this only influences xpath
|
1378
1378
|
# evaluation when using the ajaxslt engine (i.e. not "javascript-xpath").
|
@@ -1386,12 +1386,12 @@ module Selenium
|
|
1386
1386
|
# Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
|
1387
1387
|
# The snippet may have multiple lines, but only the result of the last line
|
1388
1388
|
# will be considered.
|
1389
|
-
#
|
1389
|
+
#
|
1390
1390
|
# Note that, by default, the snippet will be run in the runner's test window, not in the window
|
1391
1391
|
# of your application. To get the window of your application, you can use
|
1392
1392
|
# the JavaScript snippet <tt>selenium.browserbot.getCurrentWindow()</tt>, and then
|
1393
1393
|
# run your JavaScript in there
|
1394
|
-
#
|
1394
|
+
#
|
1395
1395
|
#
|
1396
1396
|
# 'script' is the JavaScript snippet to run
|
1397
1397
|
# 'timeout' is a timeout in milliseconds, after which this command will return with an error
|
@@ -1401,9 +1401,9 @@ module Selenium
|
|
1401
1401
|
|
1402
1402
|
|
1403
1403
|
# Specifies the amount of time that Selenium will wait for actions to complete.
|
1404
|
-
#
|
1404
|
+
#
|
1405
1405
|
# Actions that require waiting include "open" and the "waitFor*" actions.
|
1406
|
-
#
|
1406
|
+
#
|
1407
1407
|
# The default timeout is 30 seconds.
|
1408
1408
|
#
|
1409
1409
|
# 'timeout' is a timeout in milliseconds, after which the action will return with an error
|
@@ -1413,14 +1413,14 @@ module Selenium
|
|
1413
1413
|
|
1414
1414
|
|
1415
1415
|
# Waits for a new page to load.
|
1416
|
-
#
|
1416
|
+
#
|
1417
1417
|
# You can use this command instead of the "AndWait" suffixes, "clickAndWait", "selectAndWait", "typeAndWait" etc.
|
1418
1418
|
# (which are only available in the JS API).
|
1419
1419
|
# Selenium constantly keeps track of new pages loading, and sets a "newPageLoaded"
|
1420
1420
|
# flag when it first notices a page load. Running any other Selenium command after
|
1421
1421
|
# turns the flag to false. Hence, if you want to wait for a page to load, you must
|
1422
1422
|
# wait immediately after a Selenium command that caused a page-load.
|
1423
|
-
#
|
1423
|
+
#
|
1424
1424
|
#
|
1425
1425
|
# 'timeout' is a timeout in milliseconds, after which this command will return with an error
|
1426
1426
|
def wait_for_page_to_load(timeout)
|
@@ -1429,11 +1429,11 @@ module Selenium
|
|
1429
1429
|
|
1430
1430
|
|
1431
1431
|
# Waits for a new frame to load.
|
1432
|
-
#
|
1433
|
-
# Selenium constantly keeps track of new pages and frames loading,
|
1432
|
+
#
|
1433
|
+
# Selenium constantly keeps track of new pages and frames loading,
|
1434
1434
|
# and sets a "newPageLoaded" flag when it first notices a page load.
|
1435
|
-
#
|
1436
|
-
#
|
1435
|
+
#
|
1436
|
+
#
|
1437
1437
|
# See waitForPageToLoad for more information.
|
1438
1438
|
#
|
1439
1439
|
# 'frameAddress' is FrameAddress from the server side
|
@@ -1480,7 +1480,7 @@ module Selenium
|
|
1480
1480
|
# need to delete it using the exact same path and domain that were used to create the cookie.
|
1481
1481
|
# If the path is wrong, or the domain is wrong, the cookie simply won't be deleted. Also
|
1482
1482
|
# note that specifying a domain that isn't a subset of the current domain will usually fail.
|
1483
|
-
#
|
1483
|
+
#
|
1484
1484
|
# Since there's no way to discover at runtime the original path and domain of a given cookie,
|
1485
1485
|
# we've added an option called 'recurse' to try all sub-domains of the current domain with
|
1486
1486
|
# all paths that are a subset of the current path. Beware; this option can be slow. In
|
@@ -1514,7 +1514,7 @@ module Selenium
|
|
1514
1514
|
end
|
1515
1515
|
|
1516
1516
|
|
1517
|
-
# Creates a new "script" tag in the body of the current test window, and
|
1517
|
+
# Creates a new "script" tag in the body of the current test window, and
|
1518
1518
|
# adds the specified text into the body of the command. Scripts run in
|
1519
1519
|
# this way can often be debugged more easily than scripts executed using
|
1520
1520
|
# Selenium's "getEval" command. Beware that JS exceptions thrown in these script
|
@@ -1531,16 +1531,16 @@ module Selenium
|
|
1531
1531
|
# Defines a new function for Selenium to locate elements on the page.
|
1532
1532
|
# For example,
|
1533
1533
|
# if you define the strategy "foo", and someone runs click("foo=blah"), we'll
|
1534
|
-
# run your function, passing you the string "blah", and click on the element
|
1534
|
+
# run your function, passing you the string "blah", and click on the element
|
1535
1535
|
# that your function
|
1536
1536
|
# returns, or throw an "Element not found" error if your function returns null.
|
1537
|
-
#
|
1537
|
+
#
|
1538
1538
|
# We'll pass three arguments to your function:
|
1539
1539
|
# * locator: the string the user passed in
|
1540
1540
|
# * inWindow: the currently selected window
|
1541
1541
|
# * inDocument: the currently selected document
|
1542
|
-
#
|
1543
|
-
#
|
1542
|
+
#
|
1543
|
+
#
|
1544
1544
|
# The function must return null if the element can't be found.
|
1545
1545
|
#
|
1546
1546
|
# 'strategyName' is the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation.
|
@@ -1584,11 +1584,11 @@ module Selenium
|
|
1584
1584
|
# to the document of the AUT, not the Selenium document. The following
|
1585
1585
|
# entities in the script content are replaced by the characters they
|
1586
1586
|
# represent:
|
1587
|
-
#
|
1587
|
+
#
|
1588
1588
|
# <
|
1589
1589
|
# >
|
1590
1590
|
# &
|
1591
|
-
#
|
1591
|
+
#
|
1592
1592
|
# The corresponding remove command is removeScript.
|
1593
1593
|
#
|
1594
1594
|
# 'scriptContent' is the Javascript content of the script to add
|
@@ -1648,10 +1648,10 @@ module Selenium
|
|
1648
1648
|
end
|
1649
1649
|
|
1650
1650
|
|
1651
|
-
# Downloads a screenshot of the browser current window canvas to a
|
1651
|
+
# Downloads a screenshot of the browser current window canvas to a
|
1652
1652
|
# based 64 encoded PNG file. The <em>entire</em> windows canvas is captured,
|
1653
1653
|
# including parts rendered outside of the current view port.
|
1654
|
-
#
|
1654
|
+
#
|
1655
1655
|
# Currently this only works in Mozilla and when running in chrome mode.
|
1656
1656
|
#
|
1657
1657
|
# 'kwargs' is A kwargs string that modifies the way the screenshot is captured. Example: "background=#CCFFDD". This may be useful to set for capturing screenshots of less-than-ideal layouts, for example where absolute positioning causes the calculation of the canvas dimension to fail and a black background is exposed (possibly obscuring black text).
|
@@ -1662,7 +1662,7 @@ module Selenium
|
|
1662
1662
|
|
1663
1663
|
# Kills the running Selenium Server and all browser sessions. After you run this command, you will no longer be able to send
|
1664
1664
|
# commands to the server; you can't remotely start the server once it has been stopped. Normally
|
1665
|
-
# you should prefer to run the "stop" command, which terminates the current browser session, rather than
|
1665
|
+
# you should prefer to run the "stop" command, which terminates the current browser session, rather than
|
1666
1666
|
# shutting down the entire server.
|
1667
1667
|
#
|
1668
1668
|
def shut_down_selenium_server()
|
@@ -1716,5 +1716,5 @@ module Selenium
|
|
1716
1716
|
|
1717
1717
|
|
1718
1718
|
end # GeneratedDriver
|
1719
|
-
end # Client
|
1719
|
+
end # Client
|
1720
1720
|
end # Selenium
|