async-webdriver 0.1.2 → 0.2.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/async/webdriver/bridge/chrome.rb +81 -0
  4. data/lib/async/webdriver/bridge/firefox.rb +80 -0
  5. data/lib/async/webdriver/bridge/generic.rb +91 -0
  6. data/lib/async/webdriver/bridge/pool.rb +99 -0
  7. data/lib/async/webdriver/bridge/process_group.rb +77 -0
  8. data/lib/async/webdriver/bridge.rb +30 -0
  9. data/lib/async/webdriver/client.rb +71 -26
  10. data/lib/async/webdriver/element.rb +270 -17
  11. data/lib/async/webdriver/error.rb +214 -0
  12. data/lib/async/webdriver/locator.rb +127 -0
  13. data/lib/async/webdriver/request_helper.rb +120 -0
  14. data/lib/async/webdriver/scope/alerts.rb +40 -0
  15. data/lib/async/webdriver/scope/cookies.rb +43 -0
  16. data/lib/async/webdriver/scope/document.rb +41 -0
  17. data/lib/async/webdriver/scope/elements.rb +111 -0
  18. data/lib/async/webdriver/scope/fields.rb +66 -0
  19. data/lib/async/webdriver/scope/frames.rb +33 -0
  20. data/lib/async/webdriver/scope/navigation.rb +50 -0
  21. data/lib/async/webdriver/scope/printing.rb +22 -0
  22. data/lib/async/webdriver/scope/screen_capture.rb +23 -0
  23. data/lib/async/webdriver/scope/timeouts.rb +63 -0
  24. data/lib/async/webdriver/scope.rb +15 -0
  25. data/lib/async/webdriver/session.rb +107 -65
  26. data/lib/async/webdriver/version.rb +8 -3
  27. data/lib/async/webdriver/xpath.rb +29 -0
  28. data/lib/async/webdriver.rb +7 -12
  29. data/{LICENSE.txt → license.md} +6 -6
  30. data/readme.md +37 -0
  31. data.tar.gz.sig +0 -0
  32. metadata +71 -149
  33. metadata.gz.sig +0 -0
  34. data/.gitignore +0 -11
  35. data/.rspec +0 -3
  36. data/.ruby-gemset +0 -1
  37. data/.ruby-version +0 -1
  38. data/.travis.yml +0 -7
  39. data/Gemfile +0 -6
  40. data/Gemfile.lock +0 -103
  41. data/Guardfile +0 -45
  42. data/README.md +0 -3
  43. data/Rakefile +0 -6
  44. data/async-webdriver.gemspec +0 -37
  45. data/bin/console +0 -12
  46. data/bin/setup +0 -8
  47. data/examples/multiple_sessions.rb +0 -29
  48. data/lib/async/webdriver/connection.rb +0 -78
  49. data/lib/async/webdriver/connection_path.rb +0 -25
  50. data/lib/async/webdriver/execute.rb +0 -29
  51. data/lib/async/webdriver/session_creator.rb +0 -22
