selenium-webdriver 3.0.0.beta3.1 → 3.0.0.beta4.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.
@@ -26,28 +26,17 @@ module Selenium
26
26
 
27
27
  class Bridge < Remote::Bridge
28
28
  def initialize(opts = {})
29
- http_client = opts.delete(:http_client)
30
- caps = opts.delete(:desired_capabilities) { Remote::Capabilities.phantomjs }
29
+ port = opts.delete(:port) || Service::DEFAULT_PORT
30
+ opts[:desired_capabilities] ||= Remote::Capabilities.phantomjs
31
31
 
32
- if opts.key?(:url)
33
- url = opts.delete(:url)
34
- else
35
- args = opts.delete(:args) || caps['phantomjs.cli.args']
36
-
37
- @service = Service.new(PhantomJS.path, Service::DEFAULT_PORT, *args)
32
+ unless opts.key?(:url)
33
+ args = opts.delete(:args) || opts[:desired_capabilities]['phantomjs.cli.args']
34
+ @service = Service.new(PhantomJS.path, port, *args)
38
35
  @service.start
39
-
40
- url = @service.uri
36
+ opts[:url] = @service.uri
41
37
  end
42
38
 
43
- remote_opts = {
44
- url: url,
45
- desired_capabilities: caps
46
- }
47
-
48
- remote_opts[:http_client] = http_client if http_client
49
-
50
- super(remote_opts)
39
+ super(opts)
51
40
  end
52
41
 
53
42
  def browser
@@ -62,9 +62,10 @@ module Selenium
62
62
  def initialize(opts = {})
63
63
  opts = opts.dup
64
64
 
65
+ port = opts.delete(:port) || 4444
65
66
  http_client = opts.delete(:http_client) { Http::Default.new }
66
67
  desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.firefox }
67
- url = opts.delete(:url) { "http://#{Platform.localhost}:4444/wd/hub" }
68
+ url = opts.delete(:url) { "http://#{Platform.localhost}:#{port}/wd/hub" }
68
69
 
69
70
  unless opts.empty?
70
71
  raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
@@ -63,9 +63,7 @@ module Selenium
63
63
  new({
64
64
  browser_name: 'chrome',
65
65
  javascript_enabled: true,
66
- css_selectors_enabled: true,
67
- loggingPrefs: {browser: 'ALL',
68
- driver: 'ALL'}
66
+ css_selectors_enabled: true
69
67
  }.merge(opts))
70
68
  end
71
69
 
@@ -67,9 +67,10 @@ module Selenium
67
67
 
68
68
  opts = opts.dup
69
69
 
70
+ port = opts.delete(:port) || 4444
70
71
  http_client = opts.delete(:http_client) { Http::Default.new }
71
72
  desired_capabilities = opts.delete(:desired_capabilities) { W3CCapabilities.firefox }
72
- url = opts.delete(:url) { "http://#{Platform.localhost}:4444/wd/hub" }
73
+ url = opts.delete(:url) { "http://#{Platform.localhost}:#{port}/wd/hub" }
73
74
 
74
75
  desired_capabilities = W3CCapabilities.send(desired_capabilities) if desired_capabilities.is_a? Symbol
75
76
 
@@ -24,9 +24,8 @@ module Selenium
24
24
  module WebDriver
25
25
  module Safari
26
26
  MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
27
- Unable to find safari extension. Please download the file from
28
- http://www.seleniumhq.org/download/ and place it
29
- somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/SafariDriver.
27
+ Unable to find Apple's safaridriver which comes with Safari 10.
28
+ More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
30
29
  ERROR
31
30
 
32
31
  class << self
@@ -36,22 +35,10 @@ module Selenium
36
35
  end
37
36
 
38
37
  def path
39
- @path ||= (
40
- path = case Platform.os
41
- when :windows
42
- Platform.find_in_program_files('Safari\\Safari.exe')
43
- when :macosx
44
- '/Applications/Safari.app/Contents/MacOS/Safari'
45
- else
46
- Platform.find_binary('Safari')
47
- end
48
-
49
- unless File.file?(path) && File.executable?(path)
50
- raise Error::WebDriverError, MISSING_TEXT
51
- end
52
-
53
- path
54
- )
38
+ @path ||= '/Applications/Safari.app/Contents/MacOS/Safari'
39
+ return @path if File.file?(@path) && File.executable?(@path)
40
+ raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os == :macosx
41
+ raise Error::WebDriverError, 'Unable to find Safari'
55
42
  end
56
43
 
57
44
  def resource_path
@@ -64,18 +51,14 @@ module Selenium
64
51
  end
65
52
 
66
53
  def driver_path
