marta 0.26150 → 0.28017

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23b20fe634d3cc98a3adbb3997269c9687256b23
4
- data.tar.gz: d9644a0f8c01d32f4d25c9f67e1b30482a24ec98
3
+ metadata.gz: 89341581be4f3b0b1ebf57de01d8e583748ac7c5
4
+ data.tar.gz: ff147c84a554e8ec66b3f94f0a1016bfb364cc7c
5
5
  SHA512:
6
- metadata.gz: 1ba5036b4d3350b73cc4004e39af27c9af90dd67ad89f9efac0e9937f54bcccba7463dc0156aa2ab7bced7702c08f823498edeb895d8c67b7a6cd7f28715b89a
7
- data.tar.gz: 2eb03fb937126b707e5290a765dc50314701301548389d5b8baf982316e5b542e694f719cbf38fbd21acb45dc691e276520df30e0ce847f4ee9fda4bd36dc65b
6
+ metadata.gz: 6abbbd0b0b39235df76bd6fa6abaaea92227fb4ede3a51f9ba65c6e0f6d86488dcc7430e9b52a3070099a90118acbda9fd00272e3c91c3af66920b116cc26d04
7
+ data.tar.gz: 4cd9c90457d6ef3dd77b924048b6b9fa6c5f125f2753c71b72502e566ce2c9b9762d4b8ad03e54dbcbd5952dee26d5093e870ac021e1252b6a46be7fca1d918b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Marta
2
2
 
3
- Marta is a pretty new way to write selenium tests for WEB applications using Watir. Main idea is very similar to cucumber. In Cucumber you are writing test and then defining a code behind it. In Marta you are writing code and then defining classes/pageobjects and methods/elements behind it thru your browser window.
3
+ Marta was planned as an element locating tool for Watir tests. But now Marta is also a pretty new way to write selenium tests for WEB applications using Watir. Main idea is very similar to cucumber. In Cucumber you are writing test and then defining a code behind it. In Marta you are writing code and then defining classes/pageobjects and methods/elements behind it thru your browser window.
4
4
 
5
5
  Also Marta is providing a little more stability when locating elements on the page.
6
6
 
@@ -193,7 +193,7 @@ g_page.search "I am in love with selenium."
193
193
 
194
194
  **Q: What else?**
195
195
 
196
- *A: Nothing. Marta is under development. Her version is 0.26150 only. And I am not a professional developer. But I am training her on new tricks.*
196
+ *A: Nothing. Marta is under development. Her version is 0.28017 only. And I am not a professional developer. But I am training her on new tricks.*
197
197
 
198
198
  ## Internal Design
199
199
 
@@ -1,7 +1,6 @@
1
1
  var marta_result = {};
2
2
  var marta_confirm_mark = false;
3
3
  var marta_temp_els =[];
4
- var marta_temp_styles = [];
5
4
 
