selenium_standalone_dsl 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +1 -12
- data/Gemfile.lock +7 -19
- data/README.md +40 -2
- data/lib/selenium_standalone_dsl/version.rb +1 -1
- data/selenium_standalone_dsl.gemspec +10 -4
- data/spec/selenium_standalone_dsl_spec.rb +64 -0
- metadata +78 -8
- data/.rspec +0 -2
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3693c0d5500983b794af7fdf98364312dad7641
|
4
|
+
data.tar.gz: f2c0ededad165e7f43ab72be4fe8f0503d7c2c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f62c910a6fc5d0ce9c95729b34bb512dfe79952f04493100354a825fd136d2655d197ca349313e6f2e3d66154298ef96523fec4c71ade5961953b37c5bd1738
|
7
|
+
data.tar.gz: f48cc8dd3eb385b692b0f99b0cce5a617830f379ece17b1c441a6f0e75c984cb7d2813ae748b4573930c7c36d475f5a7acab72049373cd23266a11aacb98a6a5
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem 'nokogiri'
|
5
|
-
gem 'headless'
|
6
|
-
gem 'activesupport'
|
7
|
-
gem 'rake'
|
8
|
-
|
9
|
-
group :development, :staging do
|
10
|
-
gem 'pry'
|
11
|
-
gem 'rspec'
|
12
|
-
gem 'sinatra'
|
13
|
-
end
|
14
|
-
|
3
|
+
# Specify your gem's dependencies in selenium_standalone_dsl.gemspec
|
15
4
|
gemspec
|
16
5
|
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
selenium_standalone_dsl (0.1.
|
4
|
+
selenium_standalone_dsl (0.1.2)
|
5
|
+
headless
|
6
|
+
nokogiri
|
7
|
+
selenium-webdriver
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: https://rubygems.org/
|
8
11
|
specs:
|
9
|
-
activesupport (5.0.0.1)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (~> 0.7)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
12
|
childprocess (0.5.9)
|
15
13
|
ffi (~> 1.0, >= 1.0.11)
|
16
14
|
coderay (1.1.1)
|
17
|
-
concurrent-ruby (1.0.2)
|
18
15
|
diff-lcs (1.2.5)
|
19
16
|
ffi (1.9.14)
|
20
17
|
headless (2.3.1)
|
21
|
-
i18n (0.7.0)
|
22
18
|
method_source (0.8.2)
|
23
19
|
mini_portile2 (2.1.0)
|
24
|
-
minitest (5.9.0)
|
25
20
|
nokogiri (1.6.8)
|
26
21
|
mini_portile2 (~> 2.1.0)
|
27
22
|
pkg-config (~> 1.1.7)
|
@@ -33,7 +28,7 @@ GEM
|
|
33
28
|
rack (1.6.4)
|
34
29
|
rack-protection (1.5.3)
|
35
30
|
rack
|
36
|
-
rake (
|
31
|
+
rake (10.5.0)
|
37
32
|
rspec (3.5.0)
|
38
33
|
rspec-core (~> 3.5.0)
|
39
34
|
rspec-expectations (~> 3.5.0)
|
@@ -57,24 +52,17 @@ GEM
|
|
57
52
|
rack-protection (~> 1.4)
|
58
53
|
tilt (>= 1.3, < 3)
|
59
54
|
slop (3.6.0)
|
60
|
-
thread_safe (0.3.5)
|
61
55
|
tilt (2.0.5)
|
62
|
-
tzinfo (1.2.2)
|
63
|
-
thread_safe (~> 0.1)
|
64
56
|
websocket (1.2.3)
|
65
57
|
|
66
58
|
PLATFORMS
|
67
59
|
ruby
|
68
60
|
|
69
61
|
DEPENDENCIES
|
70
|
-
activesupport
|
71
62
|
bundler (~> 1.12)
|
72
|
-
headless
|
73
|
-
nokogiri
|
74
63
|
pry
|
75
|
-
rake
|
76
|
-
rspec
|
77
|
-
selenium-webdriver
|
64
|
+
rake (~> 10.0)
|
65
|
+
rspec (~> 3.0)
|
78
66
|
selenium_standalone_dsl!
|
79
67
|
sinatra
|
80
68
|
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
[](https://badge.fury.io/rb/selenium_standalone_dsl)
|
2
2
|
|
3
|
-
#
|
3
|
+
# Selenium Standalone DSL
|
4
4
|
|
5
5
|
Gem for using Selenium webdriver simply.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Ensure you already
|
9
|
+
Ensure you have already installed Firefox:
|
10
10
|
|
11
11
|
```sh
|
12
12
|
sudo apt-get install firefox
|
@@ -82,6 +82,44 @@ bundle exec rake spec
|
|
82
82
|
|
83
83
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
84
84
|
|
85
|
+
## Roadmap
|
86
|
+
|
87
|
+
I will create `Selenium Spider` after completing `Selenium Standalone DSL`.
|
88
|
+
|
89
|
+
`Selenium Spider` aims to scrape websites using JavaScript.
|
90
|
+
|
91
|
+
There are a lot of tools such as `mechanize` but they are no longer useful for SPA websites.
|
92
|
+
|
93
|
+
In my heart, `Selenium Spider` will have these features:
|
94
|
+
|
95
|
+
### Full JavaScript support
|
96
|
+
|
97
|
+
Based on Selenium Standalone DSL, it comprehences JavaScript.
|
98
|
+
|
99
|
+
### PMC architecture
|
100
|
+
|
101
|
+
PMC = Pagination Model Controller
|
102
|
+
|
103
|
+
Generally, scraping is consist of two parts: Listing page and Detail page.
|
104
|
+
|
105
|
+
In PMC architecture, Page is for listing items and pagenation.
|
106
|
+
|
107
|
+
Model is for extracting information from detail page and store data to database.
|
108
|
+
|
109
|
+
Controller is for handle the above two.
|
110
|
+
|
111
|
+
### Web-based task execution
|
112
|
+
|
113
|
+
Scraping tasks are often multiply and difficult to arrange.
|
114
|
+
|
115
|
+
Imagine Web-based task execution, definition, and scheduling like Jenkins.
|
116
|
+
|
117
|
+
## TODO
|
118
|
+
|
119
|
+
- [ ] Fix class name. Dsl => DSL
|
120
|
+
- [ ] Log and config
|
121
|
+
- [ ] TravisCI
|
122
|
+
|
85
123
|
## Contributing
|
86
124
|
|
87
125
|
Bug reports and pull requests are welcome on GitHub at https://github.com/acro5piano/selenium_standalone_dsl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["gosho-kazuya"]
|
10
10
|
spec.email = ["ketsume0211@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Gem for using Selenium webdriver simply}
|
13
|
+
spec.description = %q{Gem for using Selenium webdriver simply}
|
14
14
|
spec.homepage = "https://github.com/acro5piano/selenium_standalone_dsl"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -23,11 +23,17 @@ Gem::Specification.new do |spec|
|
|
23
23
|
# end
|
24
24
|
|
25
25
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
spec.
|
27
|
-
spec.executables =
|
26
|
+
spec.test_files = `git ls-files -- spec/*_spec.rb`.split("\n")
|
27
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
+
spec.add_dependency 'selenium-webdriver'
|
31
|
+
spec.add_dependency 'nokogiri'
|
32
|
+
spec.add_dependency 'headless'
|
33
|
+
|
30
34
|
spec.add_development_dependency "bundler", "~> 1.12"
|
31
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "sinatra"
|
38
|
+
spec.add_development_dependency "pry"
|
33
39
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SeleniumStandaloneDsl do
|
4
|
+
it 'has a version number' do
|
5
|
+
expect(SeleniumStandaloneDsl::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe SeleniumStandaloneDsl::Base do
|
9
|
+
before :all do
|
10
|
+
@pid = Process.spawn('bundle e ruby spec/fixtures/app.rb')
|
11
|
+
|
12
|
+
config = {
|
13
|
+
log_path: '/tmp/selenium_standalone_dsl_spec.log',
|
14
|
+
user_agent: 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36',
|
15
|
+
headless: true,
|
16
|
+
}
|
17
|
+
@driver = SeleniumStandaloneDsl::Base.new(config)
|
18
|
+
end
|
19
|
+
|
20
|
+
after :all do
|
21
|
+
@driver.quit
|
22
|
+
Process.kill 9, @pid
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'visit a site' do
|
26
|
+
expect { @driver.visit('http://localhost:4567') }.not_to raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'click a link and follow href' do
|
30
|
+
@driver.visit 'http://localhost:4567/click'
|
31
|
+
expect { @driver.click('ClickMe') }.not_to raise_error
|
32
|
+
expect(@driver.driver.current_url).to eq 'http://localhost:4567/'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'fill_in a input box' do
|
36
|
+
@driver.visit 'http://localhost:4567/fill_in'
|
37
|
+
expect { @driver.fill_in('input_box', with: 'hoge') }.not_to raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'close alert' do
|
41
|
+
@driver.visit 'http://localhost:4567/alert'
|
42
|
+
expect { @driver.prompt_ok }.not_to raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'select a value in a select box' do
|
46
|
+
@driver.visit 'http://localhost:4567/select'
|
47
|
+
expect { @driver.select('an option', from: 'select_box') }.not_to raise_error
|
48
|
+
expect { @driver.select('an option', from: 'select_box', find_by: :name) }.not_to raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'determine if the page has the text' do
|
52
|
+
@driver.visit 'http://localhost:4567/'
|
53
|
+
expect(@driver.has_element?(:text, 'Hello')).to be true
|
54
|
+
expect(@driver.has_element?(:text, 'Hogehogehoge')).to be false
|
55
|
+
expect(@driver.has_element?(:class, 'title')).to be true
|
56
|
+
expect(@driver.has_element?(:class, 'titleIsNotBlank')).to be false
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'search with Nokogiri' do
|
60
|
+
@driver.visit 'http://localhost:4567/search'
|
61
|
+
expect(@driver.search('th:contains("title") + td').inner_html).to eq 'Hello'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_standalone_dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gosho-kazuya
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: selenium-webdriver
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: headless
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: bundler
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +94,35 @@ dependencies:
|
|
52
94
|
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
96
|
version: '3.0'
|
55
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sinatra
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Gem for using Selenium webdriver simply
|
56
126
|
email:
|
57
127
|
- ketsume0211@gmail.com
|
58
128
|
executables: []
|
@@ -60,8 +130,6 @@ extensions: []
|
|
60
130
|
extra_rdoc_files: []
|
61
131
|
files:
|
62
132
|
- ".gitignore"
|
63
|
-
- ".rspec"
|
64
|
-
- ".ruby-version"
|
65
133
|
- ".travis.yml"
|
66
134
|
- CODE_OF_CONDUCT.md
|
67
135
|
- Gemfile
|
@@ -74,6 +142,7 @@ files:
|
|
74
142
|
- lib/selenium_standalone_dsl/base.rb
|
75
143
|
- lib/selenium_standalone_dsl/version.rb
|
76
144
|
- selenium_standalone_dsl.gemspec
|
145
|
+
- spec/selenium_standalone_dsl_spec.rb
|
77
146
|
homepage: https://github.com/acro5piano/selenium_standalone_dsl
|
78
147
|
licenses:
|
79
148
|
- MIT
|
@@ -97,5 +166,6 @@ rubyforge_project:
|
|
97
166
|
rubygems_version: 2.5.1
|
98
167
|
signing_key:
|
99
168
|
specification_version: 4
|
100
|
-
summary:
|
101
|
-
test_files:
|
169
|
+
summary: Gem for using Selenium webdriver simply
|
170
|
+
test_files:
|
171
|
+
- spec/selenium_standalone_dsl_spec.rb
|
data/.rspec
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.0
|