marta 0.29156 → 0.30366
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 +4 -4
- data/README.md +41 -7
- data/lib/marta/classes_creation.rb +1 -0
- data/lib/marta/data/style.css +3 -2
- data/lib/marta/dialogs.rb +1 -1
- data/lib/marta/json_2_class.rb +4 -2
- data/lib/marta/options_and_paths.rb +19 -8
- data/lib/marta/public_methods.rb +11 -6
- data/lib/marta/simple_element_finder.rb +1 -6
- data/lib/marta/version.rb +1 -1
- data/lib/marta.rb +4 -2
- data/marta.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be4abef064cc25eb50c8a5eb9a56882df5f06f29
|
|
4
|
+
data.tar.gz: 91f8843e49995ddc89d1067074ae253f10aafc66
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba23f875bbab44dc04ed47d03342499ccf1c7ba7acded1b242a8313aea4ab67e84bfd3cd816e16c91b867d4eab10ecd76cbe1c719d21c24ddad11cd2d9e4c1e4
|
|
7
|
+
data.tar.gz: fd42bd950f95de0bea1ee2b36070a784633ff262ef775975a785935a28a77b3b8a2fd887394d4e8c5b7198a09cbfbf190f10d51afec8533df6cb027b066e82fb
|
data/README.md
CHANGED
|
@@ -40,7 +40,7 @@ your_page.your_element.click
|
|
|
40
40
|
5. Add *url* variable with the url of desired page as a default value.
|
|
41
41
|
6. Confirm.
|
|
42
42
|
7. Then page will be opened and you will be asked about your_element.
|
|
43
|
-
8. Just click the element and confirm the selection
|
|
43
|
+
8. Just click the element and confirm the selection.
|
|
44
44
|
9. Now you can run the test without LEARN parameter and it will work.
|
|
45
45
|
|
|
46
46
|
**So you are `writing code in pageobject pattern` style.**
|
|
@@ -95,6 +95,37 @@ dance_with learn: true or false
|
|
|
95
95
|
your_page.method_edit('newelementname')
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
**Q: How is working the open_page method?**
|
|
99
|
+
|
|
100
|
+
*A: That method is a part of the SmartPage class. It means that you can call it for any class\page object which was generated by Marta. There are three ways to use it:*
|
|
101
|
+
|
|
102
|
+
*The most straight way*
|
|
103
|
+
```ruby
|
|
104
|
+
dance_with
|
|
105
|
+
TestPage.new.open_page("smthing.com") # Will navigate you to http://smthing.com
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
*Predefined url way:*
|
|
109
|
+
|
|
110
|
+
*At the step of the page defining set variable url = smthing.com*
|
|
111
|
+
```ruby
|
|
112
|
+
dance_with
|
|
113
|
+
test_page = TestPage.new
|
|
114
|
+
test_page.url #=> "smthing.com"
|
|
115
|
+
test_page.open_page # Will navigate you to http://smthing.com
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
*The most flexible way:*
|
|
119
|
+
|
|
120
|
+
*At the step of the page defining you set path = testpath*
|
|
121
|
+
```ruby
|
|
122
|
+
dance_with base_url: "smthing.com"
|
|
123
|
+
test_page = TestPage.new
|
|
124
|
+
test_page.path #=> "testpath"
|
|
125
|
+
test_page.open_page # Will navigate you to http://smthing.com/testpath
|
|
126
|
+
```
|
|
127
|
+
*Note: If there is no path provided than Marta will go to base_url. Also if url value is defined for page Marta will use it instead the base_url. If url is given as argument for the open_page method Marta will ignore both url and base_url values and will use the argument provided.*
|
|
128
|
+
|
|
98
129
|
**Q: And what if I want to create page and define element without learn mode? For example in the middle of a debug session.**
|
|
99
130
|
|
|
100
131
|
*A Code in learn mode =*
|
|
@@ -131,13 +162,16 @@ engine.element(id: 'will_be_located_without_Marta')
|
|
|
131
162
|
|
|
132
163
|
*A: When defining an element you can set a collection checkbox at the top of the dialog. In that case Marta will return Watir::ElementCollection.*
|
|
133
164
|
|
|
165
|
+
**Q: How can I find an invisible element? Or hardly clickable element with 1px size?**
|
|
166
|
+
|
|
167
|
+
*A: At the stage of element defining you can see a button "Find by HTML". That button will open html code of your page in a special blue form. Find the html code of your element and click on it.*
|
|
168
|
+
|
|
134
169
|
**Q: How can I find not just an element but a Watir::Radio for example?**
|
|
135
170
|
|
|
136
171
|
*A: Marta automatically performs to_subtype for every element. So if your element is a radio button you will be able to use specific methods.*
|
|
137
172
|
```ruby
|
|
138
173
|
your_page.element_that_supposed_to_be_radio.set?
|
|
139
174
|
```
|
|
140
|
-
*ATTENTION. Until [Watir issue 537](https://github.com/watir/watir/issues/537) is not fixed it may work wrong. Sometimes.*
|
|
141
175
|
|
|
142
176
|
**Q: And what about elements under iframes?**
|
|
143
177
|
|
|
@@ -173,11 +207,11 @@ your_page.important_element.click
|
|
|
173
207
|
|
|
174
208
|
**Q: And what about Cucumber? Will it work with Marta?**
|
|
175
209
|
|
|
176
|
-
*A:
|
|
210
|
+
*A: Yes it is working with Cucumber and Spinach. I will add some examples later.*
|
|
177
211
|
|
|
178
|
-
**Q:
|
|
212
|
+
**Q: Where is an example?**
|
|
179
213
|
|
|
180
|
-
*A:
|
|
214
|
+
*A: See "example_project" for rspec based example*
|
|
181
215
|
|
|
182
216
|
**Q: How can I design more object oriented and DRY tests using Marta**
|
|
183
217
|
|
|
@@ -206,7 +240,7 @@ g_page.search "I am in love with selenium."
|
|
|
206
240
|
|
|
207
241
|
**Q: What else?**
|
|
208
242
|
|
|
209
|
-
*A: Nothing. Marta is under development. Her version is 0.
|
|
243
|
+
*A: Nothing. Marta is under development. Her version is 0.30366 only. And I am not a professional developer. But I am training her on new tricks.*
|
|
210
244
|
|
|
211
245
|
## Internal Design
|
|
212
246
|
|
|
@@ -299,7 +333,7 @@ end
|
|
|
299
333
|
|
|
300
334
|
## Development
|
|
301
335
|
|
|
302
|
-
After checking out the repo, run `
|
|
336
|
+
After checking out the repo, run `bundle install` to install dependencies. Then run `rake install` to install the current version of gem. Then, run `rake spec` to run the tests.
|
|
303
337
|
|
|
304
338
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
305
339
|
|
data/lib/marta/data/style.css
CHANGED
|
@@ -222,15 +222,16 @@ div[martastyle=html_content] div {
|
|
|
222
222
|
padding: 5px;
|
|
223
223
|
border-style: solid;
|
|
224
224
|
border-width: 1px;
|
|
225
|
-
width: 90
|
|
225
|
+
width: 90%;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
div[martastyle=html_content] div span {
|
|
229
229
|
display: block;
|
|
230
230
|
position: relative;
|
|
231
|
-
left: 30px;
|
|
231
|
+
margin-left: 30px;
|
|
232
232
|
text-align: left;
|
|
233
233
|
cursor: pointer;
|
|
234
|
+
word-wrap:break-word;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
div[martaclass=marta_div] b {
|
data/lib/marta/dialogs.rb
CHANGED
data/lib/marta/json_2_class.rb
CHANGED
|
@@ -86,8 +86,8 @@ module Marta
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def build_content(data)
|
|
89
|
-
build_methods(data['meths'])
|
|
90
|
-
build_vars(data['vars'])
|
|
89
|
+
build_methods(data['meths']) if !data['meths'].nil?
|
|
90
|
+
build_vars(data['vars']) if !data['vars'].nil?
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def build_methods(methods)
|
|
@@ -116,6 +116,8 @@ module Marta
|
|
|
116
116
|
if !self.methods.include?(name.to_sym) and (@data['meths'][name].nil?)
|
|
117
117
|
self.singleton_class.send(:attr_accessor, name.to_sym)
|
|
118
118
|
instance_variable_set("@#{name}", process_string(content))
|
|
119
|
+
elsif self.methods.include?(name.to_sym) and (@data['meths'][name].nil?)
|
|
120
|
+
instance_variable_set("@#{name}", process_string(content))
|
|
119
121
|
else
|
|
120
122
|
if !@data['meths'][name].nil?
|
|
121
123
|
warn "Marta will not create '#{name}' variable for #{self.class}"\
|
|
@@ -17,6 +17,7 @@ module Marta
|
|
|
17
17
|
@@tolerancy = Hash.new
|
|
18
18
|
@@learn = Hash.new
|
|
19
19
|
@@engine = Hash.new
|
|
20
|
+
@@base_url = Hash.new
|
|
20
21
|
|
|
21
22
|
# Getting uniq id for process thread
|
|
22
23
|
def self.thread_id
|
|
@@ -52,6 +53,11 @@ module Marta
|
|
|
52
53
|
@@engine[thread_id]
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
# Marta knows what web application she is trying to test
|
|
57
|
+
def self.base_url
|
|
58
|
+
@@base_url[thread_id]
|
|
59
|
+
end
|
|
60
|
+
|
|
55
61
|
# Marta is changing parameters by the same scheme.
|
|
56
62
|
def self.parameter_set(what, value, default)
|
|
57
63
|
what[thread_id] = !value.nil? ? value : what[thread_id]
|
|
@@ -101,6 +107,16 @@ module Marta
|
|
|
101
107
|
def self.set_tolerancy(value)
|
|
102
108
|
@@tolerancy = parameter_set(@@tolerancy, value, 1024)
|
|
103
109
|
end
|
|
110
|
+
|
|
111
|
+
# Marta uses a simple ruke to set the basic url.
|
|
112
|
+
def self.set_base_url(value)
|
|
113
|
+
if (value.nil?) or (value.class == String)
|
|
114
|
+
@@base_url = parameter_set(@@base_url, value, "")
|
|
115
|
+
else
|
|
116
|
+
raise ArgumentError, "Basic url at least should be a string. Not"\
|
|
117
|
+
" a #{value}:#{value.class}"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
104
120
|
end
|
|
105
121
|
|
|
106
122
|
private
|
|
@@ -127,14 +143,9 @@ module Marta
|
|
|
127
143
|
SettingMaster.tolerancy_value
|
|
128
144
|
end
|
|
129
145
|
|
|
130
|
-
# Marta
|
|
131
|
-
def
|
|
132
|
-
SettingMaster.
|
|
133
|
-
SettingMaster.set_folder folder
|
|
134
|
-
SettingMaster.set_learn learn
|
|
135
|
-
read_folder
|
|
136
|
-
SettingMaster.set_tolerancy tolerancy
|
|
137
|
-
engine
|
|
146
|
+
# Marta knows the basic url of the projec. If it is defined
|
|
147
|
+
def base_url
|
|
148
|
+
SettingMaster.base_url
|
|
138
149
|
end
|
|
139
150
|
end
|
|
140
151
|
end
|
data/lib/marta/public_methods.rb
CHANGED
|
@@ -29,9 +29,11 @@ module Marta
|
|
|
29
29
|
@data ||= my_data
|
|
30
30
|
@class_name ||= my_class_name
|
|
31
31
|
@edit_mark ||= will_edit
|
|
32
|
+
data_vars = Hash.new
|
|
32
33
|
build_content my_data
|
|
33
34
|
if will_edit
|
|
34
|
-
page_edit my_class_name, my_data
|
|
35
|
+
data_vars = page_edit my_class_name, my_data
|
|
36
|
+
my_data["vars"] = data_vars if data_vars != Hash.new
|
|
35
37
|
end
|
|
36
38
|
# We need optimization here very much!
|
|
37
39
|
build_content my_data
|
|
@@ -58,13 +60,16 @@ module Marta
|
|
|
58
60
|
|
|
59
61
|
# If page has url variable it can be opened like Page.new.open_page
|
|
60
62
|
def open_page(url = nil)
|
|
61
|
-
|
|
63
|
+
@path ||= ""
|
|
64
|
+
if !url.nil?
|
|
62
65
|
engine.goto url
|
|
63
|
-
|
|
64
|
-
if @url == nil
|
|
65
|
-
raise ArgumentError, "You should set url to use open_page"
|
|
66
|
-
end
|
|
66
|
+
elsif !@url.nil?
|
|
67
67
|
engine.goto @url
|
|
68
|
+
elsif base_url != ""
|
|
69
|
+
engine.goto base_url + "/" + (@path.nil? ? "" : @path)
|
|
70
|
+
else
|
|
71
|
+
raise ArgumentError, "You should set url to use open_page. You may"\
|
|
72
|
+
" also use base_url option for dance_with and path for page object"
|
|
68
73
|
end
|
|
69
74
|
end
|
|
70
75
|
|
|
@@ -56,12 +56,7 @@ module Marta
|
|
|
56
56
|
|
|
57
57
|
# Transforming an element to a subtype
|
|
58
58
|
def subtype_of(element)
|
|
59
|
-
|
|
60
|
-
#https://github.com/watir/watir/issues/537
|
|
61
|
-
if element.class == Watir::IFrame
|
|
62
|
-
element = @engine.iframe(xpath: @xpath)
|
|
63
|
-
end
|
|
64
|
-
element
|
|
59
|
+
@engine.element(xpath: @xpath).to_subtype
|
|
65
60
|
end
|
|
66
61
|
|
|
67
62
|
# Main logic. We are returning a prefinded collection
|
data/lib/marta/version.rb
CHANGED
data/lib/marta.rb
CHANGED
|
@@ -54,11 +54,13 @@ module Marta
|
|
|
54
54
|
# dance_with is for creating settings to be used later.
|
|
55
55
|
# Settings can be changed at any time by calling dance with.
|
|
56
56
|
# Read more in the README
|
|
57
|
-
def dance_with(browser: nil, folder: nil, learn: nil, tolerancy: nil
|
|
57
|
+
def dance_with(browser: nil, folder: nil, learn: nil, tolerancy: nil,
|
|
58
|
+
base_url: nil)
|
|
58
59
|
SettingMaster.set_engine browser
|
|
59
60
|
SettingMaster.set_folder folder
|
|
61
|
+
SettingMaster.set_base_url base_url
|
|
60
62
|
SettingMaster.set_learn learn
|
|
61
|
-
|
|
63
|
+
read_folder
|
|
62
64
|
SettingMaster.set_tolerancy tolerancy
|
|
63
65
|
engine
|
|
64
66
|
end
|
data/marta.gemspec
CHANGED
|
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.add_development_dependency "rake"
|
|
24
24
|
spec.add_development_dependency "rspec"
|
|
25
25
|
spec.add_development_dependency "simplecov"
|
|
26
|
-
spec.add_dependency "watir"
|
|
26
|
+
spec.add_dependency "watir", '~> 6.7.2'
|
|
27
27
|
spec.add_dependency "json"
|
|
28
28
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marta
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.30366'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergei Seleznev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-08-
|
|
11
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -70,16 +70,16 @@ dependencies:
|
|
|
70
70
|
name: watir
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- - "
|
|
73
|
+
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: 6.7.2
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- - "
|
|
80
|
+
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 6.7.2
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: json
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|