kirchhoff 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +2 -1
- data/exe/kirchhoff +1 -1
- data/lib/kirchhoff/version.rb +1 -1
- data/lib/kirchhoff.rb +25 -9
- 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: 4b4685b6ac03e6611ca24f2337f79d12078ea07a
|
4
|
+
data.tar.gz: 87cc14431e9556168881c17e0d2ddd08255dcab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7fe60b4f1676c657dac0c62f67cb75c2e0a16370732a5029a0ec462ad6a260d6af6b485dc7c5b6cc63f117f23a01f07bb7c91cfbcc5351fd85b12b312fb4e9
|
7
|
+
data.tar.gz: 962ae7e2550548e7bb6992ff575c9b0d04802daae0beafe32316e63dc098c66a65f1279907ab601de49f714571f2a51f53d9f82a7642d75094472a6c94ea5a90
|
data/bin/console
CHANGED
data/exe/kirchhoff
CHANGED
data/lib/kirchhoff/version.rb
CHANGED
data/lib/kirchhoff.rb
CHANGED
@@ -6,7 +6,7 @@ require 'kirchhoff/logger'
|
|
6
6
|
|
7
7
|
module Kirchhoff
|
8
8
|
class Driver
|
9
|
-
attr_accessor :__driver__
|
9
|
+
attr_accessor :__driver__, :default_timeout
|
10
10
|
attr_reader :log_dir_path
|
11
11
|
include Kirchhoff::CommonInterface
|
12
12
|
|
@@ -22,12 +22,16 @@ module Kirchhoff
|
|
22
22
|
@__driver__.current_url
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
@__driver__
|
27
|
-
go(url) if url
|
25
|
+
def quit
|
26
|
+
@__driver__.quit
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
29
|
+
def initialize(browser: :chrome, default_timeout: 6)
|
30
|
+
@__driver__ = Selenium::WebDriver.for(browser)
|
31
|
+
@default_timeout = default_timeout
|
32
|
+
end
|
33
|
+
|
34
|
+
def go url
|
31
35
|
@__driver__.navigate.to(url)
|
32
36
|
Kirchhoff::Logger.call :info, "visiting #{url}..."
|
33
37
|
end
|
@@ -57,14 +61,26 @@ module Kirchhoff
|
|
57
61
|
@__driver__.switch_to.window @__driver__.window_handles[num]
|
58
62
|
end
|
59
63
|
|
60
|
-
def wait_element
|
61
|
-
wait = Selenium::WebDriver::Wait.new(timeout: t)
|
64
|
+
def wait_element(selector, maybe: true, t: nil)
|
65
|
+
wait = Selenium::WebDriver::Wait.new(timeout: (t || @default_timeout))
|
62
66
|
wait.until { self.find_element(css: selector) }
|
67
|
+
rescue Selenium::WebDriver::Error::TimeOutError
|
68
|
+
unless maybe
|
69
|
+
raise Selenium::WebDriver::Error::TimeOutError, "selector: #{selector}"
|
70
|
+
end
|
63
71
|
end
|
64
72
|
|
65
|
-
def wait_text
|
66
|
-
wait = Selenium::WebDriver::Wait.new(timeout: t)
|
73
|
+
def wait_text(text, maybe: true, t: nil)
|
74
|
+
wait = Selenium::WebDriver::Wait.new(timeout: (t || @default_timeout))
|
67
75
|
wait.until { self.find_element(xpath: "//*[text()[contains(.,\"#{text}\")]]") }
|
76
|
+
rescue Selenium::WebDriver::Error::TimeOutError
|
77
|
+
unless maybe
|
78
|
+
raise Selenium::WebDriver::Error::TimeOutError, "text: #{text}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def to_html
|
83
|
+
self.__driver__.page_source
|
68
84
|
end
|
69
85
|
end
|
70
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kirchhoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gogotanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|