data/Gemfile.lock DELETED
@@ -1,103 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- async-webdriver (0.1.2)
5
- async-http
6
- selenium-webdriver
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- async (1.13.1)
12
- nio4r (~> 2.3)
13
- timers (~> 4.1)
14
- async-http (0.37.7)
15
- async (~> 1.6)
16
- async-io (~> 1.16)
17
- http-protocol (~> 0.10)
18
- async-io (1.17.2)
19
- async (~> 1.3)
20
- async-rspec (1.12.0)
21
- rspec (~> 3.0)
22
- byebug (10.0.2)
23
- childprocess (0.9.0)
24
- ffi (~> 1.0, >= 1.0.11)
25
- coderay (1.1.2)
26
- diff-lcs (1.3)
27
- ffi (1.9.25)
28
- formatador (0.2.5)
29
- guard (2.15.0)
30
- formatador (>= 0.2.4)
31
- listen (>= 2.7, < 4.0)
32
- lumberjack (>= 1.0.12, < 2.0)
33
- nenv (~> 0.1)
34
- notiffany (~> 0.0)
35
- pry (>= 0.9.12)
36
- shellany (~> 0.0)
37
- thor (>= 0.18.1)
38
- guard-compat (1.2.1)
39
- guard-rspec (4.7.3)
40
- guard (~> 2.1)
41
- guard-compat (~> 1.1)
42
- rspec (>= 2.99.0, < 4.0)
43
- http-hpack (0.1.1)
44
- http-protocol (0.10.1)
45
- http-hpack (~> 0.1.0)
46
- listen (3.1.5)
47
- rb-fsevent (~> 0.9, >= 0.9.4)
48
- rb-inotify (~> 0.9, >= 0.9.7)
49
- ruby_dep (~> 1.2)
50
- lumberjack (1.0.13)
51
- method_source (0.9.2)
52
- nenv (0.3.0)
53
- nio4r (2.3.1)
54
- notiffany (0.1.1)
55
- nenv (~> 0.1)
56
- shellany (~> 0.0)
57
- pry (0.12.2)
58
- coderay (~> 1.1.0)
59
- method_source (~> 0.9.0)
60
- pry-byebug (3.6.0)
61
- byebug (~> 10.0)
62
- pry (~> 0.10)
63
- rake (10.5.0)
64
- rb-fsevent (0.10.3)
65
- rb-inotify (0.10.0)
66
- ffi (~> 1.0)
67
- rspec (3.8.0)
68
- rspec-core (~> 3.8.0)
69
- rspec-expectations (~> 3.8.0)
70
- rspec-mocks (~> 3.8.0)
71
- rspec-core (3.8.0)
72
- rspec-support (~> 3.8.0)
73
- rspec-expectations (3.8.2)
74
- diff-lcs (>= 1.2.0, < 2.0)
75
- rspec-support (~> 3.8.0)
76
- rspec-mocks (3.8.0)
77
- diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.8.0)
79
- rspec-support (3.8.0)
80
- ruby_dep (1.5.0)
81
- rubyzip (1.2.2)
82
- selenium-webdriver (3.141.0)
83
- childprocess (~> 0.5)
84
- rubyzip (~> 1.2, >= 1.2.2)
85
- shellany (0.0.1)
86
- thor (0.20.3)
87
- timers (4.2.0)
88
-
89
- PLATFORMS
90
- ruby
91
-
92
- DEPENDENCIES
93
- async-rspec
94
- async-webdriver!
95
- bundler (~> 1.16)
96
- guard
97
- guard-rspec
98
- pry-byebug
99
- rake (~> 10.0)
100
- rspec (~> 3.0)
101
-
102
- BUNDLED WITH
103
- 1.17.2
data/Guardfile DELETED
@@ -1,45 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- ## Uncomment and set this to only include directories you want to watch
5
- # directories %w(app lib config test spec features) \
6
- # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
-
8
- ## Note: if you are using the `directories` clause above and you are not
9
- ## watching the project directory ('.'), then you will want to move
10
- ## the Guardfile to a watched dir and symlink it back, e.g.
11
- #
12
- # $ mkdir config
13
- # $ mv Guardfile config/
14
- # $ ln -s config/Guardfile .
15
- #
16
- # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
-
18
- # Note: The cmd option is now required due to the increasing number of ways
19
- # rspec may be run, below are examples of the most common uses.
20
- # * bundler: 'bundle exec rspec'
21
- # * bundler binstubs: 'bin/rspec'
22
- # * spring: 'bin/rspec' (This will use spring if running and you have
23
- # installed the spring binstubs per the docs)
24
- # * zeus: 'zeus rspec' (requires the server to be started separately)
25
- # * 'just' rspec: 'rspec'
26
-
27
- guard :rspec, cmd: "bundle exec rspec" do
28
- require "guard/rspec/dsl"
29
- dsl = Guard::RSpec::Dsl.new(self)
30
-
31
- # Feel free to open issues for suggestions and improvements
32
-
33
- # RSpec files
34
- rspec = dsl.rspec
35
- watch(rspec.spec_helper) { rspec.spec_dir }
36
- watch(rspec.spec_support) { rspec.spec_dir }
37
- watch(rspec.spec_files)
38
-
39
- # Ruby files
40
- ruby = dsl.ruby
41
- dsl.watch_spec_files_for(ruby.lib_files)
42
-
43
- watch(/.+\.rb$/) { |m| puts m }
44
- watch(/.+\.rb$/) { "spec" }
45
- end
data/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Async::Webdriver
2
-
3
- run `bundle exec ruby examples/two_sessions.rb`
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,37 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "async/webdriver/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "async-webdriver"
8
- spec.version = Async::Webdriver::VERSION
9
- spec.authors = ["Matti Paksula"]
10
- spec.email = ["matti.paksula@iki.fi"]
11
-
12
- spec.summary = "async-webdriver"
13
- spec.homepage = "https://github.com/matti/async-webdriver"
14
- spec.license = "MIT"
15
-
16
- # Specify which files should be added to the gem when it is released.
17
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
- end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_runtime_dependency "async-http"
26
- spec.add_runtime_dependency "selenium-webdriver"
27
-
28
- spec.add_development_dependency "bundler", "~> 1.16"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
31
-
32
- spec.add_development_dependency "guard"
33
- spec.add_development_dependency "guard-rspec"
34
- spec.add_development_dependency "async-rspec"
35
- spec.add_development_dependency "pry-byebug"
36
-
37
- end
data/bin/console DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "async/webdriver"
5
-
6
- client = Async::Webdriver::Client.new endpoint: "http://localhost:9515"
7
-
8
- require "pry"
9
- Pry.config.pager = false
10
-
11
- eval ARGV.join(" ") if ARGV.any?
12
- Pry.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,29 +0,0 @@
1
- require "async/webdriver"
2
-
3
- client = Async::Webdriver::Client.new endpoint: "http://localhost:9515"
4
-
5
- # before starting ensure no "window is closed" sessions are left behind in the chromedriver
6
- # this is because we use .first and .last in this example later on
7
- for s in client.sessions do
8
- s.delete!
9
- end
10
-
11
- example_com_session = client.session.create!
12
- example_com_session.navigate! "http://www.example.com"
13
-
14
- time_is_session = client.session.create!
15
- time_is_session.navigate! "http://www.time.is"
16
-
17
- # another way to acess example_com_session
18
- client.sessions.first.navigate! "http://www.reddit.com"
19
-
20
- # another way to acess time_is_session
21
- client.sessions.last.navigate! "http://www.twitter.com"
22
-
23
- # close print current urls and <title>s and close all
24
- for s in client.sessions
25
- puts s.url
26
- puts s.title
27
- s.delete!
28
- puts "--"
29
- end
@@ -1,78 +0,0 @@
1
- require "async"
2
- require "async/queue"
3
- require "async/http/internet"
4
- require "json"
5
- require "base64"
6
-
7
- module Async
8
- module Webdriver
9
- class Connection
10
- def initialize(endpoint:)
11
- @url = endpoint
12
- @internet = Async::HTTP::Internet.new
13
- end
14
-
15
- def call(method:, path:nil, headers:[], body:nil)
16
- task = begin
17
- Async::Task.current.async { async_call(method: method, path: path, headers: headers, body: body) }
18
- rescue RuntimeError => e
19
- raise unless e.message == "No async task available!"
20
-
21
- Async.run { async_call(method: method, path: path, headers: headers, body: body) }
22
- end
23
-
24
- task.wait
25
- end
26
-
27
- private
28
-
29
- def headers_with_basic_auth(headers)
30
- return headers if !@url.include?('@') || headers.any? { |h| h.start_with?('Authorization') }
31
-
32
- credentials = Base64.urlsafe_encode64(@url.split('@').first.gsub(/\w+:\/\//, ''), padding: false)
33
-
34
- headers.concat(["Authorization: Basic #{credentials}"])
35
- end
36
-
37
- def async_call(method:, path:, headers:, body:nil)
38
- body_array = case body
39
- when Hash
40
- [body.to_json]
41
- end
42
-
43
- path_or_url = if path
44
- "#{@url}/#{path}"
45
- else
46
- @url
47
- end
48
-
49
- r = @internet.call method.upcase, path_or_url, headers_with_basic_auth(headers), body_array
50
-
51
- body = begin
52
- JSON.parse r.read
53
- rescue JSON::ParserError => ex
54
- p ex
55
- exit 1
56
- end
57
-
58
- @internet.close
59
-
60
- status = body.dig "status"
61
- if status == 0
62
- # POST /session has different response structure than other calls
63
- if method == "post" && path == "session"
64
- {
65
- "id" => body.dig("sessionId"),
66
- "capabilities" => body.dig("value")
67
- }
68
- else # everything else works like this
69
- body.dig "value"
70
- end
71
- else
72
- p body
73
- raise "Error: #{status} - #{body.dig("value", "message")}"
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,25 +0,0 @@
1
- require "async"
2
- require "async/queue"
3
- require "async/http/internet"
4
- require "json"
5
-
6
- module Async
7
- module Webdriver
8
- class ConnectionPath
9
- def initialize(prefix, connection:)
10
- @connection = connection
11
- @prefix = prefix
12
- end
13
-
14
- def call(method:, path:nil, headers:[], body:nil)
15
- connection_path = if path
16
- "#{@prefix}/#{path}"
17
- else
18
- "#{@prefix}"
19
- end
20
-
21
- @connection.call method: method, path: connection_path, headers: headers, body: body
22
- end
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- module Async
2
- module Webdriver
3
- class Execute
4
- def initialize(connection:)
5
- @execute_connection = ConnectionPath.new "execute", connection: connection
6
- end
7
-
8
- def sync(script, args=[])
9
- #TODO: args?
10
- body = {
11
- script: script,
12
- args: args
13
- }
14
-
15
- @execute_connection.call method: "post", path: "sync", body: body
16
- end
17
-
18
- def async(script, args=[])
19
- #TODO: args?
20
- body = {
21
- script: script,
22
- args: args
23
- }
24
-
25
- @execute_connection.call method: "post", path: "async", body: body
26
- end
27
- end
28
- end
29
- end
@@ -1,22 +0,0 @@
1
- require "async/queue"
2
-
3
- module Async
4
- module Webdriver
5
- class SessionCreator
6
- def initialize(connection:, desired_capabilities: {})
7
- @connection = connection
8
- @desired_capabilities = desired_capabilities
9
- end
10
-
11
- def create!
12
- value = @connection.call(
13
- method: "post",
14
- path: "session",
15
- body: { desiredCapabilities: @desired_capabilities }
16
- )
17
-
18
- Session.new json: value, connection: @connection
19
- end
20
- end
21
- end
22
- end