67
- @driver_path || '/usr/bin/safaridriver'
54
+ @driver_path ||= '/usr/bin/safaridriver'
55
+ return @driver_path if File.file?(@driver_path) && File.executable?(@driver_path)
56
+ raise Error::WebDriverError, MISSING_TEXT
68
57
  end
69
58
  end
70
59
  end # Safari
71
60
  end # WebDriver
72
61
  end # Selenium
73
62
 
74
- require 'selenium/webdriver/safari/browser'
75
- require 'selenium/webdriver/safari/server'
76
- require 'selenium/webdriver/safari/options'
77
- require 'selenium/webdriver/safari/legacy_bridge'
78
- require 'selenium/webdriver/safari/apple_bridge'
63
+ require 'selenium/webdriver/safari/bridge'
79
64
  require 'selenium/webdriver/safari/service'
80
-
81
- Selenium::WebDriver::Safari::Bridge = Selenium::WebDriver::Safari::LegacyBridge
@@ -21,16 +21,17 @@ module Selenium
21
21
  module WebDriver
22
22
  module Safari
23
23
  # @api private
24
- class AppleBridge < Remote::Bridge
24
+ class Bridge < Remote::Bridge
25
25
  def initialize(opts = {})
26
26
  opts[:desired_capabilities] ||= Remote::Capabilities.safari
27
+ port = opts.delete(:port) || Service::DEFAULT_PORT
28
+ service_args = opts.delete(:service_args) || {}
27
29
 
28
- @service = Service.new(Safari.driver_path, Service::DEFAULT_PORT, *extract_service_args(opts))
30
+ @service = Service.new(Safari.driver_path, port, *extract_service_args(service_args))
29
31
  @service.start
30
-
31
32
  opts[:url] = @service.uri
32
33
 
33
- super
34
+ super(opts)
34
35
  end
35
36
 
36
37
  def quit
@@ -41,11 +42,10 @@ module Selenium
41
42
 
42
43
  private
43
44
 
44
- def extract_service_args(opts)
45
- service_log_path = opts.delete(:service_log_path)
46
- service_log_path ? ["--log-path=#{service_log_path}"] : []
45
+ def extract_service_args(args = {})
46
+ args.key?(:port) ? ["--port=#{args[:port]}"] : []
47
47
  end
48
- end # AppleBridge
48
+ end # Bridge
49
49
  end # Safari
50
50
  end # WebDriver
51
51
  end # Selenium
@@ -5,7 +5,7 @@ raise "cwd must be #{root} when reading gemspec" if root != Dir.pwd
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'selenium-webdriver'
8
- s.version = '3.0.0.beta3.1'
8
+ s.version = '3.0.0.beta4.0'
9
9
 
10
10
  s.authors = ['Alex Rodionov', 'Titus Fortner']
11
11
  s.email = ['p0deje@gmail.com', 'titusfortner@gmail.com']
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 3.0.0.beta3.1
5
+ version: 3.0.0.beta4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alex Rodionov
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2016-09-03 00:00:00 -05:00
14
+ date: 2016-10-04 00:00:00 -05:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -219,13 +219,8 @@ files:
219
219
  - lib/selenium/webdriver/remote/http/curb.rb
220
220
  - lib/selenium/webdriver/remote/http/default.rb
221
221
  - lib/selenium/webdriver/remote/http/persistent.rb
222
- - lib/selenium/webdriver/safari/apple_bridge.rb
223
- - lib/selenium/webdriver/safari/browser.rb
224
- - lib/selenium/webdriver/safari/legacy_bridge.rb
225
- - lib/selenium/webdriver/safari/options.rb
226
- - lib/selenium/webdriver/safari/server.rb
222
+ - lib/selenium/webdriver/safari/bridge.rb
227
223
  - lib/selenium/webdriver/safari/service.rb
228
- - lib/selenium/webdriver/safari/resources/client.js
229
224
  - lib/selenium/webdriver/support/abstract_event_listener.rb
230
225
  - lib/selenium/webdriver/support/block_event_listener.rb
