marta 0.28017 → 0.28675

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89341581be4f3b0b1ebf57de01d8e583748ac7c5
4
- data.tar.gz: ff147c84a554e8ec66b3f94f0a1016bfb364cc7c
3
+ metadata.gz: e2794c78d3cf457b70f2c182df894b205e006ce0
4
+ data.tar.gz: 79ba7ed2850da9a2fe982d0d9a29efdb24b4d2e9
5
5
  SHA512:
6
- metadata.gz: 6abbbd0b0b39235df76bd6fa6abaaea92227fb4ede3a51f9ba65c6e0f6d86488dcc7430e9b52a3070099a90118acbda9fd00272e3c91c3af66920b116cc26d04
7
- data.tar.gz: 4cd9c90457d6ef3dd77b924048b6b9fa6c5f125f2753c71b72502e566ce2c9b9762d4b8ad03e54dbcbd5952dee26d5093e870ac021e1252b6a46be7fca1d918b
6
+ metadata.gz: 06d88ae0acaa491e65d737bee32ac5313b25972378168cc1e603f61f1b367b0dc514cf820d9d875f74f3d4335fb4bcc46781cb27bead760c675f1d14731072cb
7
+ data.tar.gz: a1a85fdd3f13c95c437893bc103d764a52235ed0b10867d697cde2ac6b72c4e6b6d89e9e830aa15fc291f610c6c541d1cf61a5b0c5de010d4ba5f5c6cd86f613
data/README.md CHANGED
@@ -95,6 +95,19 @@ dance_with learn: true or false
95
95
  your_page.method_edit('newelementname')
