smart_driver 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_driver/common_interface.rb +0 -32
- data/lib/smart_driver/version.rb +1 -1
- data/lib/smart_driver.rb +64 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5398ad2839372564d16484012594e95755586130
|
4
|
+
data.tar.gz: 91b1529e80bc77fd0fa247634f86c044c1beec92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0b93b55e343c5675d0054a640f09fe8d377129e57abad21908e23eb9734db145044940c7249d0bcd3ab031457a0e2312e22c3ffecf945e2c9eb5bd9b2fc128
|
7
|
+
data.tar.gz: 909bfd55ca17f66f0c07afda69b0ad9011e9662c9a5e6e27c9646c555c4ddb5067b4869f521d79359dee5a0e5de2240bb16225e1dc333123935c3946917d0af8
|
@@ -1,37 +1,5 @@
|
|
1
1
|
class SmartDriver
|
2
2
|
module CommonInterface
|
3
|
-
def find(selector)
|
4
|
-
logging :info, "find #{selector}..."
|
5
|
-
@__driver__.find_element(css: selector)
|
6
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
7
|
-
logging :fail, "#{selector} cannot be found"
|
8
|
-
nil
|
9
|
-
end
|
10
|
-
|
11
|
-
def finds(selector)
|
12
|
-
logging :info, "finds #{selector}..."
|
13
|
-
@__driver__.find_elements(css: selector)
|
14
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
15
|
-
logging :fail, "#{selector} cannot be found"
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def find_text(text)
|
20
|
-
logging :info, "find text '#{text}'..."
|
21
|
-
@__driver__.find_element({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
22
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
23
|
-
logging :fail, "text '#{text}' cannot be found"
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def finds_text(text)
|
28
|
-
logging :info, "finds text '#{text}'..."
|
29
|
-
@__driver__.find_elements({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
30
|
-
rescue Selenium::WebDriver::Error::NoSuchElementError
|
31
|
-
logging :fail, "text #{text} cannot be found"
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
|
35
3
|
def to_html
|
36
4
|
attribute("outerHTML")
|
37
5
|
end
|
data/lib/smart_driver/version.rb
CHANGED
data/lib/smart_driver.rb
CHANGED
@@ -12,6 +12,38 @@ class SmartDriver
|
|
12
12
|
go(url) if url
|
13
13
|
end
|
14
14
|
|
15
|
+
def find(selector)
|
16
|
+
logging :info, "find #{selector}..."
|
17
|
+
@__driver__.find_element(css: selector)
|
18
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
19
|
+
logging :fail, "#{selector} cannot be found"
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def finds(selector)
|
24
|
+
logging :info, "finds #{selector}..."
|
25
|
+
@__driver__.find_elements(css: selector)
|
26
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
27
|
+
logging :fail, "#{selector} cannot be found"
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_text(text)
|
32
|
+
logging :info, "find text '#{text}'..."
|
33
|
+
@__driver__.find_element({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
34
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
35
|
+
logging :fail, "text '#{text}' cannot be found"
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def finds_text(text)
|
40
|
+
logging :info, "finds text '#{text}'..."
|
41
|
+
@__driver__.find_elements({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
42
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
43
|
+
logging :fail, "text #{text} cannot be found"
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
15
47
|
def go(url)
|
16
48
|
logging :info, "visiting #{url}..."
|
17
49
|
@__driver__.navigate.to(url)
|
@@ -50,6 +82,38 @@ end
|
|
50
82
|
class Selenium::WebDriver::Element
|
51
83
|
include SmartDriver::CommonInterface
|
52
84
|
|
85
|
+
def find(selector)
|
86
|
+
logging :info, "find #{selector} in element..."
|
87
|
+
self.find_element(css: selector)
|
88
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
89
|
+
logging :fail, "#{selector} cannot be found in element..."
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def finds(selector)
|
94
|
+
logging :info, "finds #{selector} in element..."
|
95
|
+
self.find_elements(css: selector)
|
96
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
97
|
+
logging :fail, "#{selector} cannot be found in element..."
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def find_text(text)
|
102
|
+
logging :info, "find text '#{text}'..."
|
103
|
+
self.find_element({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
104
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
105
|
+
logging :fail, "text '#{text}' cannot be found"
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def finds_text(text)
|
110
|
+
logging :info, "finds text '#{text}'..."
|
111
|
+
self.find_elements({xpath: "//*[text()[contains(.,\"#{text}\")]]"})
|
112
|
+
rescue Selenium::WebDriver::Error::NoSuchElementError
|
113
|
+
logging :fail, "text #{text} cannot be found"
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
|
53
117
|
def fill(text)
|
54
118
|
$focus = self
|
55
119
|
logging :info, "fill '#{text}'"
|