webdriver 0.6.3 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 894b7fd4ac8ee563278d5d1d8c36bd68766fc15e21f7f9ecab6b56e1aee62b11
4
- data.tar.gz: 8e6e35aeda91198b961af903dfc709ee75ad9271f9667c5a31ab393c0ea9c802
3
+ metadata.gz: 231e634ca374f5b7bfcdfac83ebacad256fbcd14ff5bf85d953bb69c88a3e867
4
+ data.tar.gz: c094830f38527351332f4eb97cbff24cfb0999bb884e9a7474579c285f1b4754
5
5
  SHA512:
6
- metadata.gz: 8eafce628bd11a4c10e273b9e4c9ddc22d655566deffad5100e3a90785a8acb8d9454e80be47356aa1ae3e083e28f4c7023a514ddcb5fa17dcf71a69991adcd2
7
- data.tar.gz: 5d92bdf50ae82bfa57f673fb710c59a11239aad5ce83871f35b1771161ed0a437ec93857c06dd8e9dc810ecaadafa044b7375ed37900a4ef7526210b36654420
6
+ metadata.gz: ad451c9419316d6d2ce8abee8d8c17d1594e4fe3941dd5b897fde7d2f33f60efc25540d4e628f294f3c24e79e0e2d474830e58ba6c646cdbc50e0b77158c7bd1
7
+ data.tar.gz: a748ee63ca30d1c4869fb0caf0f962ec4594eb1c2f896b1072d04bd342c4a1fa393aaffce4dc262fb60c96e2c28242d2e4ec9ed6654b761c854ec6df16f3fb1e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webdriver (0.6.3)
4
+ webdriver (0.9.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,39 +1,11 @@
1
- # Webdriver
1
+ # webdriver
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/webdriver`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A Ruby https://www.w3.org/TR/webdriver/ driver
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Notes for implementators
6
6
 
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
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
@@ -11,6 +11,8 @@ module Webdriver
11
11
  end
12
12
 
13
13
  require_relative "webdriver/version"
14
+ require_relative "webdriver/errors"
15
+
14
16
  require_relative "webdriver/connection"
15
17
  require_relative "webdriver/prefix_connection"
16
18
 
@@ -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 = case method
26
- when :get
27
- @http.get path
28
- when :post
29
- @http.post path, body_json
30
- when :delete
31
- @http.delete path, body_json
32
- else
33
- raise "err"
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
@@ -47,8 +50,11 @@ module Webdriver
47
50
  else # everything else works like this
48
51
  value
49
52
  end
53
+ when 10
54
+ raise Webdriver::StaleElementReferenceError
55
+ when 11
56
+ raise Webdriver::ElementNotInteractableError
50
57
  when 1..nil
51
- # 10: stale element reference: element is not attached to the page document
52
58
  error_message = value.dig("message")
53
59
  raise "#{status}: #{error_message}"
54
60
  else
@@ -9,10 +9,19 @@ module Webdriver
9
9
  @connection = Webdriver::PrefixConnection.new "element/#{@id}", connection
10
10
  end
11
11
 
12
+ def ==(other)
13
+ return false unless other.is_a? Webdriver::Element
14
+ @id == other.id
15
+ end
16
+
12
17
  def screenshot
13
18
  @connection.get "screenshot"
14
19
  end
15
20
 
21
+ def displayed?
22
+ @connection.get "displayed"
23
+ end
24
+
16
25
  # checkbox
17
26
  def selected?
18
27
  @connection.get "selected"
@@ -26,6 +35,7 @@ module Webdriver
26
35
  def clear!
27
36
  @connection.post "clear"
28
37
  click!
38
+ self
29
39
  end
30
40
 
31
41
  def value! value
@@ -0,0 +1,6 @@
1
+ module Webdriver
2
+ # 10
3
+ class StaleElementReferenceError < StandardError; end
4
+ # 11
5
+ class ElementNotInteractableError < StandardError; end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Webdriver
2
- VERSION = "0.6.3"
2
+ VERSION = "0.9.1"
3
3
  end
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.6.3
4
+ version: 0.9.1
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-05-22 00:00:00.000000000 Z
11
+ date: 2020-06-15 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: []