watir-search 0.0.2 → 0.0.3
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/lib/watir-search/load_view.rb +5 -2
- data/lib/watir-search/search_engine.yml +8 -0
- data/lib/watir-search.rb +16 -8
- 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: 68cc2bf299a0338c567ef92de700f6d905704422
|
|
4
|
+
data.tar.gz: 2b1578d1b2c35503548797fa1ee90d668fae3d2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d30297d88cfe4d03dee10614b11e727b9ffd8ef04f87823ffd72361a935948e8067dc926337d366021fd7043ca68873a0e98a7e26c05fedffa5a4b363a408ec
|
|
7
|
+
data.tar.gz: a2720450d4108fcff72040fc64dc97a1bc51e149cabeeb5382f6f276b4f1815adc81e915d5afcdbd2965bfc8917771a2ef8ddb1613ff658991ba753875a457bb
|
|
@@ -57,9 +57,12 @@ module Watir
|
|
|
57
57
|
array
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
def original_hash(file)
|
|
61
|
+
YAML.load_file(File.join(File.dirname(__FILE__), file))
|
|
62
|
+
end
|
|
63
|
+
|
|
60
64
|
def load_view(file:nil, hash:nil, parent:nil)
|
|
61
|
-
hash ||= decode_hash(
|
|
62
|
-
YAML.load_file(File.join(File.dirname(__FILE__), file)))
|
|
65
|
+
hash ||= decode_hash(original_hash(file))
|
|
63
66
|
view_array(hash).each { |h| view_accessor(parent, h) }
|
|
64
67
|
end
|
|
65
68
|
end
|
data/lib/watir-search.rb
CHANGED
|
@@ -4,26 +4,34 @@ require 'watir-webdriver'
|
|
|
4
4
|
module Watir
|
|
5
5
|
class Search
|
|
6
6
|
include LoadView
|
|
7
|
-
attr_reader :sys
|
|
7
|
+
attr_reader :sys, :url
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
return @sys if @sys
|
|
9
|
+
def initialize(url)
|
|
11
10
|
@sys = Watir::Browser.new(:firefox)
|
|
12
|
-
|
|
11
|
+
@url = url
|
|
12
|
+
@view_file = 'search_engine.yml'
|
|
13
13
|
|
|
14
|
-
def initialize(url)
|
|
15
14
|
sys.goto url
|
|
16
15
|
sys
|
|
17
|
-
load_view(file:
|
|
16
|
+
load_view(file: @view_file, parent: sys)
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
def quit
|
|
21
20
|
sys.close if sys
|
|
22
21
|
end
|
|
23
22
|
|
|
23
|
+
def view_prefix
|
|
24
|
+
if original_hash(@view_file).keys
|
|
25
|
+
.select { |k| url.include?(k.to_s) }.empty?
|
|
26
|
+
'general'
|
|
27
|
+
else
|
|
28
|
+
url.split('.')[1]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
24
32
|
def execute(text, timeout:nil)
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
send("#{view_prefix}_search").when_present.set(text)
|
|
34
|
+
send("#{view_prefix}_enter").when_present.click
|
|
27
35
|
sleep timeout if timeout
|
|
28
36
|
end
|
|
29
37
|
end
|