watir 7.0.0.beta3 → 7.1.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.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +34 -0
- data/.github/workflows/edge.yml +28 -0
- data/.github/workflows/firefox.yml +35 -0
- data/.github/workflows/ie.yml +24 -0
- data/.github/workflows/safari.yml +27 -0
- data/.github/workflows/unit.yml +52 -0
- data/.rubocop.yml +1 -1
- data/CHANGES.md +26 -0
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +3 -3
- data/lib/watir/capabilities.rb +14 -0
- data/lib/watir/elements/date_field.rb +4 -1
- data/lib/watir/elements/date_time_field.rb +4 -1
- data/lib/watir/elements/element.rb +39 -13
- data/lib/watir/elements/table.rb +1 -1
- data/lib/watir/js_snippets/isElementInViewport.js +20 -0
- data/lib/watir/locators/element/selector_builder/xpath.rb +3 -2
- data/lib/watir/scroll.rb +2 -1
- data/lib/watir/version.rb +1 -1
- data/lib/watir/window.rb +22 -0
- data/lib/watirspec/remote_server.rb +2 -6
- data/spec/unit/capabilities_spec.rb +99 -5
- data/spec/watirspec/after_hooks_spec.rb +0 -2
- data/spec/watirspec/drag_and_drop_spec.rb +12 -0
- data/spec/watirspec/elements/date_time_field_spec.rb +3 -6
- data/spec/watirspec/elements/div_spec.rb +12 -1
- data/spec/watirspec/elements/element_spec.rb +91 -18
- data/spec/watirspec/html/scroll.html +8 -25
- data/spec/watirspec/html/sticky_elements.html +10 -0
- data/spec/watirspec/scroll_spec.rb +72 -42
- data/spec/watirspec/window_switching_spec.rb +40 -14
- data/spec/watirspec_helper.rb +2 -0
- data/watir.gemspec +3 -3
- metadata +24 -18
- data/.github/workflows/tests.yml +0 -104
- data/spec/watirspec/html/hover.html +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a3f59dcd9f56e63cf532cc2ba8c9605e8ffad78bd59d3f104e6677c9f5e20c
|
4
|
+
data.tar.gz: 1f1cb55a4270ebdce957f4a8dc33e76403eef391ed59e3179f4f6772595d3f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488c6b2f0a93a20390350da8b95025f9e33d2be9bb7bd84b130808906bca067860b3db6908c59961ef3914ccbb682d2d15d2418656749f8916a1416fa8c6cbb5
|
7
|
+
data.tar.gz: 64bc4a7b36c294a75ceb86c3fea21809dbefc158cbca08ba72dc6bf7b3b64d76f04b5c02130a8cce15e78d5156659cb317ee397e27d93d06e537e804695e425b
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Chrome Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
local-tests:
|
9
|
+
name: Local Tests
|
10
|
+
runs-on: ${{ matrix.os }}
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
15
|
+
ruby: [ 2.6, 3.0 ]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ./.github/actions/setup-linux
|
19
|
+
if: matrix.os == 'ubuntu-latest'
|
20
|
+
- uses: ./.github/actions/install-chrome
|
21
|
+
if: matrix.os == 'ubuntu-latest'
|
22
|
+
- run: |
|
23
|
+
echo "COVERAGE=true" >> $GITHUB_ENV
|
24
|
+
if: |
|
25
|
+
matrix.os == 'ubuntu-latest' ||
|
26
|
+
matrix.os == 'macos-latest'
|
27
|
+
- uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
- run: bundle install
|
31
|
+
- run: |
|
32
|
+
bundle exec rake spec:chrome
|
33
|
+
env:
|
34
|
+
DISPLAY: :99
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Edge Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
local-tests:
|
9
|
+
name: Local Tests
|
10
|
+
runs-on: ${{ matrix.os }}
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [macos-latest, windows-latest]
|
15
|
+
ruby: [ 2.6, 3.0 ]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- run: |
|
19
|
+
echo "COVERAGE=true" >> $GITHUB_ENV
|
20
|
+
if: matrix.os == 'macos-latest'
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
- run: bundle install
|
25
|
+
- run: |
|
26
|
+
bundle exec rake spec:edge
|
27
|
+
env:
|
28
|
+
DISPLAY: :99
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Firefox Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
local-tests:
|
9
|
+
name: Local Tests
|
10
|
+
runs-on: ${{ matrix.os }}
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
15
|
+
ruby: [ 2.6, 3.0 ]
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ./.github/actions/setup-linux
|
19
|
+
if: matrix.os == 'ubuntu-latest'
|
20
|
+
- uses: browser-actions/setup-firefox@latest
|
21
|
+
with:
|
22
|
+
firefox-version: '93.0'
|
23
|
+
- run: |
|
24
|
+
echo "COVERAGE=true" >> $GITHUB_ENV
|
25
|
+
if: |
|
26
|
+
matrix.os == 'ubuntu-latest' ||
|
27
|
+
matrix.os == 'macos-latest'
|
28
|
+
- uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
31
|
+
- run: bundle install
|
32
|
+
- run: |
|
33
|
+
bundle exec rake spec:firefox
|
34
|
+
env:
|
35
|
+
DISPLAY: :99
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: IE Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
local-tests:
|
9
|
+
name: Local Tests
|
10
|
+
runs-on: windows-latest
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby: [ 2.6, 3.0 ]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
- run: bundle install
|
21
|
+
- run: |
|
22
|
+
bundle exec rake spec:ie
|
23
|
+
env:
|
24
|
+
DISPLAY: :99
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Safari Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
local-tests:
|
9
|
+
name: Local Tests
|
10
|
+
runs-on: macos-latest
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
ruby: [ 2.6, 3.0 ]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: ./.github/actions/enable-safari
|
18
|
+
- run: |
|
19
|
+
echo "COVERAGE=true" >> $GITHUB_ENV
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- run: bundle install
|
24
|
+
- run: |
|
25
|
+
bundle exec rake spec:safari
|
26
|
+
env:
|
27
|
+
DISPLAY: :99
|
@@ -0,0 +1,52 @@
|
|
1
|
+
name: Unit Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
- push
|
5
|
+
- pull_request
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
documentation-test:
|
9
|
+
name: Yard Doctest
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6
|
16
|
+
- run: bundle install
|
17
|
+
- uses: ./.github/actions/install-chrome
|
18
|
+
- uses: ./.github/actions/setup-linux
|
19
|
+
- run: |
|
20
|
+
bundle exec rake yard:doctest
|
21
|
+
|
22
|
+
|
23
|
+
unit-test:
|
24
|
+
name: Unit Tests
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
strategy:
|
27
|
+
fail-fast: false
|
28
|
+
matrix:
|
29
|
+
ruby: ['2.6', '2.7', '3.0']
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
- uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
- run: bundle install
|
36
|
+
- uses: ./.github/actions/install-chrome
|
37
|
+
- uses: ./.github/actions/setup-linux
|
38
|
+
- run: |
|
39
|
+
bundle exec rake spec:unit
|
40
|
+
env:
|
41
|
+
DISPLAY: :99
|
42
|
+
|
43
|
+
linter-test:
|
44
|
+
name: Rubocop Tests
|
45
|
+
runs-on: ubuntu-latest
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
- uses: ruby/setup-ruby@v1
|
49
|
+
with:
|
50
|
+
ruby-version: 2.6
|
51
|
+
- run: bundle install
|
52
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
### 7.1.0 (2021-11-15)
|
2
|
+
|
3
|
+
* Add automatic scroll to `Element#click` with method parameters to ensure element is in viewport
|
4
|
+
* Provide `:scroll_to` parameter for element methods implemented with `Actions` class (thanks osadasami #948, #949)
|
5
|
+
* Allow `:scroll_to` parameter to accept `nil` argument to avoid automatic scrolling
|
6
|
+
* Implement `Element#in_viewport?`
|
7
|
+
* Fix but where `Scroll#to` for `Browser` with `:center` argument did not scroll to center of page
|
8
|
+
* Change `Element#obscured?` to only scroll when element out of viewport and then scroll to bottom instead of top
|
9
|
+
|
10
|
+
### 7.0.0 (2021-10-18)
|
11
|
+
|
12
|
+
* Requires Selenium 4.0.0+
|
13
|
+
* Requires Ruby 2.6+
|
14
|
+
* Implement `Window#minimize`
|
15
|
+
* Implement `Window#full_screen`
|
16
|
+
|
17
|
+
### 7.0.0.beta5 (2021-08-02)
|
18
|
+
|
19
|
+
* Add support for passing in Proxy and proxy Hash to Capabilities (#933)
|
20
|
+
* Trigger change event when setting values on date and date-time fields (#938)
|
21
|
+
* Allow user to obtain Capabilities instance from Browser instance
|
22
|
+
|
23
|
+
### 7.0.0.beta4 (2021-05-29)
|
24
|
+
|
25
|
+
* Fix Bug in using negative class names within a collection (#934)
|
26
|
+
|
1
27
|
### 7.0.0.beta3 (2021-05-05)
|
2
28
|
|
3
29
|
* Fix Bug preventing proper use of vendor extension capabilities
|
data/lib/watir/browser.rb
CHANGED
@@ -12,7 +12,7 @@ module Watir
|
|
12
12
|
include Scrolling
|
13
13
|
|
14
14
|
attr_writer :default_context, :original_window, :locator_namespace, :timer
|
15
|
-
attr_reader :driver, :after_hooks
|
15
|
+
attr_reader :driver, :after_hooks, :capabilities
|
16
16
|
alias wd driver # ensures duck typing with Watir::Element
|
17
17
|
|
18
18
|
class << self
|
@@ -42,8 +42,8 @@ module Watir
|
|
42
42
|
def initialize(browser = :chrome, *args)
|
43
43
|
case browser
|
44
44
|
when ::Symbol, String
|
45
|
-
|
46
|
-
@driver = Selenium::WebDriver.for(
|
45
|
+
@capabilities = Capabilities.new(browser, *args)
|
46
|
+
@driver = Selenium::WebDriver.for(*@capabilities.to_args)
|
47
47
|
when Selenium::WebDriver::Driver
|
48
48
|
@driver = browser
|
49
49
|
else
|
data/lib/watir/capabilities.rb
CHANGED
@@ -74,12 +74,26 @@ module Watir
|
|
74
74
|
end
|
75
75
|
|
76
76
|
options.unhandled_prompt_behavior ||= :ignore
|
77
|
+
process_proxy_options(options)
|
77
78
|
browser_specific_options(options)
|
78
79
|
raise ArgumentError, "#{@options} are unrecognized arguments for Browser constructor" unless @options.empty?
|
79
80
|
|
80
81
|
vendor_caps << options
|
81
82
|
end
|
82
83
|
|
84
|
+
def process_proxy_options(options)
|
85
|
+
proxy = @options.delete(:proxy)
|
86
|
+
return if proxy.nil?
|
87
|
+
|
88
|
+
proxy &&= Selenium::WebDriver::Proxy.new(proxy) if proxy.is_a?(Hash)
|
89
|
+
|
90
|
+
unless proxy.is_a?(Selenium::WebDriver::Proxy)
|
91
|
+
raise TypeError, "#{proxy} needs to be Selenium Proxy or Hash instance"
|
92
|
+
end
|
93
|
+
|
94
|
+
options.proxy = proxy
|
95
|
+
end
|
96
|
+
|
83
97
|
def process_vendor_capabilities(opts)
|
84
98
|
return [] unless opts.is_a? Hash
|
85
99
|
|
@@ -11,7 +11,10 @@ module Watir
|
|
11
11
|
raise ArgumentError, message unless [Date, ::Time].include?(date.class)
|
12
12
|
|
13
13
|
date_string = date.strftime('%Y-%m-%d')
|
14
|
-
element_call(:wait_for_writable)
|
14
|
+
element_call(:wait_for_writable) do
|
15
|
+
execute_js(:setValue, @element, date_string)
|
16
|
+
execute_js(:fireEvent, @element, :change)
|
17
|
+
end
|
15
18
|
end
|
16
19
|
alias set set!
|
17
20
|
alias value= set
|
@@ -11,7 +11,10 @@ module Watir
|
|
11
11
|
raise ArgumentError, message unless [DateTime, ::Time].include?(date.class)
|
12
12
|
|
13
13
|
date_time_string = date.strftime('%Y-%m-%dT%H:%M')
|
14
|
-
element_call(:wait_for_writable)
|
14
|
+
element_call(:wait_for_writable) do
|
15
|
+
execute_js(:setValue, @element, date_time_string)
|
16
|
+
execute_js(:fireEvent, @element, :change)
|
17
|
+
end
|
15
18
|
end
|
16
19
|
alias set set!
|
17
20
|
alias value= set
|
@@ -146,9 +146,10 @@ module Watir
|
|
146
146
|
# @param [:shift, :alt, :control, :command, :meta] modifiers to press while clicking.
|
147
147
|
#
|
148
148
|
|
149
|
-
def click(*modifiers)
|
149
|
+
def click(*modifiers, scroll_to: :center)
|
150
150
|
element_call(:wait_for_enabled) do
|
151
151
|
if modifiers.any?
|
152
|
+
scroll.to(scroll_to) if scroll_to
|
152
153
|
action = driver.action
|
153
154
|
modifiers.each { |mod| action.key_down mod }
|
154
155
|
action.click @element
|
@@ -202,10 +203,13 @@ module Watir
|
|
202
203
|
# @example
|
203
204
|
# browser.element(name: "new_user_button").double_click
|
204
205
|
#
|
206
|
+
# @example
|
207
|
+
# browser.element(name: "new_user_button").double_click(scroll_to: :center)
|
208
|
+
#
|
205
209
|
|
206
|
-
def double_click
|
210
|
+
def double_click(scroll_to: :center)
|
207
211
|
element_call(:wait_for_present) do
|
208
|
-
scroll.to
|
212
|
+
scroll.to(scroll_to) if scroll_to
|
209
213
|
driver.action.double_click(@element).perform
|
210
214
|
end
|
211
215
|
browser.after_hooks.run
|
@@ -237,12 +241,16 @@ module Watir
|
|
237
241
|
# @example Click an element with several modifier keys pressed
|
238
242
|
# browser.element(name: "new_user_button").right_click(:shift, :alt)
|
239
243
|
#
|
240
|
-
# @
|
244
|
+
# @example Click an element with several modifier keys pressed and scroll position
|
245
|
+
# browser.element(name: "new_user_button").right_click(:shift, :alt, scroll_to: :center)
|
246
|
+
#
|
247
|
+
# @param [:shift, :alt, :control, :command, :meta, scroll_to: :center]
|
248
|
+
# modifiers to press while right clicking and scroll position.
|
241
249
|
#
|
242
250
|
|
243
|
-
def right_click(*modifiers)
|
251
|
+
def right_click(*modifiers, scroll_to: :center)
|
244
252
|
element_call(:wait_for_present) do
|
245
|
-
scroll.to
|
253
|
+
scroll.to(scroll_to) if scroll_to
|
246
254
|
action = driver.action
|
247
255
|
if modifiers.any?
|
248
256
|
modifiers.each { |mod| action.key_down mod }
|
@@ -264,10 +272,13 @@ module Watir
|
|
264
272
|
# @example
|
265
273
|
# browser.element(name: "new_user_button").hover
|
266
274
|
#
|
275
|
+
# @example
|
276
|
+
# browser.element(name: "new_user_button").hover(scroll_to: :center)
|
277
|
+
#
|
267
278
|
|
268
|
-
def hover
|
279
|
+
def hover(scroll_to: :center)
|
269
280
|
element_call(:wait_for_present) do
|
270
|
-
scroll.to
|
281
|
+
scroll.to(scroll_to) if scroll_to
|
271
282
|
driver.action.move_to(@element).perform
|
272
283
|
end
|
273
284
|
end
|
@@ -280,13 +291,14 @@ module Watir
|
|
280
291
|
# a = browser.div(id: "draggable")
|
281
292
|
# b = browser.div(id: "droppable")
|
282
293
|
# a.drag_and_drop_on b
|
294
|
+
# a.drag_and_drop_on b, scroll_to: :center
|
283
295
|
#
|
284
296
|
|
285
|
-
def drag_and_drop_on(other)
|
297
|
+
def drag_and_drop_on(other, scroll_to: :center)
|
286
298
|
assert_is_element other
|
287
299
|
|
288
300
|
value = element_call(:wait_for_present) do
|
289
|
-
scroll.to
|
301
|
+
scroll.to(scroll_to) if scroll_to
|
290
302
|
driver.action
|
291
303
|
.drag_and_drop(@element, other.wd)
|
292
304
|
.perform
|
@@ -302,13 +314,17 @@ module Watir
|
|
302
314
|
# @example
|
303
315
|
# browser.div(id: "draggable").drag_and_drop_by 100, 25
|
304
316
|
#
|
317
|
+
# @example
|
318
|
+
# browser.div(id: "draggable").drag_and_drop_by 100, 25, scroll_to: :center
|
319
|
+
#
|
305
320
|
# @param [Integer] right_by
|
306
321
|
# @param [Integer] down_by
|
322
|
+
# @param [Symbol] scroll_to
|
307
323
|
#
|
308
324
|
|
309
|
-
def drag_and_drop_by(right_by, down_by)
|
325
|
+
def drag_and_drop_by(right_by, down_by, scroll_to: :center)
|
310
326
|
element_call(:wait_for_present) do
|
311
|
-
scroll.to
|
327
|
+
scroll.to(scroll_to) if scroll_to
|
312
328
|
driver.action
|
313
329
|
.drag_and_drop_by(@element, right_by, down_by)
|
314
330
|
.perform
|
@@ -530,11 +546,21 @@ module Watir
|
|
530
546
|
element_call do
|
531
547
|
return true unless present?
|
532
548
|
|
533
|
-
scroll.to
|
549
|
+
scroll.to :bottom unless in_viewport?
|
534
550
|
execute_js(:elementObscured, self)
|
535
551
|
end
|
536
552
|
end
|
537
553
|
|
554
|
+
#
|
555
|
+
# Returns true if the top of the element is visible in the viewport.
|
556
|
+
#
|
557
|
+
# @return [Boolean]
|
558
|
+
#
|
559
|
+
|
560
|
+
def in_viewport?
|
561
|
+
element_call { execute_js(:isElementInViewport, @element) }
|
562
|
+
end
|
563
|
+
|
538
564
|
#
|
539
565
|
# Returns given style property of this element.
|
540
566
|
#
|
data/lib/watir/elements/table.rb
CHANGED
@@ -29,7 +29,7 @@ module Watir
|
|
29
29
|
all_rows = rows.locate
|
30
30
|
header_row = all_rows.first || raise(Error, 'no rows in table')
|
31
31
|
|
32
|
-
all_rows.entries[1
|
32
|
+
all_rows.entries[1..].map do |row|
|
33
33
|
cell_size_check(header_row, row)
|
34
34
|
Hash[headers(header_row).map(&:text).zip(row.cells.map(&:text))]
|
35
35
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
function(){
|
2
|
+
var el = arguments[0];
|
3
|
+
var top = el.offsetTop;
|
4
|
+
var left = el.offsetLeft;
|
5
|
+
var width = el.offsetWidth;
|
6
|
+
var height = el.offsetHeight;
|
7
|
+
|
8
|
+
while (el.offsetParent) {
|
9
|
+
el = el.offsetParent;
|
10
|
+
top += el.offsetTop;
|
11
|
+
left += el.offsetLeft;
|
12
|
+
}
|
13
|
+
|
14
|
+
return (
|
15
|
+
top < (window.pageYOffset + window.innerHeight) &&
|
16
|
+
left < (window.pageXOffset + window.innerWidth) &&
|
17
|
+
(top + height) > window.pageYOffset &&
|
18
|
+
(left + width) > window.pageXOffset
|
19
|
+
);
|
20
|
+
}
|
@@ -172,7 +172,7 @@ module Watir
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def starts_with?(results, regexp)
|
175
|
-
regexp.source[0] == '^' && results.first == regexp.source[1
|
175
|
+
regexp.source[0] == '^' && results.first == regexp.source[1..]
|
176
176
|
end
|
177
177
|
|
178
178
|
def add_to_matching(key, regexp, results = nil)
|
@@ -218,7 +218,8 @@ module Watir
|
|
218
218
|
|
219
219
|
def equal_pair(key, value)
|
220
220
|
if key == :class
|
221
|
-
negate_xpath = value =~ /^!/
|
221
|
+
negate_xpath = value =~ /^!/
|
222
|
+
value = value[1..] if negate_xpath
|
222
223
|
expression = "contains(concat(' ', @class, ' '), #{XpathSupport.escape " #{value} "})"
|
223
224
|
|
224
225
|
negate_xpath ? "not(#{expression})" : expression
|
data/lib/watir/scroll.rb
CHANGED
@@ -58,7 +58,8 @@ module Watir
|
|
58
58
|
when :top, :start
|
59
59
|
'window.scrollTo(0, 0);'
|
60
60
|
when :center
|
61
|
-
'
|
61
|
+
y = '(document.body.scrollHeight - window.innerHeight) / 2 + document.body.getBoundingClientRect().top'
|
62
|
+
"window.scrollTo(window.outerWidth / 2, #{y});"
|
62
63
|
when :bottom, :end
|
63
64
|
'window.scrollTo(0, document.body.scrollHeight);'
|
64
65
|
when Array
|
data/lib/watir/version.rb
CHANGED
data/lib/watir/window.rb
CHANGED
@@ -92,6 +92,28 @@ module Watir
|
|
92
92
|
use { @driver.manage.window.maximize }
|
93
93
|
end
|
94
94
|
|
95
|
+
#
|
96
|
+
# Minimize window.
|
97
|
+
#
|
98
|
+
# @example
|
99
|
+
# browser.window.minimize
|
100
|
+
#
|
101
|
+
|
102
|
+
def minimize
|
103
|
+
use { @driver.manage.window.minimize }
|
104
|
+
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Make window full screen.
|
108
|
+
#
|
109
|
+
# @example
|
110
|
+
# browser.window.full_screen
|
111
|
+
#
|
112
|
+
|
113
|
+
def full_screen
|
114
|
+
use { @driver.manage.window.full_screen }
|
115
|
+
end
|
116
|
+
|
95
117
|
#
|
96
118
|
# Returns true if window exists.
|
97
119
|
#
|
@@ -20,14 +20,10 @@ module WatirSpec
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def jar
|
23
|
-
if ENV['LOCAL_SELENIUM']
|
24
|
-
local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
|
25
|
-
end
|
26
|
-
|
27
23
|
if File.exist?(ENV['REMOTE_SERVER_BINARY'] || '')
|
28
24
|
ENV['REMOTE_SERVER_BINARY']
|
29
|
-
elsif ENV['LOCAL_SELENIUM']
|
30
|
-
|
25
|
+
elsif ENV['LOCAL_SELENIUM']
|
26
|
+
File.expand_path('../selenium/bazel-bin/java/server/src/org/openqa/selenium/grid/selenium_server_deploy.jar')
|
31
27
|
elsif !Dir.glob('*selenium*.jar').empty?
|
32
28
|
Dir.glob('*selenium*.jar').first
|
33
29
|
else
|