qfunction 0.0.5 → 0.0.6
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.
- data/LICENSE +3 -0
- data/README +3 -0
- data/Rakefile +44 -11
- data/lib/function/HTMLElement.rb +1 -6
- data/lib/function/assertions.rb +4 -4
- data/lib/function/sfunction.rb +120 -104
- data/lib/qfunction.rb +2 -0
- data/lib/qvapir.rb +17 -0
- metadata +18 -25
- data/Manifest +0 -8
- data/qfunction.gemspec +0 -30
data/LICENSE
ADDED
data/README
ADDED
data/Rakefile
CHANGED
@@ -1,11 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
#
|
2
|
+
# To change this template, choose Tools | Templates
|
3
|
+
# and open the template in the editor.
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/clean'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/rdoctask'
|
11
|
+
require 'rake/testtask'
|
12
|
+
|
13
|
+
spec = Gem::Specification.new do |s|
|
14
|
+
s.name = 'qfunction'
|
15
|
+
s.version = '0.0.6'
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ['README', 'LICENSE']
|
18
|
+
s.summary = 'Nice Function'
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = 'QuangMV, Cyworld VietNam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Ha Noi, VietNam'
|
21
|
+
s.email = 'quangnnt@gmail.com'
|
22
|
+
s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
|
23
|
+
s.require_path = "lib"
|
24
|
+
s.bindir = "bin"
|
25
|
+
end
|
26
|
+
|
27
|
+
Rake::GemPackageTask.new(spec) do |p|
|
28
|
+
p.gem_spec = spec
|
29
|
+
p.need_tar = true
|
30
|
+
p.need_zip = true
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::RDocTask.new do |rdoc|
|
34
|
+
files =['README', 'LICENSE', 'lib/**/*.rb']
|
35
|
+
rdoc.rdoc_files.add(files)
|
36
|
+
rdoc.main = "README" # page to start on
|
37
|
+
rdoc.title = "qfunction Docs"
|
38
|
+
rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
|
39
|
+
rdoc.options << '--line-numbers'
|
40
|
+
end
|
41
|
+
|
42
|
+
Rake::TestTask.new do |t|
|
43
|
+
t.test_files = FileList['test/**/*.rb']
|
44
|
+
end
|
data/lib/function/HTMLElement.rb
CHANGED
data/lib/function/assertions.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#E: Assert
|
2
2
|
#Assertion text in page
|
3
3
|
module Qa
|
4
|
-
def assertText(text)
|
4
|
+
def assertText(text,waittime = $timeout) #0.0.6
|
5
5
|
i = 0
|
6
6
|
while !$ff.contains_text(text) do
|
7
7
|
sleep(1)
|
8
|
-
if i
|
9
|
-
|
8
|
+
if i>=waittime then
|
9
|
+
assert($ff.contains_text(text))
|
10
10
|
# break;
|
11
11
|
end
|
12
12
|
i=i+1
|
@@ -281,8 +281,8 @@ def falseExistsindex(browser,text,tags=1)
|
|
281
281
|
end
|
282
282
|
|
283
283
|
def returnwaitExists(text)
|
284
|
+
nwait(1) #0.0.6
|
284
285
|
sleep(0.5)
|
285
|
-
nwait(1)
|
286
286
|
if text.exists? then
|
287
287
|
return true
|
288
288
|
else
|
data/lib/function/sfunction.rb
CHANGED
@@ -1,128 +1,144 @@
|
|
1
1
|
module Qs
|
2
|
-
def decoder(n)
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
def decoder(n)
|
3
|
+
str = [" ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";",
|
4
|
+
"<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
5
|
+
"[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
6
|
+
"y","z","{","|","}","~" ]
|
7
|
+
for i in 32..126
|
8
|
+
if n == i then return "#{str[i-32]}"
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
|
-
end
|
12
12
|
|
13
|
-
#i=1: 0-9,a-z,A-Z<br>
|
14
|
-
#i=2: -_ <br>
|
15
|
-
#i=3: a-z,A-Z<br>
|
16
|
-
#i=4: 0-9<br>
|
17
|
-
#i=41: 0-9 <br>
|
18
|
-
#i=5: @domain<br>
|
19
|
-
#i=10: Ho va Ten<br>
|
20
|
-
def getRandomString(n,i)
|
21
|
-
|
13
|
+
#i=1: 0-9,a-z,A-Z<br>
|
14
|
+
#i=2: -_ <br>
|
15
|
+
#i=3: a-z,A-Z<br>
|
16
|
+
#i=4: 0-9<br>
|
17
|
+
#i=41: 0-9 <br>
|
18
|
+
#i=5: @domain<br>
|
19
|
+
#i=10: Ho va Ten<br>
|
20
|
+
def getRandomString(n,i)
|
21
|
+
str = ""
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
str1 = ["0","1","2","3","4","5","6","7","8","9",
|
24
|
+
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
|
25
|
+
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
26
|
+
"y","z"]
|
27
27
|
|
28
|
-
|
28
|
+
str2 = ["-","","_",""]
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
str3 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
|
31
|
+
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
str4 = ["0","1","2","3","4","5","6","7","8","9"]
|
34
|
+
str41 = ["0","1","2","3","4","5","6","7","8","9","","","","","","","","","",""]
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
str5 = ["@yahoo.com.vn","@gmail.com","@yahoo.com","@msn.com","@hotmail.com","@zing.vn","@google.com.vn","@dantri.com",
|
37
|
+
"@vnexpress.net","@mail.com","@abc.com","@live.com"]
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
strHo = ["Nguyen","Dinh","Dang","Huynh","Mai","Tran","Le","Hoang","Pham","Phan","Vu","Bui","Do","Ho","Ngo",
|
40
|
+
"Duong","Ly","Vuong","Trinh","Truong","Dinh","Doan","Lam","Phung"]
|
41
41
|
|
42
|
-
|
42
|
+
strTenDem = ["Thi","Hong","Van","","Duc","Thuy","Ngoc","Ly","Bac","Hien"]
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
strTen = ["Trai","Xi","Truc","Tu","Bat","Thanh","Luong","Khuong","Quyen","Quang",
|
45
|
+
"Hoang","Ky","Thai","Chinh","Trinh","Kien","Hao","Hung","Quynh","Phuong","Hoa","Hop","Dung","Thang","Van","Tu","Ninh","Vinh","Loc","Khanh","Thuy","Ha",
|
46
|
+
"Hang","Lam","Hai","Vu","Na","Duyen","Minh","Tuan","Hien","Anh","An","Be","Binh","Canh"]
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
if i == 1 then
|
49
|
+
for i in 1..n
|
50
|
+
str = "#{str}#{str1[rand(str1.length)]}"
|
51
|
+
end
|
52
|
+
return str
|
53
|
+
elsif i == 2 then
|
54
|
+
for i in 1..n
|
55
|
+
str = "#{str}#{str2[rand(str2.length)]}"
|
56
|
+
end
|
57
|
+
return str
|
58
|
+
elsif i == 3 then
|
59
|
+
for i in 1..n
|
60
|
+
str = "#{str}#{str3[rand(str3.length)]}"
|
61
|
+
end
|
62
|
+
return str
|
63
|
+
elsif i == 4 then
|
64
|
+
for i in 1..n
|
65
|
+
str = "#{str}#{str4[rand(10)]}"
|
66
|
+
end
|
67
|
+
return str
|
68
|
+
elsif i == 41 then
|
69
|
+
for i in 1..n
|
70
|
+
str = "#{str}#{str41[rand(str41.length)]}"
|
71
|
+
end
|
72
|
+
return str
|
73
|
+
elsif i == 5 then
|
74
|
+
for i in 1..n
|
75
|
+
str = "#{str}#{str5[rand(str5.length)]}"
|
76
|
+
end
|
77
|
+
return str
|
78
|
+
elsif i == 10 then
|
79
|
+
str = "#{strHo[rand(strHo.length)]} #{strTenDem[rand(strTenDem.length)]} #{strTen[rand(strTen.length)]}"
|
80
|
+
return str
|
51
81
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
elsif i == 3 then
|
59
|
-
for i in 1..n
|
60
|
-
str = "#{str}#{str3[rand(str3.length)]}"
|
61
|
-
end
|
62
|
-
return str
|
63
|
-
elsif i == 4 then
|
64
|
-
for i in 1..n
|
65
|
-
str = "#{str}#{str4[rand(10)]}"
|
66
|
-
end
|
67
|
-
return str
|
68
|
-
elsif i == 41 then
|
69
|
-
for i in 1..n
|
70
|
-
str = "#{str}#{str41[rand(str41.length)]}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def randfromto(a,b)
|
85
|
+
x = rand(b)
|
86
|
+
while x < a do
|
87
|
+
x = rand(b)
|
71
88
|
end
|
72
|
-
return
|
73
|
-
|
74
|
-
|
75
|
-
|
89
|
+
return x
|
90
|
+
end
|
91
|
+
|
92
|
+
def cutEndline(text)
|
93
|
+
if text[text.length-1] <32 or text[text.length-1] > 126 then
|
94
|
+
for i in 0..text.length-2
|
95
|
+
abc = "#{abc}#{decoder(text[i])}"
|
96
|
+
end
|
97
|
+
return abc
|
98
|
+
else
|
99
|
+
for i in 0..text.length-1
|
100
|
+
abc = "#{abc}#{decoder(text[i])}"
|
101
|
+
end
|
102
|
+
return abc
|
76
103
|
end
|
77
|
-
return str
|
78
|
-
elsif i == 10 then
|
79
|
-
str = "#{strHo[rand(strHo.length)]} #{strTenDem[rand(strTenDem.length)]} #{strTen[rand(strTen.length)]}"
|
80
|
-
return str
|
81
104
|
end
|
82
|
-
end
|
83
105
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
-
|
106
|
+
def readExcel(dir,sheet=1)
|
107
|
+
$excel = WIN32OLE.new("excel.application")
|
108
|
+
$excel.visible = true
|
109
|
+
$workbook = $excel.workbooks.open(dir)
|
110
|
+
$ws=$workbook.worksheets(sheet)
|
111
|
+
$workbook = $excel.ActiveWorkbook
|
112
|
+
end
|
113
|
+
|
114
|
+
def saveExcel
|
115
|
+
$workbook.Save
|
116
|
+
$workbook.Close
|
117
|
+
$excel.Quit
|
88
118
|
end
|
89
|
-
return x
|
90
|
-
end
|
91
119
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
120
|
+
def getFile(name)
|
121
|
+
begin
|
122
|
+
$f = IO.readlines(name)
|
123
|
+
return true
|
124
|
+
rescue
|
125
|
+
return false
|
96
126
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
127
|
+
end
|
128
|
+
|
129
|
+
def getPathExe(default_dir = "D:\\Working\\Application\\HPTel")
|
130
|
+
if ENV['OCRA_EXECUTABLE'].nil?
|
131
|
+
root_dir = default_dir
|
132
|
+
else
|
133
|
+
root_dir = File.expand_path(File.dirname(ENV['OCRA_EXECUTABLE'])).gsub('/', '\\')
|
101
134
|
end
|
102
|
-
return
|
135
|
+
return root_dir + "\\"
|
103
136
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
$ws=$workbook.worksheets(1)
|
111
|
-
$workbook = $excel.ActiveWorkbook
|
112
|
-
end
|
113
|
-
|
114
|
-
def saveExcel
|
115
|
-
$workbook.Save
|
116
|
-
$workbook.Close
|
117
|
-
$excel.Quit
|
118
|
-
end
|
119
|
-
|
120
|
-
def getFile(name)
|
121
|
-
begin
|
122
|
-
$f = IO.readlines(name)
|
123
|
-
return true
|
124
|
-
rescue
|
125
|
-
return false
|
137
|
+
|
138
|
+
def getDir(file,type = 1)
|
139
|
+
if type == 1 then
|
140
|
+
return File.dirname(file).gsub('/', '\\') + "\\"
|
141
|
+
else return File.dirname(file).gsub('/', '\\')
|
142
|
+
end
|
126
143
|
end
|
127
|
-
|
128
|
-
end
|
144
|
+
end
|
data/lib/qfunction.rb
CHANGED
data/lib/qvapir.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'vapir-firefox'
|
4
|
+
require 'win32ole'
|
5
|
+
|
6
|
+
require "function/HTMLElement"
|
7
|
+
require "function/assertions"
|
8
|
+
require "function/sfunction"
|
9
|
+
include Qh
|
10
|
+
include Qa
|
11
|
+
include Qs
|
12
|
+
|
13
|
+
def startBrowser
|
14
|
+
$ff = Vapir::Firefox.new
|
15
|
+
$timeout = 10
|
16
|
+
end
|
17
|
+
startBrowser
|
metadata
CHANGED
@@ -5,52 +5,46 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
- QuangMV, Cyworld
|
12
|
+
- QuangMV, Cyworld VietNam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Ha Noi, VietNam
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-01 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description: Nice Function
|
22
22
|
email: quangnnt@gmail.com
|
23
23
|
executables: []
|
24
24
|
|
25
25
|
extensions: []
|
26
26
|
|
27
27
|
extra_rdoc_files:
|
28
|
-
-
|
29
|
-
-
|
30
|
-
- lib/function/javascriptPopup.rb
|
31
|
-
- lib/function/sfunction.rb
|
32
|
-
- lib/qfunction.rb
|
33
|
-
- lib/qstart.rb
|
28
|
+
- README
|
29
|
+
- LICENSE
|
34
30
|
files:
|
31
|
+
- LICENSE
|
32
|
+
- README
|
35
33
|
- Rakefile
|
36
|
-
- lib/function/HTMLElement.rb
|
37
34
|
- lib/function/assertions.rb
|
35
|
+
- lib/function/HTMLElement.rb
|
38
36
|
- lib/function/javascriptPopup.rb
|
39
37
|
- lib/function/sfunction.rb
|
40
38
|
- lib/qfunction.rb
|
41
39
|
- lib/qstart.rb
|
42
|
-
-
|
43
|
-
- qfunction.gemspec
|
40
|
+
- lib/qvapir.rb
|
44
41
|
has_rdoc: true
|
45
|
-
homepage:
|
42
|
+
homepage:
|
46
43
|
licenses: []
|
47
44
|
|
48
45
|
post_install_message:
|
49
|
-
rdoc_options:
|
50
|
-
|
51
|
-
- --inline-source
|
52
|
-
- --title
|
53
|
-
- Qfunction
|
46
|
+
rdoc_options: []
|
47
|
+
|
54
48
|
require_paths:
|
55
49
|
- lib
|
56
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -67,15 +61,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
61
|
- - ">="
|
68
62
|
- !ruby/object:Gem::Version
|
69
63
|
segments:
|
70
|
-
-
|
71
|
-
|
72
|
-
version: "1.2"
|
64
|
+
- 0
|
65
|
+
version: "0"
|
73
66
|
requirements: []
|
74
67
|
|
75
|
-
rubyforge_project:
|
68
|
+
rubyforge_project:
|
76
69
|
rubygems_version: 1.3.7
|
77
70
|
signing_key:
|
78
71
|
specification_version: 3
|
79
|
-
summary:
|
72
|
+
summary: Nice Function
|
80
73
|
test_files: []
|
81
74
|
|
data/Manifest
DELETED
data/qfunction.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{qfunction}
|
5
|
-
s.version = "0.0.5"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["QuangMV, Cyworld Vietnam, 5th Floor, 447 Lac Long Quan Street, Tay Ho Dist, Hanoi, Vietnam"]
|
9
|
-
s.date = %q{2010-09-14}
|
10
|
-
s.description = %q{Funciton}
|
11
|
-
s.email = %q{quangnnt@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["lib/function/HTMLElement.rb", "lib/function/assertions.rb", "lib/function/javascriptPopup.rb", "lib/function/sfunction.rb", "lib/qfunction.rb", "lib/qstart.rb"]
|
13
|
-
s.files = ["Rakefile", "lib/function/HTMLElement.rb", "lib/function/assertions.rb", "lib/function/javascriptPopup.rb", "lib/function/sfunction.rb", "lib/qfunction.rb", "lib/qstart.rb", "Manifest", "qfunction.gemspec"]
|
14
|
-
s.homepage = %q{}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Qfunction"]
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project = %q{qfunction}
|
18
|
-
s.rubygems_version = %q{1.3.7}
|
19
|
-
s.summary = %q{Funciton}
|
20
|
-
|
21
|
-
if s.respond_to? :specification_version then
|
22
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
-
s.specification_version = 3
|
24
|
-
|
25
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
else
|
27
|
-
end
|
28
|
-
else
|
29
|
-
end
|
30
|
-
end
|