locatine 0.03118 → 0.03143

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b992087a77664cfe04949ab6bb1f343edb0c03801bcc118ac21631c4455463f3
4
- data.tar.gz: b0d586f4c4de1c38a84eee4d1f9e434a3d8136d4ae25e83367dc573a5ec67c76
3
+ metadata.gz: 38cf69f2ca475f5755477d3bf3ea25581edf0a4a1a57b6491e70f4b97073541b
4
+ data.tar.gz: 22eeccf122ed564e802047874710fb85f234d4ba52c03a89b8b3ad8e20d0a2cd
5
5
  SHA512:
6
- metadata.gz: 59ae3ed8e6aa6ac27be09e3bcaeda8e4ce7968db40e8393efd0fe47aeb25be5770181c718555ed304a1938133e7c198b788e82adbf557acb1e451aa650d90d6e
7
- data.tar.gz: b56c011bb15c36a1e42dd342f2cc0f09f21ad65835d3cdf457e20b915b18faaeb381bf3c9328b705e6b4a6ec613ebc17712e0cfead1de2e094905509bb50fbe8
6
+ metadata.gz: e637591dbc8f53827fd59747dc45675674350f0ed03985b22524b8f9b0b0b705ba60006e5575ee37b2e0c0c51fa8109bf459381fcc11fd96d51120bf2c31da40
7
+ data.tar.gz: 2b1461b445491aa49a94a725431e2a4cec9d41bbc5d46e6c6570792297f21987e887c930f17285f65e3782bc4fcc4cef9f4490fd6ee62f0e9b6c85f177f82355
data/README.md CHANGED
@@ -14,7 +14,7 @@ That's it.
14
14
 
15
15
  ## Stage of development:
16
16
 
17
- Version of Locatine is **0.03118**.
17
+ Version of Locatine is **0.03143**.
18
18
 
19
19
  ## Installation
20
20
 
@@ -48,14 +48,16 @@ driver.quit
48
48
  4. Run the locatine daemon
49
49
 
50
50
  ```
51
- $ SELENIUM=http://localhost:4444 locatine-daemon.rb --port=7733
51
+ $ locatine-daemon.rb --port=7733 --selenium="http://localhost:4444"
52
52
  ```
53
53
 
54
- 5. SELENIUM - is for url where selenium hub is started, port is the port for your code to connect. 4444 and 7733 are defaults.
54
+ 5. *--selenium* - is for url where selenium hub is started, *--port* is the port for your code to connect. 4444 and 7733 are defaults.
55
55
  6. Run your code
56
56
  7. Data of element will be stored to ./default.json file.
57
57
  8. Now if id of your element is changed on the page Locatine will show a warning and gonna try to retrieve it.
58
- 9. See [example](https://github.com/sseleznevqa/locatine/tree/master/examples) to see how it really works.
58
+ 9. See [examples](https://github.com/sseleznevqa/locatine/tree/master/examples) to see how it really works.
59
+
60
+ **NOTE!** All examples in readme are ruby language examples. But any language can be successfully used. You can find Python example using the link above.
59
61
 
60
62
  ## Session
61
63
 
@@ -13,7 +13,7 @@ module Locatine
13
13
 
14
14
  configure do
15
15
  set :sessions, {}
16
- set :selenium, ENV['SELENIUM'] || 'http://localhost:4444'
16
+ set :selenium, 'http://localhost:4444'
17
17
  set :headers, 'Content-Type' => 'application/json'
18
18
  set :port, 7733
19
19
  end
@@ -44,5 +44,16 @@ module Locatine
44
44
  @info = @session.execute_script(info, self)
45
45
  @info
46
46
  end
47
+
48
+ ##
49
+ # Method to get tag of the particular element or return it if it was
50
+ # gathered before
51
+ def tag_name
52
+ return @tag if @tag
53
+
54
+ script = 'return arguments[0].tagName'
55
+ @tag = @session.execute_script(script, self)
56
+ @tag
57
+ end
47
58
  end
48
59
  end
@@ -69,7 +69,11 @@ module Locatine
69
69
  guess if name_only?
70
70
  return if first.class == Locatine::Error || empty?
71
71
 
72
- log_found if name_only?
72
+ check_guess if name_only?
73
+ end
74
+
75
+ def check_guess
76
+ map(&:tag_name).uniq.size == 1 ? log_found : clear
73
77
  end
74
78
 
75
79
  def simple_find
@@ -53,12 +53,13 @@ module Locatine
53
53
  # @return populated instance of Locatine::Results or an empty array
54
54
  # or Locatine::Error
55
55
  def find(params, parent = nil)
56
+ @start_time = Time.now
56
57
  find_routine(params, parent)
57
58
  rescue RuntimeError => e
58
59
  raise e.message unless e.message == 'stale element reference'
59
60
 
60
61
  warn_unstable_page
61
- find(params, parent)
62
+ find_routine(params, parent)
62
63
  end
63
64
 
64
65
  ##
@@ -134,8 +135,15 @@ module Locatine
134
135
  end
135
136
  end
136
137
 
138
+ def define_timeout(params)
139
+ params['timeout'] = params['timeout']
140
+ .to_i - (Time.now - @start_time).round
141
+ params
142
+ end
143
+
137
144
  def find_routine(params, parent)
138
145
  results = Results.new
146
+ params = define_timeout(params)
139
147
  answer = results.find(self, params, parent)
140
148
  if !answer.empty? && answer.first.class != Locatine::Error
141
149
  @elements[results.name] = results.info
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Locatine
4
4
  # constants here...
5
- VERSION = '0.03118'
5
+ VERSION = '0.03143'
6
6
  NAME = 'locatine'
7
7
  HOME = if File.readable?("#{Dir.pwd}/lib/#{Locatine::NAME}")
8
8
  "#{Dir.pwd}/lib/#{Locatine::NAME}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locatine
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.03118'
4
+ version: '0.03143'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Seleznev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,7 +128,7 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0.8'
131
- description: The main goal to write locators never
131
+ description: The main goal is to write locators (almost) never
132
132
  email: s_seleznev_qa@hotmail.com
133
133
  executables:
134
134
  - locatine-daemon.rb
@@ -178,5 +178,5 @@ requirements: []
178
178
  rubygems_version: 3.0.3
179
179
  signing_key:
180
180
  specification_version: 4
181
- summary: Element locating tool based on watir
181
+ summary: Element locating proxy for selenium
182
182
  test_files: []