6
5
  function marta_add_data() {
7
6
  marta_confirm_mark = false;
@@ -11,18 +10,16 @@ function marta_add_data() {
11
10
  function marta_look() {
12
11
  try {
13
12
  for (var i=0; i<marta_temp_els.snapshotLength; i++) {
14
- marta_temp_els.snapshotItem(i).setAttribute("style",marta_temp_styles[i]);
13
+ marta_temp_els.snapshotItem(i).removeAttribute("martaclass");
15
14
  };
16
15
  var t=0;
17
16
  var value = document.getElementById("marta_user_xpath").value;
18
17
  var result = document.evaluate(value, document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
19
18
  marta_temp_els = result;
20
-
21
19
  for (var i=0; i<result.snapshotLength; i++) {
22
20
  var marta_smthing = ((result.snapshotItem(i).getAttribute("martaclass")=="marta_smthing")||(result.snapshotItem(i).getAttribute("martaclass")=="marta_div"));
23
21
  if(!marta_smthing) {
24
- marta_temp_styles[i] = result.snapshotItem(i).getAttribute("style");
25
- result.snapshotItem(i).setAttribute("style","animation: marta_found 6s infinite;");
22
+ result.snapshotItem(i).setAttribute("martaclass","foundbymarta");
26
23
  t = t+1;
27
24
  };
28
25
  };
@@ -33,6 +30,9 @@ function marta_look() {
33
30
  };
34
31
 
35
32
  function marta_confirm(){
33
+ for (var i=0; i<marta_temp_els.snapshotLength; i++) {
34
+ marta_temp_els.snapshotItem(i).removeAttribute("martaclass");
35
+ };
36
36
  marta_result["collection"] = document.getElementById("marta_array").checked;
37
37
  marta_result["xpath"] = document.getElementById("marta_user_xpath").value;
38
38
  var toClear = document.querySelector("[martaclass=marta_smthing]");
@@ -41,6 +41,9 @@ function marta_confirm(){
41
41
  };
42
42
 
43
43
  function marta_try_again(){
44
+ for (var i=0; i<marta_temp_els.snapshotLength; i++) {
45
+ marta_temp_els.snapshotItem(i).removeAttribute("martaclass");
46
+ };
44
47
  var toClear = document.querySelector("[martaclass=marta_div]");
45
48
  toClear.parentNode.removeChild(toClear);
46
49
  marta_confirm_mark = true;
@@ -11,7 +11,8 @@
11
11
  <p martaclass=marta_smthing>Find it like a usual element and focus to it in code with dance_with(your_iframe)</p>
12
12
  </div>
13
13
  <div id=marta_s_content martaclass=marta_smthing>
14
- <input type=button martaclass=marta_smthing id=marta_confirm onclick=marta_confirm(); value=Confirm />
14
+ <input type=button martaclass=marta_smthing id=marta_confirm onclick=marta_end_loop(); value=Confirm />
15
+ <input type=button martaclass=marta_smthing id=marta_set_by_hand onclick=marta_set_by_hand(); value="Set by hand" />
15
16
  </div>
16
17
  <div id=marta_s_element_type martaclass=marta_smthing>
17
18
  <div martaclass=marta_smthing class=label id=marta_element_label>What we are looking for (one element or group?)</div>
@@ -57,6 +57,7 @@ function marta_change_field(field){
57
57
  marta_result[data[0]][data[1]][parseInt(data[2])]=field.value;
58
58
  };
59
59
  };
60
+ marta_confirm();
60
61
  };
61
62
 
62
63
  function marta_confirm(){
@@ -84,7 +85,7 @@ function marta_confirm(){
84
85
  function marta_add_data() {
85
86
  marta_result = old_marta_Data;
86
87
  marta_confirm_mark = false;
87
- document.getElementById("marta_main_title").innerHTML = "You are defining " + marta_what;
88
+ document.getElementById("marta_main_title").innerHTML = marta_what;
88
89
  if (old_marta_Data != {}){
89
90
  try {
90
91
  document.getElementById("marta_array").checked = old_marta_Data["options"]["collection"];}
@@ -131,6 +132,7 @@ function marta_click_work(e, iframe=false) {
131
132
  e.stopPropagation();
132
133
  e.preventDefault();
133
134
  };
135
+ marta_confirm();
134
136
  };
135
137
  };
136
138
 
@@ -142,7 +144,7 @@ function marta_after_click(el, what) {
142
144
  marta_add_field("TAG", what, marta_result["options"][what], "taggy");
143
145
  for (var att, i = 0, atts = el.attributes, n = atts.length; i < n; i++){
144
146
  att = atts[i];
145
- if(/^[a-zA-Z0-9- _!@#$%^*();:,.?/]*$/.test(att.nodeValue) == true){
147
+ if(/^[a-zA-Z0-9- _!@#$%^*();:,.?/]*$/.test(att.nodeValue) == true && att.nodeName != "martaclass"){
146
148
  if (/class/.test(att.nodeName) == true){
147
149
  var values=att.nodeValue.split(" ");
148
150
  marta_result[what][att.nodeName]=[];
@@ -180,4 +182,20 @@ function marta_delete_line(line) {
180
182
  marta_change_field(field);
181
183
  title.parentNode.removeChild(title);
182
184
  staff.parentNode.removeChild(staff);
183
- };
185
+ };
186
+
187
+ function marta_set_by_hand(){
188
+ var toClear = document.querySelector("[martaclass=marta_div]");
189
+ toClear.parentNode.removeChild(toClear);
190
+ marta_confirm_mark = true;
191
+ marta_result = "3";
192
+ };
193
+
194
+ function marta_end_loop(){
195
+ if (marta_room != 0){
196
+ var toClear = document.querySelector("[martaclass=marta_smthing]");
197
+ toClear.parentNode.removeChild(toClear);
198
+ marta_confirm_mark = true;
199
+ marta_result = "1";
200
+ }
201
+ };
@@ -81,7 +81,7 @@ div#marta_s_everything *, div#marta_s_everything {
81
81
  empty-cells : show;
82
82
  float : none;
83
83
  font : normal;
84
- font-family : inherit;
84
+ font-family : sans-serif;
85
85
  font-size : medium;
86
86
  font-style : normal;
87
87
  font-variant : normal;
@@ -206,4 +206,8 @@ div#marta_s_everything input[type=checkbox]
206
206
  background-repeat:no-repeat;
207
207
  background-position: 0 0;
208
208
  font-size:16px;
209
- vertical-align:middle;}
209
+ vertical-align:middle;
210
+ }
211
+ [martaclass=foundbymarta]
212
+ {animation: marta_found 6s infinite;
213
+ }
data/lib/marta/dialogs.rb CHANGED
@@ -3,6 +3,7 @@ require 'marta/x_path'
3
3
  require 'marta/lightning'
4
4
  require 'marta/injector'
5
5
  require 'marta/public_methods'
6
+
6
7
  module Marta
7
8
 
8
9
  #
@@ -28,6 +29,9 @@ module Marta
28
29
  @data = data
29
30
  @title = class_name+ '.' + method_name.to_s
30
31
  @requestor = requestor
32
+ @found = 0
33
+ @attrs = @data['meths'][@method_name]
34
+ @mass = Array.new
31
35
  end
32
36
 
33
37
  # Standart question
@@ -35,15 +39,29 @@ module Marta
35
39
  inject(what, title, data)
36
40
  end
37
41
 
42
+ # Was something stated by user?
43
+ def attrs_exists?
44
+ if !@attrs.nil?
45
+ @attrs != Hash.new
46
+ else
47
+ false
48
+ end
49
+ end
50
+
38
51
  # Main method. All the dialog logic is here
39
52
  def dialog
40
53
  while !finished? do
41
- @attrs = ask_for_elements
42
- @mass = get_elements_by_attrs
43
- @styles = mass_highlight_turn @mass
44
- @result = ask_confirmation
45
- mass_highlight_turn(@mass, false, @styles)
54
+ if attrs_exists?
55
+ @mass = get_elements_by_attrs
56
+ mass_highlight_turn @mass
57
+ end
58
+ @result = ask_for_elements
59
+ if @result.class == Hash
60
+ @attrs = @result
61
+ end
62
+ mass_highlight_turn(@mass, false)
46
63
  end
64
+
47
65
  if @result == '1'
48
66
  standart_meth_merge
49
67
  else
@@ -53,7 +71,7 @@ module Marta
53
71
 
54
72
  # Asking: "What are you looking for?"
55
73
  def ask_for_elements
56
- ask 'element', @title, @data['meths'][@method_name]
74
+ ask 'element', "Found #{@found} elements for #{@title}", @attrs
57
75
  end
58
76
 
59
77
  # Creating data to save when it is a basically defined element
@@ -74,8 +92,14 @@ module Marta
74
92
 
75
93
  # Finding out what was selected
76
94
  def get_elements_by_attrs
77
- xpath = XPathFactory.new(@attrs, @requestor).generate_xpath
78
- engine.elements(xpath: xpath)
95
+ if @attrs['options']['xpath'].nil?
96
+ xpath = XPathFactory.new(@attrs, @requestor).generate_xpath
97
+ else
98
+ xpath = @attrs['options']['xpath']
99
+ end
100
+ result = engine.elements(xpath: xpath)
101
+ @found = result.length
102
+ result
79
103
  end
80
104
 
81
105
  # Asking: "Are you sure?"
@@ -97,13 +121,27 @@ module Marta
97
121
  if @result == '1'
98
122
  true
99
123
  elsif @result == '3'
100
- @result = ask_xpath
101
- (@result != '2') ? true : false
124
+ xpath_way
102
125
  else
103
126
  false
104
127
  end
105
128
  end
106
129
 
130
+ # When user selects xpath way. Marta is doing some work before finish
131
+ def xpath_way
132
+ @result = ask_xpath
133
+ if @result == '2'
134
+ false
135
+ else
136
+ @attrs['options'] = @result
137
+ @mass = get_elements_by_attrs
138
+ mass_highlight_turn @mass
139
+ @result = ask_confirmation
140
+ mass_highlight_turn(@mass, false)
141
+ finished?
142
+ end
143
+ end
144
+
107
145
  # Forming of an empty hash for storing element info
108
146
  def temp_hash
109
147
  temp, temp['meths'], temp['meths'][@method_name],
@@ -7,30 +7,25 @@ module Marta
7
7
 
8
8
  # We can highlight an element
9
9
  def highlight(element)
10
- orig_style = element.attribute_value("style")
11
- engine.execute_script("arguments[0].setAttribute(arguments[1],"\
12
- " arguments[2])", element, "style",
13
- "animation: marta_found 6s infinite;")
14
- orig_style
10
+ engine.execute_script("arguments[0].setAttribute"\
11
+ "('martaclass','foundbymarta')", element)
15
12
  end
16
13
 
17
14
  # We can unhighlight an element
18
- def unhighlight(element, style)
19
- engine.execute_script("arguments[0].setAttribute(arguments[1],"\
20
- " arguments[2])", element, "style", style)
15
+ def unhighlight(element)
16
+ engine.execute_script("arguments[0].removeAttribute('martaclass')",
17
+ element)
21
18
  end
22
19
 
23
20
  # We can highlight\unhighlight tons of elements at once
24
- def mass_highlight_turn(mass, turn_on = true, styles = nil)
25
- result = Array.new
21
+ def mass_highlight_turn(mass, turn_on = true)
26
22
  mass.each_with_index do |element, i|
27
23
  if turn_on
28
- result[i] = highlight(element)
24
+ highlight element
29
25
  else
30
- unhighlight(element, styles[i])
26
+ unhighlight element
31
27
  end
32
28
  end
33
- result
34
29
  end
35
30
  end
36
31
  end
data/lib/marta/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Marta
2
- VERSION = "0.26150"
2
+ VERSION = "0.28017"
3
3
  NAME = "marta"
4
4
  end
data/marta.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["s_seleznev_qa@hotmail.com"]
11
11
 
12
12
  spec.summary = "That will be an another one watir-webdriver wrap"
13
- spec.description = "It's nothing to describe now."
13
+ spec.description = "Element location tool for your watir autotests"
14
14
  spec.homepage = "https://github.com/sseleznevqa/marta"
15
15
  spec.license = "MIT"
16
16
 
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "simplecov"
25
26
  spec.add_dependency "watir"
26
27
  #spec.add_dependency "fileutils"
27
28
  spec.add_dependency "json"
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.26150'
4
+ version: '0.28017'
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-06-13 00:00:00.000000000 Z
11
+ date: 2017-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: watir
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +94,7 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
- description: It's nothing to describe now.
97
+ description: Element location tool for your watir autotests
84
98
  email:
85
99
  - s_seleznev_qa@hotmail.com
86
100
  executables: []