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 +4 -4
- data/fe_core_ext.gemspec +3 -2
- data/lib/fe_core_ext/gem_ext/ferrum.rb +35 -0
- data/lib/fe_core_ext/gem_ext/selenium_webdriver.rb +41 -37
- data/lib/fe_core_ext/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a87561be521ad11c7d5b9c45c292b44dd806c14e2d4e836df71102bda24b92
|
4
|
+
data.tar.gz: 8f7cb9da94fe4add3c0460a135b2a53ff3ef2b5b4273c2c6531fdff221af7a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
26
|
-
spec.add_development_dependency "
|
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
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
|
data/lib/fe_core_ext/version.rb
CHANGED
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.
|
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:
|
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
|