softwear-lib 1.3.13 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b1f4276e4fb33b20f7d84a98b0c6a7dc2a831cd
4
- data.tar.gz: 9c39b81dc8c6743b0a784a22822dba4eda82f657
3
+ metadata.gz: 796a34ecd1ab8a9df7114dda0eff8887a4862771
4
+ data.tar.gz: a7340a19f5bb73d05587084bd6a10402c6257908
5
5
  SHA512:
6
- metadata.gz: a764e96e8b481a9d48c02f3611b57ef6d91978471fd9dd48c5faf7618780933451baa96632bcee27c33daed8339b144f7606f75b71526b93526c948d1bd1dabd
7
- data.tar.gz: b355f311c2be574a7077087ab15b2d0fe05277f8d05341e0564ed179ec90db3c96408140f67a5201694a7db5e79f5e72c5bbc68907dcdef0577fa7819e5225c1
6
+ metadata.gz: e302e491ccb7c3d8ef64305dfa68ff3f95e9af84624bfc94d2671b950ad2368c6d24525722803d3a8461b40bbe339cc3e07aa7a71f814fd62e609e1829001df0
7
+ data.tar.gz: aa09921516bdae126c684859ea9127e95901210c8070c80fae8e07bb2871f7068b279bd1ac32652bb51392b5071ebed4a8604ed8f12ab295c7b034c4b5cae851
@@ -66,18 +66,11 @@ module Softwear::Lib
66
66
  end
67
67
  end
68
68
 
69
- def find_label_by_text(text)
69
+ def find_label_by_text(text, options = {})
70
70
  label = find_label(text)
71
71
  counter = 0
72
72
 
73
- # Because JavaScript testing is prone to errors...
74
- while label.nil? && counter < 10
75
- sleep(1)
76
- counter += 1
77
- label = find_label(text)
78
- end
79
-
80
- if label.nil?
73
+ if !options[:try] && label.nil?
81
74
  raise "Could not find label by text #{text}"
82
75
  end
83
76
 
@@ -91,73 +84,17 @@ module Softwear::Lib
91
84
  end
92
85
 
93
86
  module Select2
94
- def set_select2_field(field, value)
95
- page.execute_script %Q{$('#{field}').select2('val', '#{value}')}
96
- end
97
-
98
- def select2_search(value, options)
99
- label = find_label_by_text(options[:from])
100
- within label.first(:xpath,'.//..') do
101
- options[:from] = "##{find('.select2-container')['id']}"
102
- end
103
- targetted_select2_search(value, options)
104
- end
105
-
106
- def targetted_select2_search(value, options)
107
- page.execute_script %Q{$('#{options[:from]}').select2('open')}
108
- page.execute_script "$('#{options[:dropdown_css]} input.select2-input').val('#{value}').trigger('keyup-change');"
109
- select_select2_result(value)
110
- end
111
-
112
- def select2(value, options)
113
- label = find_label_by_text(options[:from])
114
-
115
- within label.first(:xpath,'.//..') do
116
- options[:from] = "##{find('.select2-container')['id']}"
117
- end
118
- targetted_select2(value, options)
119
- end
120
-
121
- def nogood_select2(value, from)
122
- label = find_label_by_text(from[:from])
123
-
124
- select2_container = nil
125
- within label.first(:xpath,'.//..') do
126
- select2_container = find('.select2-container')
87
+ def select2(text, options)
88
+ label = find_label_by_text(options[:from], try: true)
89
+ if label
90
+ selector = "select[name='#{label['for']}']"
91
+ else
92
+ selector = options[:from]
127
93
  end
128
94
 
129
- select2_container.find(".select2-choice").click
130
-
131
- find(:xpath, "//body").find("input.select2-input").set(value)
132
- page.execute_script(%|$("input.select2-input:visible").keyup();|)
133
- drop_container = ".select2-results"
134
- find(:xpath, "//body").find("#{drop_container} li", text: value).click
135
- end
136
-
137
-
138
- def select2_no_label value, options={}
139
- raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
140
-
141
- placeholder = options[:from]
142
- # TODO: still need this?
143
- # minlength = options[:minlength] || 4
144
-
145
- click_link placeholder
146
-
147
- select_select2_result(value)
148
- end
149
-
150
- def targetted_select2(value, options)
151
- # find select2 element and click it
152
- find(options[:from]).find('a').click
153
- select_select2_result(value)
154
- end
155
-
156
- def select_select2_result(value)
157
- # results are in a div appended to the end of the document
158
- within(:xpath, '//body') do
159
- page.find('div.select2-result-label', text: %r{#{Regexp.escape(value)}}i).click
160
- end
95
+ find("#{selector}+span").click
96
+ find('input.select2-search__field').set(text)
97
+ first('li.select2-results__option').click
161
98
  end
162
99
  end
163
100
 
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Lib
3
- VERSION = "1.3.13"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softwear-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.13
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler