fe_core_ext 0.30.1 → 0.33.0
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 +43 -0
- data/lib/fe_core_ext/gem_ext/selenium_webdriver.rb +41 -37
- data/lib/fe_core_ext/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e03934108a512eada22df20a49377eacbcc98decb4cf1ef976a6b4a68625d878
|
4
|
+
data.tar.gz: 47c126a960a3c00b535ad7c0de71a00dd891bf1c3df80a25e252376ea0c32bb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0237b7d187495a4362e7cd499cafefd9ac5a4ba0092a7e6988c98cccfeef01c6022a6e7f175dc2224d24f768cf513ee7d478bab6cfd84042d58dd6b06e88d01
|
7
|
+
data.tar.gz: 0e2294134a6b53bbe9cebd60e311549220559429ac5586b02914ce036d34948df94e13a279b9b63ed70f833441169c2f637eb3f2fbdae4bfdf705120dd01a634
|
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,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ferrum
|
4
|
+
class Browser
|
5
|
+
delegate %i[wait_for_css wait_for_csses wait_for_xpath wait_for_xpaths], to: :page
|
6
|
+
end
|
7
|
+
|
8
|
+
class Page
|
9
|
+
delegate %i[wait_for_css wait_for_csses wait_for_xpath wait_for_xpaths], to: :main_frame
|
10
|
+
end
|
11
|
+
|
12
|
+
class Frame
|
13
|
+
module DOM
|
14
|
+
def wait_for_csses(selector, timeout: 3)
|
15
|
+
wait_for_selector(selector, :css, timeout)
|
16
|
+
end
|
17
|
+
|
18
|
+
def wait_for_xpaths(selector, timeout: 3)
|
19
|
+
wait_for_selector(selector, :xpath, timeout)
|
20
|
+
end
|
21
|
+
|
22
|
+
def wait_for_css(selector, timeout: 3)
|
23
|
+
wait_for_selector(selector, :at_css, timeout)
|
24
|
+
end
|
25
|
+
|
26
|
+
def wait_for_xpath(selector, timeout: 3)
|
27
|
+
wait_for_selector(selector, :at_xpath, timeout)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def wait_for_selector(selector, selector_method, timeout)
|
33
|
+
interval = 0.1
|
34
|
+
(timeout / interval).to_i.times do
|
35
|
+
nodes = send(selector_method, selector)
|
36
|
+
return nodes if nodes
|
37
|
+
sleep(interval)
|
38
|
+
end
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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,14 +1,14 @@
|
|
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.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tetsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -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
|