fe_core_ext 0.30.1 → 0.32.1

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: 8418dd8035fa99643b26a7960e1f3cf1e16bb0e4605aa64bf8febb14aaf36eda
4
- data.tar.gz: ea17906cfd926562a7c39b2ec7460e91b4d232649923389fc7480b3652a151de
3
+ metadata.gz: f2a87561be521ad11c7d5b9c45c292b44dd806c14e2d4e836df71102bda24b92
4
+ data.tar.gz: 8f7cb9da94fe4add3c0460a135b2a53ff3ef2b5b4273c2c6531fdff221af7a5e
5
5
  SHA512:
6
- metadata.gz: 3122f6848091b0fe21a382273895705bfc8ccdf6cf71419fdb487924985e502b87959f6144449d285fae9b98de1b8ff73e130aa731e040f921f3b48a341c82fa
7
- data.tar.gz: d82eecef2cd089d5c93e40f2d6bfbda73fa99d2e6ed21b1033d36bc732b964da5d6e0376729e1c0fa70f5929fda16cbdcfffabc2dcf232aadd90aa235c0af734
6
+ metadata.gz: a99aa40c9559997728260c51822d934d324b534f8ed5498cb5b230d23d7ee5aec2163e88634e1307b782d5ce3ad4f8ceeda37ed93f25d513e594fdaaf0f05ee7
7
+ data.tar.gz: 00277dc37128f4bd68e0abaec8f5eb5fdd67e858bf831072a876c34d9331d344de5d96b0311e7bba238ac6ca3a1c3a9a6a73c52eb69fba40fd6d1a1fb4462b62
data/fe_core_ext.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "activesupport"
23
23
  spec.add_development_dependency "bundler", "~> 2.1"
24
24
  spec.add_development_dependency "rake", "~> 12.3"
25
- spec.add_development_dependency "rspec", "~> 0"
26
- spec.add_development_dependency "selenium-webdriver", "~> 0"
25
+
26
+ spec.add_development_dependency "ferrum"
27
+ spec.add_development_dependency "selenium-webdriver"
27
28
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ferrum
4
+ class Browser
5
+ delegate :wait_for_css, :wait_for_xpath, to: :page
6
+ end
7
+
8
+ class Page
9
+ delegate :wait_for_css, :wait_for_xpath, to: :main_frame
10
+ end
11
+
12
+ class Frame
13
+ module DOM
14
+ def wait_for_css(selector, timeout: 3)
15
+ wait_for_selector(selector, :at_css, timeout)
16
+ end
17
+
18
+ def wait_for_xpath(selector, timeout: 3)
19
+ wait_for_selector(selector, :at_xpath, timeout)
20
+ end
21
+
22
+ private
23
+
24
+ def wait_for_selector(selector, selector_method, timeout)
25
+ interval = 0.1
26
+ (timeout / interval).to_i.times do
27
+ node = send(selector_method, selector)
28
+ return node if node
29
+ sleep(interval)
30
+ end
31
+ nil
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,46 +1,50 @@
1
- module Selenium::WebDriver::Find
2
- def find_element_without_no_element_error(*args)
3
- find_element(*args)
4
- rescue Selenium::WebDriver::Error::NoSuchElementError
5
- nil
6
- end
1
+ module Selenium
2
+ module WebDriver
3
+ module Find
4
+ def find_element_without_no_element_error(*args)
5
+ find_element(*args)
6
+ rescue Selenium::WebDriver::Error::NoSuchElementError
7
+ nil
8
+ end
7
9
 
8
- def find_elements_without_no_element_error(*args)
9
- find_elements(*args)
10
- rescue Selenium::WebDriver::Error::NoSuchElementError
11
- nil
12
- end
10
+ def find_elements_without_no_element_error(*args)
11
+ find_elements(*args)
12
+ rescue Selenium::WebDriver::Error::NoSuchElementError
13
+ nil
14
+ end
13
15
 
14
- def at_xpath(path, wait: nil)
15
- if wait.present?
16
- driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
17
- driver_wait.until { find_element_without_no_element_error(:xpath, path) }
18
- end
19
- find_element_without_no_element_error(:xpath, path)
20
- end
16
+ def at_xpath(path, wait: nil)
17
+ if wait.present?
18
+ driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
19
+ driver_wait.until { find_element_without_no_element_error(:xpath, path) }
20
+ end
21
+ find_element_without_no_element_error(:xpath, path)
22
+ end
21
23
 
22
- def xpath(path, wait: nil)
23
- if wait.present?
24
- driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
25
- driver_wait.until { find_elements_without_no_element_error(:xpath, path) }
26
- end
27
- find_elements_without_no_element_error(:xpath, path)
28
- end
24
+ def xpath(path, wait: nil)
25
+ if wait.present?
26
+ driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
27
+ driver_wait.until { find_elements_without_no_element_error(:xpath, path) }
28
+ end
29
+ find_elements_without_no_element_error(:xpath, path)
30
+ end
29
31
 
30
- def at_css(path, wait: nil)
31
- if wait.present?
32
- driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
33
- driver_wait.until { find_element_without_no_element_error(:css, path) }
34
- end
35
- find_element_without_no_element_error(:css, path)
36
- end
32
+ def at_css(path, wait: nil)
33
+ if wait.present?
34
+ driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
35
+ driver_wait.until { find_element_without_no_element_error(:css, path) }
36
+ end
37
+ find_element_without_no_element_error(:css, path)
38
+ end
37
39
 
38
- def css(path, wait: nil)
39
- if wait.present?
40
- driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
41
- driver_wait.until { find_elements_without_no_element_error(:css, path) }
40
+ def css(path, wait: nil)
41
+ if wait.present?
42
+ driver_wait = Selenium::WebDriver::Wait.new(timeout: wait)
43
+ driver_wait.until { find_elements_without_no_element_error(:css, path) }
44
+ end
45
+ find_elements_without_no_element_error(:css, path)
46
+ end
42
47
  end
43
- find_elements_without_no_element_error(:css, path)
44
48
  end
45
49
  end
46
50
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FeCoreExt
4
- VERSION = "0.30.1"
4
+ VERSION = "0.32.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fe_core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.1
4
+ version: 0.32.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tetsu
@@ -53,31 +53,31 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '12.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: ferrum
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: selenium-webdriver
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Core class extensions that doesn't supported by active_recored core_ext
@@ -109,6 +109,7 @@ files:
109
109
  - lib/fe_core_ext/core_ext/time.rb
110
110
  - lib/fe_core_ext/core_ext/uri.rb
111
111
  - lib/fe_core_ext/gem_ext.rb
112
+ - lib/fe_core_ext/gem_ext/ferrum.rb
112
113
  - lib/fe_core_ext/gem_ext/selenium_webdriver.rb
113
114
  - lib/fe_core_ext/version.rb
114
115
  homepage: http://github.com/ironsand/fe_core_ext