231
226
  - lib/selenium/webdriver/support/color.rb
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Safari
23
- class Browser
24
- def start(*args)
25
- Platform.exit_hook { stop } # make sure we don't leave the browser running
26
-
27
- @process = ChildProcess.new(Safari.path, *args)
28
- @process.io.inherit! if $DEBUG
29
- @process.start
30
- end
31
-
32
- def stop
33
- @process.stop if @process
34
- end
35
- end # Browser
36
- end # Safari
37
- end # WebDriver
38
- end # Selenium
@@ -1,138 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Safari
23
- # @api private
24
- class LegacyBridge < Remote::Bridge
25
- COMMAND_TIMEOUT = 60
26
-
27
- def self.legacy?
28
- !File.exist?(Safari.driver_path)
29
- end
30
-
31
- def initialize(opts = {})
32
- command_timeout = Integer(opts[:timeout] || COMMAND_TIMEOUT)
33
- safari_options = opts.delete(:options) || Safari::Options.new(opts)
34
- capabilities = merge_capabilities(opts, safari_options)
35
-
36
- @command_id ||= 0
37
-
38
- # TODO: handle safari_opts['cleanSession']
39
- @server = Server.new(safari_options.port, command_timeout)
40
- @server.start
41
-
42
- @safari = Browser.new
43
- @safari.start(prepare_connect_file)
44
-
45
- @server.wait_for_connection
46
-
47
- super(desired_capabilities: capabilities)
48
- end
49
-
50
- def quit
51
- super
52
-
53
- @server.stop
54
- @safari.stop
55
- end
56
-
57
- def driver_extensions
58
- [
59
- DriverExtensions::TakesScreenshot,
60
- DriverExtensions::HasInputDevices
61
- ]
62
- end
63
-
64
- private
65
-
66
- def create_session(desired_capabilities)
67
- resp = raw_execute :newSession, {}, {desiredCapabilities: desired_capabilities}
68
- Remote::Capabilities.json_create resp.fetch('value')
69
- end
70
-
71
- def raw_execute(command, opts = {}, command_hash = nil)
72
- @command_id += 1
73
-
74
- params = {}
75
- opts.each do |key, value|
76
- params[camel_case(key.to_s)] = value
77
- end
78
-
79
- params.merge!(command_hash) if command_hash
80
-
81
- @server.send(
82
- origin: 'webdriver',
83
- type: 'command',
84
- command: {id: @command_id.to_s, name: command, parameters: params}
85
- )
86
-
87
- raw = @server.receive
88
- response = raw.fetch('response')
89
-
90
- status_code = response['status']
91
- if status_code != 0
92
- raise Error.for_code(status_code), response['value']['message']
93
- end
94
-
95
- if raw['id'].to_s != @command_id.to_s
96
- raise Error::WebDriverError, "response id does not match command id: #{raw['id']} != #{@command_id}"
97
- end
98
-
99
- response
100
- end
101
-
102
- def camel_case(str)
103
- parts = str.split('_')
104
- parts[1..-1].map(&:capitalize!)
105
-
106
- parts.join
107
- end
108
-
109
- def prepare_connect_file
110
- # TODO: use tempfile?
111
- path = File.join(Dir.tmpdir, "safaridriver-#{Time.now.usec}.html")
112
-
113
- File.open(path, 'w') do |io|
114
- io << "<!DOCTYPE html><script>window.location = '#{@server.uri}';</script>"
115
- end
116
-
117
- FileReaper << path
118
- path.tr! '/', '\\' if Platform.windows?
119
-
120
- path
121
- end
122
-
123
- def merge_capabilities(opts, safari_options)
124
- caps = safari_options.to_capabilities
125
- other = opts[:desired_capabilities]
126
-
127
- if other
128
- other = opts[:desired_capabilities].as_json
129
- caps['safari.options'].merge!(other.delete('safari.options') || {})
130
- caps.merge!(other)
131
- end
132
-
133
- caps
134
- end
135
- end # Bridge
136
- end # Safari
137
- end # WebDriver
138
- end # Selenium
@@ -1,61 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # Licensed to the Software Freedom Conservancy (SFC) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The SFC licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
-
20
- module Selenium
21
- module WebDriver
22
- module Safari
23
- class Options
24
- DEFAULT_PORT = 56485
25
-
26
- attr_accessor :port, :data_dir, :skip_extension_installation
27
-
28
- def initialize(opts = {})
29
- extract_options(opts)
30
- end
31
-
32
- def clean_session?
33
- @clean_session == true
34
- end
35
-
36
- def to_capabilities
37
- caps = Remote::Capabilities.safari
38
- caps['safari.options'] = as_json
39
-
40
- caps
41
- end
42
-
43
- def as_json
44
- {
45
- 'port' => port,
46
- 'dataDir' => data_dir,
47
- 'cleanSession' => clean_session?
48
- }
49
- end
50
-
51
- private
52
-
53
- def extract_options(opts)
54
- @port = Integer(opts[:port] || DEFAULT_PORT)
55
- @data_dir = opts[:custom_data_dir] || opts[:data_dir]
56
- @clean_session = opts[:clean_session]
57
- end
58
- end # Options
59
- end # Safari
60
- end # WebDriver
61
- end # Selenium