gogo_driver 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/gogo_driver.gemspec +1 -1
- data/lib/gogo_driver.rb +17 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e7946e9abcb06c37b3cb4c987f42c8cac8352eb
|
4
|
+
data.tar.gz: c502c4cc6791fced6b2edf6c536ad140240c8c06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de60adc30dcc940c73fdedc464818fb0ce59069d32b1b91f0dd2792cb029db5934b74e1b436174bdf62743b4ffcfafdd69b77734f5e32ecc2edec0aecd9e579
|
7
|
+
data.tar.gz: 096bbf152ae5c5e589a26d1bcdd6a5a65825901d6091493b9cf856a9a7211abcf9bf948a4d63b61df4591ae8c790dc67f9e75010619d7faf237de68e0baea237
|
data/README.md
CHANGED
@@ -22,7 +22,8 @@ Let me show how to login Facebook.
|
|
22
22
|
```rb
|
23
23
|
require 'gogo_driver'
|
24
24
|
|
25
|
-
driver = GogoDriver.new
|
25
|
+
driver = GogoDriver.new
|
26
|
+
driver.go('https://www.facebook.com/')
|
26
27
|
driver.find('input#email').fill('mail@gogotanaka.com')
|
27
28
|
driver.find('input#pass').fill('password')
|
28
29
|
driver.submit
|
data/gogo_driver.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "gogo_driver"
|
7
|
-
spec.version = "0.1.
|
7
|
+
spec.version = "0.1.2"
|
8
8
|
spec.authors = ["gogotanaka"]
|
9
9
|
spec.email = ["mail@tanakakazuki.com"]
|
10
10
|
spec.summary = %q{Super simple web driver.}
|
data/lib/gogo_driver.rb
CHANGED
@@ -3,11 +3,12 @@ require 'selenium-webdriver'
|
|
3
3
|
class GogoDriver
|
4
4
|
attr_accessor :driver
|
5
5
|
|
6
|
-
def initialize
|
7
|
-
@driver = Selenium::WebDriver.for(
|
6
|
+
def initialize(browser=:chrome)
|
7
|
+
@driver = Selenium::WebDriver.for(browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
def go(url)
|
11
|
+
logging "[VISITE] #{url}..."
|
11
12
|
@driver.navigate.to(url)
|
12
13
|
end
|
13
14
|
|
@@ -16,6 +17,7 @@ class GogoDriver
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def find(selector)
|
20
|
+
logging "[FIND] #{selector}..."
|
19
21
|
@driver.find_element(css: selector)
|
20
22
|
end
|
21
23
|
|
@@ -36,21 +38,29 @@ class GogoDriver
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def click(selector)
|
41
|
+
logging "[CLICK] #{selector}..."
|
39
42
|
has?(selector) ? find(selector).click : false
|
40
43
|
end
|
41
44
|
|
42
45
|
def submit
|
46
|
+
logging "[SUBMIT] ..."
|
43
47
|
$focus.submit if $focus
|
44
48
|
end
|
45
49
|
|
46
50
|
def method_missing(method, *args, &block)
|
47
51
|
@driver.respond_to?(method) ? @driver.send(method, *args, &block) : super
|
48
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def logging(text)
|
56
|
+
puts text
|
57
|
+
end
|
49
58
|
end
|
50
59
|
|
51
60
|
class Selenium::WebDriver::Element
|
52
61
|
def fill(text)
|
53
62
|
$focus = self
|
63
|
+
"[FILL] #{selector}..."
|
54
64
|
send_key(text)
|
55
65
|
end
|
56
66
|
|
@@ -61,4 +71,9 @@ class Selenium::WebDriver::Element
|
|
61
71
|
def finds(selector)
|
62
72
|
find_elements(css: selector)
|
63
73
|
end
|
74
|
+
|
75
|
+
private
|
76
|
+
def logging(text)
|
77
|
+
puts text
|
78
|
+
end
|
64
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gogo_driver
|
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
|
- gogotanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|