aranha-selenium 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8049f9b39bc5bdcf4b0d1f99c2d56ebe27de42a6753ab6265761af7af4133e60
4
- data.tar.gz: bb330a8b485846dcb70a32845f8e0ed98a70d80051e12e0efba9ad2341052fee
3
+ metadata.gz: 311e72ca409d486986d984d0f5ad995f9aa83912a2ec5eb3eeb9851b7c1791cf
4
+ data.tar.gz: a2fedda793addcc387a7a3f59b32f5e6dfc802ea8d139df03fd5c6d93e0826ec
5
5
  SHA512:
6
- metadata.gz: 4602f4e1be967594d4611a7e84d4d785196e633a4f35da9a909ed3998383f6b936bd056cd359ed8cd44b0841903f2883dd432aabb06aff0520a7f246688a19da
7
- data.tar.gz: 12e8385c7eed3bf717a8bc90a57e39e20c08a577f14bb48994cc33a5eee172fe8b301fa93da7193e55adb3ef910eb2841bcfc117d93d165691e3253885770b15
6
+ metadata.gz: da8d00d672419479fbafeadf723647d7c696d647e27897d0291b503e76fd250e600a04f23354ae5da73b0ecc66e19e8b2f8866e2dbec47b2e112c663f00e703b
7
+ data.tar.gz: ec09d4e135dba9a5e2c588b49e81f46b572fb81cb9f59ada2c2e80af99455b9e6d4a121a38176021bccacaef6ba0bd920d0ca61384d7db9c314c096ae5e07c62
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'aranha/selenium/driver_options'
4
+ require 'aranha/selenium/executables'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Aranha
@@ -12,6 +13,11 @@ module Aranha
12
13
  end
13
14
  end
14
15
 
16
+ DRIVERS = {
17
+ chrome: :chromedriver,
18
+ firefox: :geckodriver
19
+ }.freeze
20
+
15
21
  # @!attribute [r] options
16
22
  # @return [ActiveSupport::HashWithIndifferentAccess]
17
23
 
@@ -37,7 +43,11 @@ module Aranha
37
43
  end
38
44
 
39
45
  def default_driver_name
40
- :firefox
46
+ DRIVERS.each do |driver, executable|
47
+ return driver if ::Aranha::Selenium::Executables.send(executable).exist?
48
+ end
49
+
50
+ raise "No driver found (#{DRIVERS.value.join(', ')})"
41
51
  end
42
52
 
43
53
  # @return [Aranha::Selenium::DriverOptions]
@@ -23,17 +23,31 @@ module Aranha
23
23
  end
24
24
 
25
25
  enable_listable
26
+ lists.add_symbol :headless, :auto, :no, :yes
26
27
  lists.add_symbol :option, :accept_insecure_certs, :downloads_dir, :headless, :profile_dir,
27
28
  :profile_name, :user_agent
28
29
  BOOLEAN_OPTIONS = [OPTION_ACCEPT_INSECURE_CERTS, OPTION_HEADLESS].freeze
29
30
 
30
31
  DEFAULT_DOWNLOADS_DIR = ::File.join(::Dir.tmpdir, 'aranha_downloads_dir')
31
32
  DEFAULT_ACCEPT_INSECURE_CERTS = false
32
- DEFAULT_HEADLESS = false
33
+ DEFAULT_HEADLESS = HEADLESS_AUTO
33
34
  DEFAULT_PROFILE_DIR = nil
34
35
  DEFAULT_PROFILE_NAME = nil
35
36
  DEFAULT_USER_AGENT = nil
36
37
 
38
+ HEADLESS_AUTO_ENVVAR = 'DISPLAY'
39
+
40
+ OPTIONS_SANITIZERS = {
41
+ headless: lambda { |value|
42
+ case value
43
+ when HEADLESS_AUTO then ENV[HEADLESS_AUTO_ENVVAR].blank?
44
+ when HEADLESS_NO then false
45
+ when HEADLESS_YES then true
46
+ else value.to_bool
47
+ end
48
+ }
49
+ }.freeze
50
+
37
51
  # @param user_values [Hash]
38
52
  def initialize(user_values = {})
39
53
  user_values.each { |k, v| send("#{k}=", v) }
@@ -45,9 +59,9 @@ module Aranha
45
59
  define_method(key) { send("#{key}_option").value }
46
60
  define_method("#{key}=") { |user_value| send("#{key}_option").user_value = user_value }
47
61
 
48
- option_proc = nil
62
+ option_proc = OPTIONS_SANITIZERS[key]
49
63
  if BOOLEAN_OPTIONS.include?(key)
50
- option_proc = proc { |v| ::EacRubyUtils::Boolean.parse(v) }
64
+ option_proc = proc { |v| ::EacRubyUtils::Boolean.parse(v) } if option_proc.blank?
51
65
  define_method("#{key}?") { send(key) }
52
66
  end
53
67
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Aranha
6
+ module Selenium
7
+ module Executables
8
+ class << self
9
+ enable_simple_cache
10
+
11
+ def env
12
+ ::EacRubyUtils::Envs.local
13
+ end
14
+
15
+ private
16
+
17
+ %w[chromedriver geckodriver].each do |program|
18
+ define_method("#{program.underscore}_uncached") do
19
+ env.executable(program, '--version')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -28,11 +28,11 @@ module Aranha
28
28
  wait.until { find_element(find_element_args) }
29
29
  end
30
30
 
31
- def wait_for_download
31
+ def wait_for_download(timeout = nil)
32
32
  initial_downloads = downloads.current
33
33
  yield
34
34
  new_downloads = []
35
- wait.until do
35
+ wait(timeout).until do
36
36
  new_downloads = downloads.current - initial_downloads
37
37
  new_downloads.any?
38
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Selenium
5
- VERSION = '0.9.0'
5
+ VERSION = '0.10.0'
6
6
  end
7
7
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
4
+
3
5
  module Aranha
4
6
  module Selenium
5
- require 'aranha/selenium/driver_factory'
6
- require 'aranha/selenium/session'
7
+ require_sub __FILE__
7
8
  end
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha-selenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_fs
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0.10'
95
+ - !ruby/object:Gem::Dependency
96
+ name: stub_server
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.7'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.7'
95
109
  description:
96
110
  email:
97
111
  executables: []
@@ -107,6 +121,7 @@ files:
107
121
  - lib/aranha/selenium/driver_factory/firefox_auto_download_mime_types
108
122
  - lib/aranha/selenium/driver_options.rb
109
123
  - lib/aranha/selenium/driver_options/option.rb
124
+ - lib/aranha/selenium/executables.rb
110
125
  - lib/aranha/selenium/session.rb
111
126
  - lib/aranha/selenium/session/downloads.rb
112
127
  - lib/aranha/selenium/session/find.rb