findElement 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/findElement.rb +28 -24
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22629b919f842a7d9a34fb15ed7d6d0aad8373d676faaf426fe41f4d58d9de1
4
- data.tar.gz: bbfc3afa068f426811959951ea7ca39fbfd284b48c50bacb6becd8b1fc8d3855
3
+ metadata.gz: e570a279ecfafeb56eaa78cae09371ef3417ad593a772c4f2d27377914f39d0e
4
+ data.tar.gz: a4180466cfc6eba0ed1e20816b37428d746c5412e8b24ae8a5c919c3edf44359
5
5
  SHA512:
6
- metadata.gz: b30f1fb768b96c0a843c50e5c3345ebde12a8ea8684fb689fe76f7b1aa56b2988b6e427e002a52e798719feceb3dd6e20ff6ed07d220ef7ec1a0a14711c3cb3d
7
- data.tar.gz: 7c88a102566120ce06e9a9ac9a1b4b55bece94904254baad9e2c364034cda03effefc3aa5442e5da905d18a3be51d82c11f3071e1e8a180f6de3be1a75dbaf52
6
+ metadata.gz: 3476867dabc3e10df473ec4740b4bd4f9780c946c20f6b580d49f244c0bbe0a1c5acd542927a449ceb31b5e78875f4802cd2b1d97d2859ea01956f0d0c13373a
7
+ data.tar.gz: 7b46fb5920d21b223ff3e76e5450da5f3e3a6a7d79c6a05b459050d63750e93672af237834c8519f37d33bf0fe1b41b9508d4a59655ab6bcb07022739da220a4
data/lib/findElement.rb CHANGED
@@ -28,30 +28,36 @@ findElement("adv-spinner loadingSpinner").text ==> picture
28
28
 
29
29
  def findElement text
30
30
 
31
- soruce = page.html
32
- cond = soruce.split(text)
33
- if cond.count == 2
34
- tag = cond[0].split("<").last
35
- tag = tag.split[0]
36
-
37
- if cond[0][cond[0].length - 1] == '"'
38
- attr = cond[0].split('<').last
39
- attr = attr.split('="').last
40
- attr = attr.split.last
41
- return find(:xpath, "//#{tag}[@#{attr}='#{text}']", visible: true)
42
- else
43
- attr = cond[0].split("<").last
44
- unless attr.include? "=\""
45
- return find(:xpath, "//#{tag}[contains(text(),'#{text}')]", visible: true)
31
+
32
+ begin
33
+ Timeout.timeout(2) do
34
+ return find(:xpath, "//*[contains(text(),'#{text}')]", visible: true)
35
+ end
36
+ rescue
37
+ soruce = page.html
38
+ cond = soruce.split(text)
39
+ if cond.count == 2
40
+ tag = cond[0].split("<").last
41
+ tag = tag.split[0]
42
+
43
+ if cond[0][cond[0].length - 1] == '"'
44
+ attr = cond[0].split('<').last
45
+ attr = attr.split('="').last
46
+ attr = attr.split.last
47
+ return find(:xpath, "//#{tag}[@#{attr}='#{text}']", visible: true)
46
48
  else
47
- key = attr.split('="')[0].split[1]
48
- value = attr.split(key)[1].split('"')[1]
49
- return find(:xpath, "//#{tag}[@#{key}='#{value}'][contains(text(),'#{text}')]", visible: true)
49
+ attr = cond[0].split("<").last
50
+ unless attr.include? "=\""
51
+ return find(:xpath, "//#{tag}[contains(text(),'#{text}')]", visible: true)
52
+ else
53
+ key = attr.split('="')[0].split[1]
54
+ value = attr.split(key)[1].split('"')[1]
55
+ return find(:xpath, "//#{tag}[@#{key}='#{value}'][contains(text(),'#{text}')]", visible: true)
56
+ end
50
57
  end
51
- end
52
- else
53
- begin
54
- attr_name = ['name', 'id', 'class', 'href', 'data-title', 'data-dismiss', 'style', 'title', 'type', 'placeholder', 'value', 'list', 'dropzone', 'draggable', 'download', 'form', 'headers']
58
+ else
59
+
60
+ attr_name = ['data-guid','data-id','id', 'name', 'class', 'href', 'data-title','text-area','text', 'data-dismiss', 'style', 'title', 'type', 'placeholder', 'value', 'list', 'dropzone', 'draggable', 'download', 'form', 'headers']
55
61
  i = 0
56
62
  attr_name.each do |attribute|
57
63
  @element = attribute + '="' + text + '"'
@@ -61,8 +67,6 @@ def findElement text
61
67
  raise('could not find :' + @element)
62
68
  end
63
69
  return find(:xpath, "//*[@#{@element}]", visible: true)
64
- rescue
65
- return find(:xpath, "//*[contains(text(),'#{text}')]", visible: true)
66
70
  end
67
71
 
68
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: findElement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bünyamin orhan