async-webdriver 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/webdriver/bridge/safari.rb +84 -0
- data/lib/async/webdriver/bridge.rb +2 -0
- data/lib/async/webdriver/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf43f03c5d84881a589b4b8ada0b4b610bd81d7434b42387986c2e62be565748
|
4
|
+
data.tar.gz: eeeda998354a547586c84f796a74062304510e3778011d18e60bead39ffb9d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 061ec510b866722f3893e549153532e8053a8aa4301316b338fec0bdd0785d00e7b84257969bfd2622581aecedaf59dd08f375577f051fc64c51ab4411b9fbe0
|
7
|
+
data.tar.gz: 73ef488209fcdff4efb657b3c47b61459de197e9303790ed59356e05c6f7553155971b225d2271987da64e7336d5343aa5de4882bf0610c6d435cad369860c86
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative 'generic'
|
7
|
+
require_relative 'process_group'
|
8
|
+
|
9
|
+
module Async
|
10
|
+
module WebDriver
|
11
|
+
module Bridge
|
12
|
+
# A bridge to the Safari browser using `safaridriver`.
|
13
|
+
#
|
14
|
+
# ``` ruby
|
15
|
+
# begin
|
16
|
+
# bridge = Async::WebDriver::Bridge::Safari.start
|
17
|
+
# client = Async::WebDriver::Client.open(bridge.endpoint)
|
18
|
+
# ensure
|
19
|
+
# bridge&.close
|
20
|
+
# end
|
21
|
+
# ```
|
22
|
+
class Safari < Generic
|
23
|
+
def path
|
24
|
+
@options.fetch(:path, "safaridriver")
|
25
|
+
end
|
26
|
+
|
27
|
+
# @returns [String] The version of the `safaridriver` executable.
|
28
|
+
def version
|
29
|
+
::IO.popen([self.path, "--version"]) do |io|
|
30
|
+
return io.read
|
31
|
+
end
|
32
|
+
rescue Errno::ENOENT
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
36
|
+
class Driver < Bridge::Driver
|
37
|
+
def initialize(**options)
|
38
|
+
super(**options)
|
39
|
+
@process_group = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
# @returns [Array(String)] The arguments to pass to the `safaridriver` executable.
|
43
|
+
def arguments(**options)
|
44
|
+
[
|
45
|
+
options.fetch(:path, "safaridriver"),
|
46
|
+
"--port=#{self.port}",
|
47
|
+
].compact
|
48
|
+
end
|
49
|
+
|
50
|
+
def start
|
51
|
+
@process_group = ProcessGroup.spawn(*arguments(**@options))
|
52
|
+
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
def close
|
57
|
+
if @process_group
|
58
|
+
@process_group.close
|
59
|
+
@process_group = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
super
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Start the driver.
|
67
|
+
def start(**options)
|
68
|
+
Driver.new(**options).tap(&:start)
|
69
|
+
end
|
70
|
+
|
71
|
+
# The default capabilities for the Safari browser which need to be provided when requesting a new session.
|
72
|
+
# @parameter headless [Boolean] Whether to run the browser in headless mode.
|
73
|
+
# @returns [Hash] The default capabilities for the Safari browser.
|
74
|
+
def default_capabilities(headless: self.headless?)
|
75
|
+
{
|
76
|
+
alwaysMatch: {
|
77
|
+
browserName: "safari",
|
78
|
+
},
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
require_relative 'bridge/chrome'
|
7
7
|
require_relative 'bridge/firefox'
|
8
|
+
require_relative 'bridge/safari'
|
8
9
|
|
9
10
|
require_relative 'error'
|
10
11
|
|
@@ -17,6 +18,7 @@ module Async
|
|
17
18
|
ALL = [
|
18
19
|
Bridge::Chrome,
|
19
20
|
Bridge::Firefox,
|
21
|
+
Bridge::Safari,
|
20
22
|
]
|
21
23
|
|
22
24
|
def self.each(&block)
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/async/webdriver/bridge/generic.rb
|
124
124
|
- lib/async/webdriver/bridge/pool.rb
|
125
125
|
- lib/async/webdriver/bridge/process_group.rb
|
126
|
+
- lib/async/webdriver/bridge/safari.rb
|
126
127
|
- lib/async/webdriver/client.rb
|
127
128
|
- lib/async/webdriver/element.rb
|
128
129
|
- lib/async/webdriver/error.rb
|
metadata.gz.sig
CHANGED
Binary file
|