findElement 0.1.9 → 0.2.0

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 +42 -37
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28a493f5b47298958d793bd581ea1eab5f5d89fe8cdff6c5623f71147dd4e9fc
4
- data.tar.gz: 69f656ccf0e2ccb128e69464eb9ee0c58b777bac6ca170e9908fd3f3884c849a
3
+ metadata.gz: 0f9ef2944e06d806563bb23f039029a4a4876a9f07e67494b68eb8accb02a94a
4
+ data.tar.gz: 709d4e19f9a52e862e19fc56f73fd6b39949c995aea586e46333f571b623fe15
5
5
  SHA512:
6
- metadata.gz: acfef7762601a619e9d081ccda6a6c0e28583a649a949b735887710588f7c3ad77ae0ae7e6f8bc3faed9ce93947ee5dee260723486ab5b39fc9a275517084a29
7
- data.tar.gz: 49030665b4fce8c8f365541fe7c6c3e278ec88013320e01781a20fd7269470a285e44388abf1d2d10e80c71102f56c6ddf652f8e7f752374a31158b4b93ef8b0
6
+ metadata.gz: 75d55650f9dfe7e38668de2b703859d7b7f074dc50f2dbd7140c2795af7187174fbc21e3cb15b700a0d1dc572a0e0519a61eb3ec7bc42219f56867f749d88fb7
7
+ data.tar.gz: 82ca022388e31d365c0c3a3a305663d198f5a2fb038ae52f3b0e2e4abc8d6e315fe63b6210c497574f9ff152ac34d0f59fb9b2e1c7d7a05fd3c5c7e0f6c7edad
data/lib/findElement.rb CHANGED
@@ -28,48 +28,53 @@ findElement("adv-spinner loadingSpinner").text ==> picture
28
28
 
29
29
  def findElement text
30
30
 
31
+ if text.include? '@xpath'
31
32
 
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].delete(">")
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)
48
- else
49
- attr = cond[0].split("<").last
50
- unless attr.include? "=\""
51
- return find(:xpath, "//#{tag}[contains(text(),'#{text}')]", visible: true)
33
+ return find(:xpath, text.split('@xpath')[0])
34
+
35
+ else
36
+
37
+ begin
38
+ Timeout.timeout(2) do
39
+ return find(:xpath, "//*[contains(text(),'#{text}')]", visible: true)
40
+ end
41
+ rescue
42
+ soruce = page.html
43
+ cond = soruce.split(text)
44
+ if cond.count == 2
45
+ tag = cond[0].split("<").last
46
+ tag = tag.split[0].delete(">")
47
+
48
+ if cond[0][cond[0].length - 1] == '"'
49
+ attr = cond[0].split('<').last
50
+ attr = attr.split('="').last
51
+ attr = attr.split.last
52
+ return find(:xpath, "//#{tag}[@#{attr}='#{text}']", visible: true)
52
53
  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)
54
+ attr = cond[0].split("<").last
55
+ unless attr.include? "=\""
56
+ return find(:xpath, "//#{tag}[contains(text(),'#{text}')]", visible: true)
57
+ else
58
+ key = attr.split('="')[0].split[1]
59
+ value = attr.split(key)[1].split('"')[1]
60
+ return find(:xpath, "//#{tag}[@#{key}='#{value}'][contains(text(),'#{text}')]", visible: true)
61
+ end
56
62
  end
63
+ else
64
+
65
+ attr_name = ['id', 'name', 'class', 'href', 'data-title', 'text-area', 'text', 'data-dismiss', 'style', 'title', 'type', 'placeholder', 'value', 'list', 'dropzone', 'draggable', 'download', 'form', 'headers']
66
+ i = 0
67
+ attr_name.each do |attribute|
68
+ @element = attribute + '="' + text + '"'
69
+ break if soruce.include? @element
70
+ i += 1
71
+ next if i < attr_name.count
72
+ raise('could not find :' + @element)
73
+ end
74
+ return find(:xpath, "//*[@#{@element}]", visible: true)
57
75
  end
58
- else
59
-
60
- attr_name = ['id', 'name', 'class', 'href', 'data-title','text-area','text', 'data-dismiss', 'style', 'title', 'type', 'placeholder', 'value', 'list', 'dropzone', 'draggable', 'download', 'form', 'headers']
61
- i = 0
62
- attr_name.each do |attribute|
63
- @element = attribute + '="' + text + '"'
64
- break if soruce.include? @element
65
- i += 1
66
- next if i < attr_name.count
67
- raise('could not find :' + @element)
68
- end
69
- return find(:xpath, "//*[@#{@element}]", visible: true)
76
+
70
77
  end
71
78
 
72
79
  end
73
-
74
-
75
80
  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.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bünyamin orhan