96
96
  ```
97
97
 
98
+ **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
+
100
+ *A Code in learn mode =*
101
+ ```ruby
102
+ test_page = TestPage.new # Will show page creation dialog
103
+ test_page.magic_button # Will show magic_button locating dialog
104
+ ```
105
+ *is totally identical to code without learn mode =*
106
+ ```ruby
107
+ test_page = SmartPage.new("TestPage")
108
+ test_page.method_edit("magic_button")
109
+ ```
110
+
98
111
  **Q: Sometimes Marta is looking for lost element for too long. What can I do about it?**
99
112
 
100
113
  *A: You can set tolerancy parameter. Larger = longer*
@@ -193,7 +206,7 @@ g_page.search "I am in love with selenium."
193
206
 
194
207
  **Q: What else?**
195
208
 
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.*
209
+ *A: Nothing. Marta is under development. Her version is 0.28675 only. And I am not a professional developer. But I am training her on new tricks.*
197
210
 
198
211
  ## Internal Design
199
212
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  <div id=marta_s_text martaclass=marta_smthing>
4
4
  <h2 id=marta_main_title martaclass=marta_smthing></h2>
5
+ <p martaclass=marta_smthing>If you cannot see all the elements try to move menu down using a button below</p>
6
+ <input type=button martaclass=marta_smthing id=marta_down onclick=marta_down(); value=DOWN />
5
7
  <p martaclass=marta_smthing>You are about to write your own xpath.</p>
6
8
  <p martaclass=marta_smthing>Use it when element is: invisible, not present, should be found by exact xpath, marta fails to find it.</p>
7
9
  <p martaclass=marta_smthing>Marta will highlight the elements targeted by your xpath. Sometimes it will even show hidden elements.</p>
@@ -49,3 +49,8 @@ function marta_try_again(){
49
49
  marta_confirm_mark = true;
50
50
  marta_result = "2";
51
51
  };
52
+
53
+ function marta_down() {
54
+ var toDown = document.querySelector("[martaclass=marta_div]");
55
+ toDown.setAttribute("martastyle", "down");
56
+ }
@@ -1,6 +1,8 @@
1
1
  <div id=marta_s_everything martaclass=marta_smthing>
2
2
  <div id=marta_s_text martaclass=marta_smthing>
3
3
  <h2 id=marta_main_title martaclass=marta_smthing></h2>
4
+ <p martaclass=marta_smthing>If you cannot see all the elements try to move menu down using a button below</p>
5
+ <input type=button martaclass=marta_smthing id=marta_down onclick=marta_down(); value=DOWN />
4
6
  <p martaclass=marta_smthing>You are about to confirm element selection</p>
5
7
  <p martaclass=marta_smthing>Marta highlights elements right now</p>
6
8
  <p martaclass=marta_smthing>If something wrong was found - maybe it is time to talk to the developer?</p>
@@ -5,7 +5,7 @@ function marta_confirm(){
5
5
  var toClear = document.querySelector("[martaclass=marta_smthing]");
6
6
  toClear.parentNode.removeChild(toClear);
7
7
  marta_confirm_mark = true;
8
- marta_result = "1";
8
+ marta_result = "4";
9
9
  };
10
10
 
11
11
  function marta_click_work(e){};
@@ -28,3 +28,8 @@ function marta_add_data() {
28
28
  marta_confirm_mark = false;
29
29
  document.getElementById("marta_main_title").innerHTML = old_marta_Data + " elements found for " + marta_what;
30
30
  };
31
+
32
+ function marta_down() {
33
+ var toDown = document.querySelector("[martaclass=marta_div]");
34
+ toDown.setAttribute("martastyle", "down");
35
+ }
@@ -1,6 +1,8 @@
1
1
  <div id=marta_s_everything martaclass=marta_smthing>
2
2
  <div id=marta_s_text martaclass=marta_smthing>
3
3
  <h2 id=marta_main_title martaclass=marta_smthing></h2>
4
+ <p martaclass=marta_smthing>If you cannot see all the elements try to move menu down using a button below</p>
5
+ <input type=button martaclass=marta_smthing id=marta_down onclick=marta_down(); value=DOWN />
4
6
  <p martaclass=marta_smthing>You are about to define some element</p>
5
7
  <p martaclass=marta_smthing>CLICK to select element. Do not worry nothing will work</p>
6
8
  <p martaclass=marta_smthing>After the click select the attributes of an element and parents</p>
@@ -199,3 +199,8 @@ function marta_end_loop(){
199
199
  marta_result = "1";
200
200
  }
201
201
  };
202
+
203
+ function marta_down() {
204
+ var toDown = document.querySelector("[martaclass=marta_div]");
205
+ toDown.setAttribute("martastyle", "down");
206
+ }
@@ -1,7 +1,8 @@
1
1
  <div id=marta_s_everything martaclass=marta_smthing>
2
-
3
2
  <div id=marta_s_text>
4
3
  <h2 id=marta_main_title></h2>
4
+ <p>If you cannot see all the elements try to move menu down using a button below</p>
5
+ <input type=button martaclass=marta_smthing id=marta_down onclick=marta_down(); value=DOWN />
5
6
  <p>You are about to add some vars to the page_object</p>
6
7
  <p>Please use only valid names for ruby vars (no <b>CROCO</b>, <b>special symbols</b>, just <b>some_var</b> or <b>anotherVar</b>)</p>
7
8
  <p>You can use variable in the other one adding: <b>#{@your_var}</b> just like in ruby</p>
@@ -13,7 +14,6 @@
13
14
  <div id=marta_s_content>
14
15
  <input type=button martaclass=marta_smthing id=marta_more_fields onclick=marta_add_field(); value=Add More />
15
16
  <input type=button martaclass=marta_smthing id=marta_confirm onclick=marta_confirm(); value=Confirm />
16
-
17
17
  <div id=vars_fileds>
18
18
  <div class=label>Custom vars:</div>
19
19
  <div class=content>
@@ -36,3 +36,8 @@ function marta_delete_line(line) {
36
36
  title.parentNode.removeChild(title);
37
37
  staff.parentNode.removeChild(staff);
38
38
  };
39
+
40
+ function marta_down() {
41
+ var toDown = document.querySelector("[martaclass=marta_div]");
42
+ toDown.setAttribute("martastyle", "down");
43
+ }
@@ -156,11 +156,10 @@ div#marta_s_everything *, div#marta_s_everything {
156
156
  div#marta_s_everything h2 {
157
157
  text-align: center;
158
158
  font-size: 20px;}
159
- div#marta_s_everything {
159
+ div[martaclass=marta_div] {
160
160
  position : relative;
161
161
  z-index : 150000;
162
162
  padding: 0;
163
- margin: 0;
164
163
  margin: 0px 0px 0px 0px;
165
164
  border: 4px solid rgb(115,115,100);
166
165
  font-size: 14px;
@@ -168,6 +167,10 @@ div#marta_s_everything {
168
167
  background-color: rgb(230,230,200);
169
168
  color: black;
170
169
  }
170
+
171
+ div[martastyle=down] {
172
+ margin: 100% 0px 0px 0px;
173
+ }
171
174
  div#marta_s_everything p {text-align: left;
172
175
  margin-left: 20px;}
173
176
  div#marta_s_everything p b {color: red;}
data/lib/marta/dialogs.rb CHANGED
@@ -56,12 +56,13 @@ module Marta
56
56
  mass_highlight_turn @mass
57
57
  end
58
58
  @result = ask_for_elements
59
+ mass_highlight_turn(@mass, false)
59
60
  if @result.class == Hash
60
61
  @attrs = @result
62
+ elsif @result != '1'
63
+ xpath_way
61
64
  end
62
- mass_highlight_turn(@mass, false)
63
65
  end
64
-
65
66
  if @result == '1'
66
67
  standart_meth_merge
67
68
  else
@@ -85,7 +86,7 @@ module Marta
85
86
  # Creating data to save when user suggests a custom xpath
86
87
  def xpath_meth_merge
87
88
  temp = temp_hash
88
- temp['meths'][@method_name]['options'] = @result
89
+ temp['meths'][@method_name]['options'] = @attrs['options']
89
90
  @data['meths'].merge!(temp['meths'])
90
91
  @data
91
92
  end
@@ -118,10 +119,8 @@ module Marta
118
119
  # JS returning '1' when it's done. That is not good
119
120
  # and should be rewrited as soon as possible
120
121
  def finished?
121
- if @result == '1'
122
+ if @result == '1' or @result == '4'
122
123
  true
123
- elsif @result == '3'
124
- xpath_way
125
124
  else
126
125
  false
127
126
  end
@@ -130,15 +129,13 @@ module Marta
130
129
  # When user selects xpath way. Marta is doing some work before finish
131
130
  def xpath_way
132
131
  @result = ask_xpath
133
- if @result == '2'
134
- false
135
- else
132
+ if @result != '2'
133
+ @attrs = Hash.new
136
134
  @attrs['options'] = @result
137
135
  @mass = get_elements_by_attrs
138
136
  mass_highlight_turn @mass
139
137
  @result = ask_confirmation
140
138
  mass_highlight_turn(@mass, false)
141
- finished?
142
139
  end
143
140
  end
144
141
 
@@ -36,24 +36,15 @@ module Marta
36
36
  include OptionsAndPaths, ReadWrite
37
37
 
38
38
  #
39
- # Main class creation method. SmartPage method is only working with
40
- # a proper initialization.
39
+ # Main class creation method.
41
40
  #
42
- # By default SmartPage has no initialization which is making it almost
43
- # useles while not constructed like that. It will be fixed.
41
+ # SmartPage can be initialized with user data as well
44
42
  def self.create(class_name, data, edit)
45
43
  c = Class.new(SmartPage) do
44
+ alias_method :old_init, :initialize
46
45
  define_method :initialize do |my_data=data, my_class_name=class_name,
47
46
  will_edit=edit|
48
- @data = my_data
49
- @class_name = class_name
50
- @edit_mark = will_edit
51
- build_content my_data
52
- if will_edit
53
- page_edit my_class_name, my_data
54
- end
55
- # We need optimization here very much!
56
- build_content my_data
47
+ old_init(class_name, my_data, will_edit)
57
48
  end
58
49
  end
59
50
  # We are vanishing previous version of class
@@ -122,7 +113,7 @@ module Marta
122
113
  end
123
114
 
124
115
  def build_var(name, content)
125
- if !self.methods.include?(name.to_sym) and (@data['meths'][name] == nil)
116
+ if !self.methods.include?(name.to_sym) and (@data['meths'][name].nil?)
126
117
  self.singleton_class.send(:attr_accessor, name.to_sym)
127
118
  instance_variable_set("@#{name}", process_string(content))
128
119
  else
@@ -107,9 +107,9 @@ module Marta
107
107
 
108
108
  # Defining the place for files to inject to browser
109
109
  def gem_libdir
110
- t = ["#{File.dirname(File.expand_path($0))}/../lib/#{Marta::NAME}",
110
+ t = ["#{Dir.pwd}/lib/#{Marta::NAME}",
111
111
  "#{Gem.dir}/gems/#{Marta::NAME}-#{Marta::VERSION}/lib/#{Marta::NAME}"]
112
- t.each {|i| return i if File.readable?(i) }
112
+ File.readable?(t[0])? t[0] : t[1]
113
113
  end
114
114
 
115
115
  # Marta knows does she learn or not.
@@ -6,6 +6,37 @@ module Marta
6
6
 
7
7
  include OptionsAndPaths
8
8
 
9
+
10
+ #
11
+ # User can create pageobject class using SmartPage.new
12
+ #
13
+ # SmartPage can be created withoud all the data. But in that case
14
+ # it will be pretty useless until values are provided
15
+ #
16
+ # The first argument is a class name. It is a constant like string like
17
+ # "MyClass". All data provided will be stored in MyClass.json
18
+ # Once created that way you can call it like MyClass.new.
19
+ # That argument is totally necessary one
20
+ #
21
+ # The second argument is a marta's special data hash. By default =
22
+ # {"vars"=>{},"meths"=>{}}. You can take an existing json as well.
23
+ # Notice that rocket like syntax is a must here. It will be changed later
24
+ #
25
+ # Third parameter is about to show or not default page creation dialog.
26
+ # So it can be true or false
27
+ def initialize(my_class_name, my_data = ({"vars" => {},"meths" => {}}),
28
+ will_edit = true)
29
+ @data ||= my_data
30
+ @class_name ||= my_class_name
31
+ @edit_mark ||= will_edit
32
+ build_content my_data
33
+ if will_edit
34
+ page_edit my_class_name, my_data
35
+ end
36
+ # We need optimization here very much!
37
+ build_content my_data
38
+ end
39
+
9
40
  # User can define a method for example in a middle of a debug session
10
41
  def method_edit(name)
11
42
  method_name = correct_name(name)
data/lib/marta/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Marta
2
- VERSION = "0.28017"
2
+ VERSION = "0.28675"
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 = "Element location tool for your watir autotests"
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
 
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.28017'
4
+ version: '0.28675'
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-07-02 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Element location tool for your watir autotests
97
+ description: Element location tool for your watir autotests.
98
98
  email:
99
99
  - s_seleznev_qa@hotmail.com
100
100
  executables: []