findElement 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/findElement.rb +28 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e570a279ecfafeb56eaa78cae09371ef3417ad593a772c4f2d27377914f39d0e
|
4
|
+
data.tar.gz: a4180466cfc6eba0ed1e20816b37428d746c5412e8b24ae8a5c919c3edf44359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
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
|