findElement 0.1.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.
- checksums.yaml +7 -0
- data/lib/findElement.rb +42 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d542e1e94238ae51d805134128b51534ef13ca6125db9d53fe28a56dd93f742
|
4
|
+
data.tar.gz: 1ccfdc84d2212ab74b4aad20e11a9d5524a0124f6d81db4f1d4b4df6f620aa39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6dfa20ffc12622b663ec93a663e73a97550bed9d3081d444c0df60b035a762aa625df32db3691fd86e87abc2dbe6315438080a1c57991bb2bc00b353264ca282
|
7
|
+
data.tar.gz: d2c362c5a1175a240e08498dc1d18b553326418f589401080496e4518de92b51ce07def0c751840654971d14974bf080c978d0eae4cbd9fb8d4385258930bace
|
data/lib/findElement.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
def findElement text
|
4
|
+
|
5
|
+
soruce = page.html
|
6
|
+
cond = soruce.split(text)
|
7
|
+
if cond.count == 2
|
8
|
+
|
9
|
+
tag = cond[0].split("<").last
|
10
|
+
tag = tag.split[0]
|
11
|
+
|
12
|
+
if cond[0][cond[0].length - 1] == '"'
|
13
|
+
attr = cond[0].split('<').last
|
14
|
+
attr = attr.split('="').last
|
15
|
+
attr = attr.split.last
|
16
|
+
return find(:xpath, "//#{tag}[@#{attr}='#{text}']", visible: true)
|
17
|
+
else
|
18
|
+
attr = cond[0].split("<").last
|
19
|
+
unless attr.include? "=\""
|
20
|
+
return find(:xpath, "//#{tag}[contains(text(),'#{text}')]", visible: true)
|
21
|
+
else
|
22
|
+
attr = attr.split[1]
|
23
|
+
return find(:xpath, "//#{tag}[@#{attr}][contains(text(),'#{text}')]", visible: true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
|
28
|
+
attr_name = ['name', 'id', 'class', 'href', 'title', 'type', 'placeholder', 'list', 'dropzone', 'draggable', 'download', 'form', 'headers']
|
29
|
+
i = 0
|
30
|
+
attr_name.each do |attribute|
|
31
|
+
@element = attribute + '="' + text + '"'
|
32
|
+
break if soruce.include? @element
|
33
|
+
i += 1
|
34
|
+
next if i < attr_name.count
|
35
|
+
raise('aranan element bulunamadı. başaka metod kullanın ya da attr_name değişkeninde aradığınız attribute olmayabilir')
|
36
|
+
end
|
37
|
+
return find(:xpath, "//*[@#{@element}]", visible: true)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: findElement
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bünyamin orhan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: simple find element gem
|
14
|
+
email: ahmet.orhan65@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/findElement.rb
|
20
|
+
homepage: http://rubygems.org/gems/findElement
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: find element
|
44
|
+
test_files: []
|