webdriver 0.7.0 → 0.11.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/Gemfile.lock +1 -1
- data/README.md +8 -36
- data/lib/webdriver.rb +2 -0
- data/lib/webdriver/connection.rb +21 -12
- data/lib/webdriver/element.rb +12 -0
- data/lib/webdriver/errors.rb +6 -0
- data/lib/webdriver/session.rb +97 -7
- data/lib/webdriver/version.rb +1 -1
- data/lib/webdriver/window.rb +18 -5
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2cedf06258ad35e58eebf1a51682fae8eb58ab42a782e3f71fd8333bb87b350
|
4
|
+
data.tar.gz: 44583f74accd0d09c7ea419eaf373b61bf4e5ce2423ef628eecffe98f0cbd47b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8833fa8e7a38d4e80cdebd3dd314d5fb006c8b8f27f3366114654a4c26616dcce96e25056f2b86da6130a6703d86a77c442618762ff129c66391805643c895c5
|
7
|
+
data.tar.gz: efe90801a943b65bf9aca63ed8de6d6ccef273ce8c271a76bc2333aeb6db17cd2ec3d3d1f4ab35739cf06c47ff779fde74b8f75a4ac1af17adcd5168f8fcf022
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# webdriver
|
2
2
|
|
3
|
-
|
3
|
+
A Ruby https://www.w3.org/TR/webdriver/ driver
|
4
4
|
|
5
|
-
|
5
|
+
## Notes for implementators
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
gem 'webdriver'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install webdriver
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/webdriver.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
7
|
+
- `element.value!` is slow when compared to JavaScript `el.value = ...`
|
8
|
+
- element visibility helper `element.displayed?`
|
9
|
+
hitrate.
|
10
|
+
- Remember to use JavaScript multiline strings \` \` in `session.async_exec`
|
11
|
+
- looks like delaying 0.5s between element find and click improves
|
data/lib/webdriver.rb
CHANGED
data/lib/webdriver/connection.rb
CHANGED
@@ -3,6 +3,7 @@ module Webdriver
|
|
3
3
|
def initialize endpoint
|
4
4
|
uri = URI(endpoint)
|
5
5
|
@http = Net::HTTP.new uri.hostname, uri.port
|
6
|
+
@mutex = Mutex.new
|
6
7
|
end
|
7
8
|
|
8
9
|
def get path, headers={}
|
@@ -22,15 +23,17 @@ module Webdriver
|
|
22
23
|
body_json = body.to_json if body
|
23
24
|
Webdriver.debug [method, path, headers, body_json]
|
24
25
|
|
25
|
-
response =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
response = @mutex.synchronize do
|
27
|
+
case method
|
28
|
+
when :get
|
29
|
+
@http.get path
|
30
|
+
when :post
|
31
|
+
@http.post path, body_json
|
32
|
+
when :delete
|
33
|
+
@http.delete path, body_json
|
34
|
+
else
|
35
|
+
raise "err"
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
36
39
|
response_body = JSON.parse response.body
|
@@ -39,7 +42,11 @@ module Webdriver
|
|
39
42
|
session_id = response_body.dig "sessionId"
|
40
43
|
value = response_body.dig "value"
|
41
44
|
|
45
|
+
|
42
46
|
case status
|
47
|
+
when nil
|
48
|
+
# application_status_cache
|
49
|
+
value
|
43
50
|
when 0
|
44
51
|
# POST /session has different response structure than other calls
|
45
52
|
if method == :post && path == "/session"
|
@@ -47,16 +54,18 @@ module Webdriver
|
|
47
54
|
else # everything else works like this
|
48
55
|
value
|
49
56
|
end
|
57
|
+
when 10
|
58
|
+
raise Webdriver::StaleElementReferenceError
|
59
|
+
when 11
|
60
|
+
raise Webdriver::ElementNotInteractableError
|
50
61
|
when 1..nil
|
51
|
-
# 10: stale element reference: element is not attached to the page document
|
52
|
-
# 11: element not interactable
|
53
62
|
error_message = value.dig("message")
|
54
63
|
raise "#{status}: #{error_message}"
|
55
64
|
else
|
56
65
|
if method == :get && path == "/status"
|
57
66
|
value
|
58
67
|
else
|
59
|
-
raise
|
68
|
+
raise "unknown status: #{status}"
|
60
69
|
end
|
61
70
|
end
|
62
71
|
end
|
data/lib/webdriver/element.rb
CHANGED
@@ -14,10 +14,22 @@ module Webdriver
|
|
14
14
|
@id == other.id
|
15
15
|
end
|
16
16
|
|
17
|
+
def location_in_view
|
18
|
+
@connection.get "location_in_view"
|
19
|
+
end
|
20
|
+
|
21
|
+
def size
|
22
|
+
@connection.get "size"
|
23
|
+
end
|
24
|
+
|
17
25
|
def screenshot
|
18
26
|
@connection.get "screenshot"
|
19
27
|
end
|
20
28
|
|
29
|
+
def displayed?
|
30
|
+
@connection.get "displayed"
|
31
|
+
end
|
32
|
+
|
21
33
|
# checkbox
|
22
34
|
def selected?
|
23
35
|
@connection.get "selected"
|
data/lib/webdriver/session.rb
CHANGED
@@ -17,10 +17,97 @@ module Webdriver
|
|
17
17
|
value.map { |id| Webdriver::Window.new id, @connection }
|
18
18
|
end
|
19
19
|
|
20
|
+
def chromium_send_command_and_get_result! opts
|
21
|
+
# cmd: "Browser.getVersion", params: {}
|
22
|
+
@connection.post "chromium/send_command_and_get_result", {}, opts
|
23
|
+
end
|
24
|
+
|
25
|
+
def is_loading?
|
26
|
+
@connection.get "is_loading"
|
27
|
+
end
|
28
|
+
|
29
|
+
def page_freeze!
|
30
|
+
@connection.post "goog/page/freeze"
|
31
|
+
end
|
32
|
+
|
33
|
+
def page_resume!
|
34
|
+
# needs window min/max / timeout to resume
|
35
|
+
@connection.post "goog/page/resume"
|
36
|
+
end
|
37
|
+
|
38
|
+
# https://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/Keys
|
39
|
+
# enter "\ue007"
|
40
|
+
def keys= opts
|
41
|
+
@connection.post "keys", {}, opts
|
42
|
+
end
|
43
|
+
|
44
|
+
def moveto! opts
|
45
|
+
# xoffset, yoffset, element
|
46
|
+
@connection.post "moveto", {}, opts
|
47
|
+
end
|
48
|
+
|
49
|
+
def location
|
50
|
+
@connection.get "location"
|
51
|
+
end
|
52
|
+
|
53
|
+
def location! opts
|
54
|
+
#{location: {latitude: 20, longitude:20}}
|
55
|
+
@connection.post "location", {}, opts
|
56
|
+
end
|
57
|
+
|
58
|
+
def reporting_generate_test_report! opts
|
59
|
+
@connection.post "reporting/generate_test_report", {}, opts
|
60
|
+
end
|
61
|
+
|
62
|
+
def timeouts
|
63
|
+
@connection.get "timeouts"
|
64
|
+
end
|
65
|
+
|
66
|
+
def timeouts! opts
|
67
|
+
@connection.post "timeouts", {}, opts
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
def timeouts_async_script! opts
|
72
|
+
@connection.post "timeouts/async_script", {}, opts
|
73
|
+
end
|
74
|
+
|
75
|
+
def log_types
|
76
|
+
@connection.get "log/types"
|
77
|
+
end
|
78
|
+
|
79
|
+
def log type
|
80
|
+
@connection.post "log", {}, {
|
81
|
+
type: type
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def application_cache_status
|
86
|
+
@connection.get "application_cache/status"
|
87
|
+
end
|
88
|
+
|
20
89
|
# not implemented in chromedriver
|
21
|
-
|
22
|
-
|
23
|
-
|
90
|
+
def source
|
91
|
+
@connection.get "source"
|
92
|
+
end
|
93
|
+
|
94
|
+
def chromium_heap_snapshot
|
95
|
+
@connection.get "chromium/heap_snapshot"
|
96
|
+
end
|
97
|
+
|
98
|
+
def chromium_network_conditions
|
99
|
+
@connection.get "chromium/network_conditions"
|
100
|
+
end
|
101
|
+
|
102
|
+
def chromium_network_conditions! conditions
|
103
|
+
@connection.post "chromium/network_conditions", {}, conditions
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
def chromium_network_conditions_delete!
|
108
|
+
@connection.delete "chromium/network_conditions"
|
109
|
+
self
|
110
|
+
end
|
24
111
|
|
25
112
|
def dismiss_alert!
|
26
113
|
@connection.post "alert/dismiss"
|
@@ -149,15 +236,18 @@ module Webdriver
|
|
149
236
|
end
|
150
237
|
end
|
151
238
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# end
|
239
|
+
def print! opts
|
240
|
+
@connection.post "print", {} opts
|
241
|
+
end
|
156
242
|
|
157
243
|
def screenshot
|
158
244
|
@connection.get "screenshot"
|
159
245
|
end
|
160
246
|
|
247
|
+
def screenshot_full
|
248
|
+
@connection.get "screenshot/full"
|
249
|
+
end
|
250
|
+
|
161
251
|
# when moving with tab, or clicked
|
162
252
|
def active_element
|
163
253
|
el = @connection.get "element/active"
|
data/lib/webdriver/version.rb
CHANGED
data/lib/webdriver/window.rb
CHANGED
@@ -3,7 +3,20 @@ module Webdriver
|
|
3
3
|
attr_reader :id
|
4
4
|
def initialize(id, connection)
|
5
5
|
@id = id
|
6
|
-
@
|
6
|
+
@session_connection = connection
|
7
|
+
@connection = Webdriver::PrefixConnection.new "window/#{@id}", connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def size
|
11
|
+
@connection.get "size"
|
12
|
+
end
|
13
|
+
|
14
|
+
def position
|
15
|
+
@connection.get "position"
|
16
|
+
end
|
17
|
+
|
18
|
+
def position! opts
|
19
|
+
@connection.post "position", {}, opts
|
7
20
|
end
|
8
21
|
|
9
22
|
def maximize!
|
@@ -12,22 +25,22 @@ module Webdriver
|
|
12
25
|
end
|
13
26
|
|
14
27
|
def minimize!
|
15
|
-
@
|
28
|
+
@session_connection.post "window/minimize"
|
16
29
|
self
|
17
30
|
end
|
18
31
|
|
19
32
|
def rect! width: nil, height: nil, x: nil, y:nil
|
20
|
-
@
|
33
|
+
@session_connection.post "window/rect", {}, {
|
21
34
|
width: width,
|
22
35
|
height: height,
|
23
36
|
x: x,
|
24
37
|
y: y
|
25
|
-
}
|
38
|
+
}
|
26
39
|
self
|
27
40
|
end
|
28
41
|
|
29
42
|
def rect
|
30
|
-
@
|
43
|
+
@session_connection.get "window/rect"
|
31
44
|
end
|
32
45
|
|
33
46
|
def fullscreen!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/webdriver/connection.rb
|
158
158
|
- lib/webdriver/cookie.rb
|
159
159
|
- lib/webdriver/element.rb
|
160
|
+
- lib/webdriver/errors.rb
|
160
161
|
- lib/webdriver/prefix_connection.rb
|
161
162
|
- lib/webdriver/session.rb
|
162
163
|
- lib/webdriver/version.rb
|
@@ -166,7 +167,7 @@ homepage: https://www.github.com/matti/webdriver
|
|
166
167
|
licenses:
|
167
168
|
- MIT
|
168
169
|
metadata: {}
|
169
|
-
post_install_message:
|
170
|
+
post_install_message:
|
170
171
|
rdoc_options: []
|
171
172
|
require_paths:
|
172
173
|
- lib
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubygems_version: 3.0.6
|
185
|
-
signing_key:
|
186
|
+
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: webdriver
|
188
189
|
test_files: []
|