locatine 0.02637 → 0.02651
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +268 -297
- data/bin/locatine-daemon.rb +4 -2
- data/lib/locatine/daemon.rb +44 -60
- data/lib/locatine/daemon_helpers/methods.rb +85 -0
- data/lib/locatine/element.rb +28 -0
- data/lib/locatine/results.rb +125 -0
- data/lib/locatine/results_helpers/common.rb +68 -0
- data/lib/locatine/results_helpers/find_by_magic.rb +106 -0
- data/lib/locatine/results_helpers/guess.rb +45 -0
- data/lib/locatine/results_helpers/info_generator.rb +79 -0
- data/lib/locatine/results_helpers/logger.rb +64 -0
- data/lib/locatine/{for_search → results_helpers}/xpath_generator.rb +18 -19
- data/lib/locatine/scripts/element.js +40 -0
- data/lib/locatine/scripts/page.js +53 -0
- data/lib/locatine/scripts/parent.js +6 -0
- data/lib/locatine/session.rb +102 -0
- data/lib/locatine/version.rb +4 -2
- data/lib/locatine.rb +3 -2
- metadata +39 -49
- data/lib/locatine/app/background.js +0 -8
- data/lib/locatine/app/content.css +0 -38
- data/lib/locatine/app/content.js +0 -152
- data/lib/locatine/app/devtools.html +0 -1
- data/lib/locatine/app/devtools.js +0 -3
- data/lib/locatine/app/manifest.json +0 -20
- data/lib/locatine/app/popup.css +0 -47
- data/lib/locatine/app/popup.html +0 -19
- data/lib/locatine/app/popup.js +0 -65
- data/lib/locatine/daemon_helpers.rb +0 -52
- data/lib/locatine/for_search/data_generate.rb +0 -67
- data/lib/locatine/for_search/data_logic.rb +0 -98
- data/lib/locatine/for_search/defaults.rb +0 -40
- data/lib/locatine/for_search/dialog_logic.rb +0 -107
- data/lib/locatine/for_search/element_selection.rb +0 -80
- data/lib/locatine/for_search/file_work.rb +0 -67
- data/lib/locatine/for_search/find_by_guess.rb +0 -67
- data/lib/locatine/for_search/find_by_locator.rb +0 -59
- data/lib/locatine/for_search/find_by_magic.rb +0 -65
- data/lib/locatine/for_search/find_logic.rb +0 -79
- data/lib/locatine/for_search/helpers.rb +0 -106
- data/lib/locatine/for_search/highlight.rb +0 -41
- data/lib/locatine/for_search/listening.rb +0 -48
- data/lib/locatine/for_search/merge.rb +0 -40
- data/lib/locatine/for_search/name_helper.rb +0 -51
- data/lib/locatine/for_search/page_work.rb +0 -126
- data/lib/locatine/for_search/public.rb +0 -179
- data/lib/locatine/for_search/saying.rb +0 -199
- data/lib/locatine/for_search.rb +0 -6
- data/lib/locatine/large_scripts/css.js +0 -21
- data/lib/locatine/large_scripts/dimensions.js +0 -17
- data/lib/locatine/large_scripts/element.js +0 -30
- data/lib/locatine/large_scripts/page.js +0 -60
- data/lib/locatine/scope.rb +0 -88
- data/lib/locatine/search.rb +0 -67
data/lib/locatine/scope.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
module Locatine
|
2
|
-
##
|
3
|
-
# Scope is the class representing group of elements
|
4
|
-
#
|
5
|
-
# Locatine has scopes
|
6
|
-
class Scope
|
7
|
-
def initialize(scope, search)
|
8
|
-
@search = search
|
9
|
-
@scope = scope
|
10
|
-
end
|
11
|
-
|
12
|
-
##
|
13
|
-
# Way to define locatine a bunch elements at once. Elements will be taken
|
14
|
-
# from user selection one by one and saved in scope.
|
15
|
-
#
|
16
|
-
# Params:
|
17
|
-
#
|
18
|
-
# +vars+ hash of vars used for dynamic attributes. Same as in :find
|
19
|
-
def define(vars = {})
|
20
|
-
find_all(vars, false, true) if data.to_h != {}
|
21
|
-
new_define(vars)
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# Getting all the elements of the scope at once
|
26
|
-
#
|
27
|
-
# Params:
|
28
|
-
#
|
29
|
-
# +vars+ hash of vars used for dynamic attributes. Same as in :find
|
30
|
-
def all(vars = {})
|
31
|
-
find_all(vars)
|
32
|
-
end
|
33
|
-
|
34
|
-
##
|
35
|
-
# Checking all the elements of the scope at once.
|
36
|
-
# Will fail if something was lost
|
37
|
-
#
|
38
|
-
# Params:
|
39
|
-
#
|
40
|
-
# +vars+ hash of vars used for dynamic attributes. Same as in :find
|
41
|
-
def check(vars = {})
|
42
|
-
success = []
|
43
|
-
result = find_all(vars, true)
|
44
|
-
result.each_pair do |name, hash|
|
45
|
-
success.push name if hash[:elements].empty?
|
46
|
-
end
|
47
|
-
raise "Check of #{@scope} failed! Lost: #{success}" unless success.empty?
|
48
|
-
|
49
|
-
result
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def data
|
55
|
-
@search.data[@scope]
|
56
|
-
end
|
57
|
-
|
58
|
-
def find_one(name, hash, vars, strict)
|
59
|
-
locator = { xpath: @search.send(:generate_xpath, hash, vars) } if strict
|
60
|
-
elements = @search.collect(scope: @scope, name: name,
|
61
|
-
locator: locator,
|
62
|
-
exact: strict,
|
63
|
-
no_fail: strict)
|
64
|
-
locator = { xpath: @search.send(:generate_xpath, hash, vars) }
|
65
|
-
{ elements: elements, locator: locator }
|
66
|
-
end
|
67
|
-
|
68
|
-
def find_all(vars = {}, strict = false, define = false)
|
69
|
-
learn = @search.learn
|
70
|
-
@search.learn = define
|
71
|
-
result = {}
|
72
|
-
data.each_pair do |name, hash|
|
73
|
-
result[name] = find_one(name, hash, vars, strict)
|
74
|
-
end
|
75
|
-
@search.learn = learn
|
76
|
-
result
|
77
|
-
end
|
78
|
-
|
79
|
-
def new_define(vars)
|
80
|
-
item = @search.send(:ask, @scope, '', nil, vars)
|
81
|
-
return find_all(vars) if item[:element].nil?
|
82
|
-
|
83
|
-
@search.send(:set_env_for_search, nil, nil, nil, nil, nil, nil)
|
84
|
-
@search.send(:store, item[:attributes], @scope, item[:name])
|
85
|
-
new_define(vars)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
data/lib/locatine/search.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'watir'
|
2
|
-
require 'json'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'webdrivers'
|
5
|
-
|
6
|
-
# Internal requires
|
7
|
-
require 'locatine/for_search/merge'
|
8
|
-
require 'locatine/for_search/public'
|
9
|
-
require 'locatine/for_search/saying'
|
10
|
-
require 'locatine/for_search/helpers'
|
11
|
-
require 'locatine/for_search/defaults'
|
12
|
-
require 'locatine/for_search/file_work'
|
13
|
-
require 'locatine/for_search/page_work'
|
14
|
-
require 'locatine/for_search/listening'
|
15
|
-
require 'locatine/for_search/highlight'
|
16
|
-
require 'locatine/for_search/data_logic'
|
17
|
-
require 'locatine/for_search/find_logic'
|
18
|
-
require 'locatine/for_search/name_helper'
|
19
|
-
require 'locatine/for_search/dialog_logic'
|
20
|
-
require 'locatine/for_search/find_by_magic'
|
21
|
-
require 'locatine/for_search/find_by_guess'
|
22
|
-
require 'locatine/for_search/data_generate'
|
23
|
-
require 'locatine/for_search/xpath_generator'
|
24
|
-
require 'locatine/for_search/find_by_locator'
|
25
|
-
require 'locatine/for_search/element_selection'
|
26
|
-
|
27
|
-
module Locatine
|
28
|
-
##
|
29
|
-
# Search is the main class of the Locatine
|
30
|
-
#
|
31
|
-
# Locatine can search.
|
32
|
-
class Search
|
33
|
-
include Locatine::ForSearch::Merge
|
34
|
-
include Locatine::ForSearch::Public
|
35
|
-
include Locatine::ForSearch::Saying
|
36
|
-
include Locatine::ForSearch::Helpers
|
37
|
-
include Locatine::ForSearch::Defaults
|
38
|
-
include Locatine::ForSearch::FileWork
|
39
|
-
include Locatine::ForSearch::PageWork
|
40
|
-
include Locatine::ForSearch::DataLogic
|
41
|
-
include Locatine::ForSearch::Listening
|
42
|
-
include Locatine::ForSearch::FindLogic
|
43
|
-
include Locatine::ForSearch::Highlight
|
44
|
-
include Locatine::ForSearch::NameHelper
|
45
|
-
include Locatine::ForSearch::FindByMagic
|
46
|
-
include Locatine::ForSearch::DialogLogic
|
47
|
-
include Locatine::ForSearch::FindByGuess
|
48
|
-
include Locatine::ForSearch::DataGenerate
|
49
|
-
include Locatine::ForSearch::FindByLocator
|
50
|
-
include Locatine::ForSearch::XpathGenerator
|
51
|
-
include Locatine::ForSearch::ElementSelection
|
52
|
-
|
53
|
-
attr_accessor :data,
|
54
|
-
:depth,
|
55
|
-
:learn,
|
56
|
-
:stability_limit,
|
57
|
-
:scope,
|
58
|
-
:tolerance,
|
59
|
-
:visual_search,
|
60
|
-
:no_fail,
|
61
|
-
:trusted,
|
62
|
-
:untrusted,
|
63
|
-
:autolearn
|
64
|
-
attr_reader :json,
|
65
|
-
:browser
|
66
|
-
end
|
67
|
-
end
|