Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

vidjil_browser.rb 11.1 KB
Newer Older
1
# coding: utf-8
Mikaël Salson's avatar
Mikaël Salson committed
2
require 'watir'
3 4 5

class VidjilBrowser < Watir::Browser

6 7 8 9
  def initialize
    if ENV['WATIR_BROWSER_PATH']
      print "Using custom browser location " + ENV['WATIR_BROWSER_PATH'] + "\n"
      Selenium::WebDriver::Firefox.path = ENV['WATIR_BROWSER_PATH']
10
      Selenium::WebDriver::Chrome.path = ENV['WATIR_BROWSER_PATH'] 
11 12
    end
    # :chrome or :safari
13
    if ENV['WATIR_CHROME'] or ENV['WATIR_BROWSER_PATH'].include? "chrom"
14
      super :chrome
15 16
    elsif ENV['WATIR_MARIONETTE']
      super :firefox
17 18 19
    else
      super :firefox, :marionette => false
    end
20 21

    print "Running "+driver.capabilities.browser_name+" "+driver.capabilities.version+"\n"
22 23
  end

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  # Return the text field that allows to edit a clone name
  def clone_name_editor
    return text_field(:id => 'new_name')
  end

  # Buttons that allows to save a name change
  def clone_name_saver
    return a(:id => 'btnSave')
  end

  # Return the clone in the list
  def clone_in_list(id, extra={})
    return list.li(extra.merge(:id => id))
  end

  # Return the info on the clone in the list (one item of a list)
40
  # A hash with keys cluster, system, name, info, star, axis and size defined with
41 42 43
  # the corresponding elements in the list.
  def clone_info(id, extra={})
    clone = clone_in_list(id, extra)
Mikaël Salson's avatar
Mikaël Salson committed
44
    return {cluster: clone.element(:class => 'clusterBox'), system: clone.element(:class => "systemBox"),
45
            name: clone.element(:class => 'nameBox'), info: clone.element(:class => 'infoBox'),
46 47
            star: clone.element(:class => 'starBox'), size: clone.element(:class => 'sizeBox'),
            axis: clone.element(:class => 'axisBox')}
48
  end
49 50 51 52 53 54

  # Return the clone cluster for clone ID
  def clone_cluster(id, extra = {})
    return clone_in_list(id, extra).element(:id => 'cluster'+id)
  end

55 56
  # Return a given clone in a cluster for clone ID
  # n: a str corresponding to the clone ID in the cluster
57 58 59 60 61 62 63
  def clone_in_cluster(id, n, extra = {})
    cluster = clone_cluster(id, extra).element(:id => '_'+n)
    return {object: cluster,
            name: cluster.element(:class => 'nameBox'), size: cluster.element(:class => 'sizeBox'),
            info: cluster.element(:class => 'infoBox'), delete: cluster.element(:class => 'delBox')}
  end

64
  # Return a hash with information on the sequence in the segmenter
65
  # A hash with keys name, star, axis and size defined with
66 67 68 69
  # the corresponding elements in the segmenter.
  def clone_info_segmenter(id, extra={})
    item = clone_in_segmenter(id, extra)
    return {name: item.element(:class => 'nameBox'), star: item.element(:class => 'starBox'),
70
            size: item.element(:class => 'sizeBox'), identity: item.element(:class => 'identityBox'),
71
            info: item.elements(:class => 'infoBox'), axis: item.element(:class => 'axisBox')
72
    }
73 74 75 76
  end


  # Return the clone on the scatterplot
77
  # Beware the id must be a string
78 79
  def clone_in_scatterplot(id, extra={}, number=1)
    circle = element(extra.merge(:id => scatterplot_id(number) + "_circle"+id))
Mikaël Salson's avatar
Mikaël Salson committed
80
    if circle.exists? and not circle.present?
81
      bar = element(extra.merge(:id => scatterplot_id(number) + "_bar"+id))
Mikaël Salson's avatar
Mikaël Salson committed
82
      if bar.exists? and bar.present?
83 84 85 86
        return bar
      end
    end
    return circle
87 88 89
  end

  # Return the clone in the graph
90
  # Beware the id must be a string
91 92 93 94 95
  def clone_in_graph(id, extra={})
    return element(extra.merge(:id => "polyline"+id))
  end

  # Return the item of clone id in segmenter (may not exist…)
96
  # Beware the id must be a string
97 98 99 100
  def clone_in_segmenter(id, extra={})
    return element(extra.merge(:id => 'seq'+id))
  end

101 102 103 104 105
  # Change the coloration
  def color_by(dimension)
    menu_color.select_list.select dimension
  end

106 107 108 109 110 111 112
  # Return an associative array (keys name, and value) for the following external data
  def external_data(id)
    item = element(:id => 'data_'+id)
    return {name: item.element(:class => 'data_name').text,
            value: item.element(:class => 'data_value').text.to_f}
  end

113 114 115 116 117
  # Return the div of the graph component
  def graph(extra = {})
    return element(extra.merge(:class => 'graph', :id => 'visu2'))
  end

118 119 120 121 122
  # Return the x legend of the graph (id is a string from 0 to the number of samples - 1)
  def graph_x_legend(id, extra = {})
    return graph.element(extra.merge(:id => 'time'+id))
  end

123 124 125 126 127
  # Information on the currently displayed point
  def info_point
    return element(:id => 'info_point')
  end

128 129 130 131 132 133 134 135
  def info_segmented
    return element(:id => 'info_segmented').span(:index => 1)
  end

  def info_selected_locus
    return element(:id => 'info_selected_locus').span(:index => 1)
  end

136 137
  # Return the div containing the information (status bar)
  def infoline
138
    return div(:id => segmenter_id).div(:class => 'focus')
139 140
  end

141 142
  # Return the span of the locus
  def locus_topleft(locus)
Mikaël Salson's avatar
Mikaël Salson committed
143
       return span(:class => ['systemBoxNameMenu', locus])
144 145
  end

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
  def menu_patient
    return div(:id => 'db_menu')
  end

  def menu_import_export
    return div(:id => 'demo_file_menu')
  end

  def menu_cluster
    return div(:id => 'cluster_menu')
  end

  def menu_analysis
    return div(:id => 'analysis_menu')
  end

  def menu_color
    return div(:id => 'color_menu')
  end

  def menu_filter
    return div(:id => 'filter_menu')
  end
  
  def menu_settings
    return div(:id => 'settings_menu')
  end
173

174 175 176 177 178 179 180 181 182 183 184 185
  def menu_palette
    return div(:id => 'palette_menu')
  end

  def menu_help
    return div(:id => 'help_menu')
  end

  def menu_upload
    return div(:id => 'upload_summary')
  end

186
  def menu_item_export(id, extra = {})
187 188
    menu = menu_import_export
    menu.click
189
    return menu.a(extra.merge(:id => id))
190 191
  end

192 193
  def menu_item_export_fasta(extra = {})
    return menu_item_export('export_fasta', extra)
194 195
  end

196 197
  def menu_item_export_fasta_align(extra = {})
    return menu_item_export('export_fasta_align', extra)
198 199
  end

200 201 202 203 204 205 206 207 208 209 210 211 212
  def menu_item(id, extra = {})
    item = element(extra.merge(:id => id))
    assert(item.exists?)
    parent = item.parent
    while parent.tag_name != "body" and not parent.classes.include? "menu"
      parent = parent.parent
    end
    if parent.tag_name != "body"
      parent.click
    end
    return item
  end

213 214 215 216 217 218 219 220
  def merge
    return element(:id => 'merge')
  end

  def select_tag(id, extra={})
    return element(extra.merge(:id => 'fastTag'+id))
  end

221
  # Return the div of the scatterplot
222 223 224
  # The number gives the number of the scatterplot
  def scatterplot(number=1)
    return element(:id => scatterplot_id(number))
225 226
  end

227 228
  def scatterplot_menu(number=1)
    return scatterplot(number).element(:class => 'sp_menu')
229 230 231 232
  end

  # Select a preset in the scatterplot menu
  # (String or Regex)
233 234
  def scatterplot_select_preset(axis, number = 1)
    scatterplot_menu(number).hover
Mikaël Salson's avatar
Mikaël Salson committed
235
    sleep 1
236 237 238
    preset_selector.select axis
  end

239
  # Return the element corresponding to the x axis of the scatterplot
240 241
  def scatterplot_x(number = 1)
    return scatterplot_axis('x', number)
242 243 244
  end

  # Return the element corresponding to the legend of the x axis of the scatterplot
245 246
  def scatterplot_x_legend(index, number = 1)
    return scatterplot_legend('x', index, number)
247 248
  end

249
  # Return the x axis label of the scatterplot
250 251
  def scatterplot_x_label(number = 1)
    return scatterplot_labels(number)[0]
252 253
  end

254
  # Return the element corresponding to the x axis of the scatterplot
255 256
  def scatterplot_y(number)
    return scatterplot_axis('y', number)
257 258 259
  end

  # Return the element corresponding to the legend of the y axis of the scatterplot
260 261
  def scatterplot_y_legend(index, number = 1)
    return scatterplot_legend('y', index, number)
262 263
  end

264
  # Return the y axis label of the scatterplot
265 266
  def scatterplot_y_label(number)
    return scatterplot_labels(number)[1]
267 268
  end

269 270 271 272 273 274 275 276 277 278 279 280
  def segmenter_checkbox_aa
    return element(:id => 'segmenter_aa')
  end

  def segmenter_checkbox_imgt_cdr3
    return element(:id => 'imgt_cdr3_input_check')
  end

  def segmenter_checkbox_imgt_vdj
    return element(:id => 'imgt_vdj_input_check')
  end

281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
  # Return the span containing elements of the sequence in the scatterplot
  def sequence(id)
    return element(:id => 'm'+id)
  end

  # Return the V sequence of the clone id
  def sequence_V(id)
    return sequence(id).element(:class => 'V')
  end

  # Return the N1 sequence of the clone id
  def sequence_N1(id)
    return sequence(id).element(:class => 'N', :index => 0)
  end

  # Return the N2 sequence of the clone id
  def sequence_N2(id)
    return sequence(id).element(:class => 'N', :index => 1)
  end

  # Return the D sequence of the clone id
  def sequence_D(id)
    return sequence(id).element(:class => 'D')
  end

  # Return the J sequence of the clone id
  def sequence_J(id)
    return sequence(id).element(:class => 'J')
  end

  # Return the div containing stats information on selected clone(s)
  def statsline
313
    div(:id => segmenter_id).div(:class => 'stats')
314 315
  end

316 317
  # Return an item from a tag selector (the menu to select the tag
  # for a clone) split in a hash.
318 319 320 321 322 323 324 325
  # The hash contains the following keys:
  def tag_item(id)
    ts = tag_selector
    return {color: ts.span(:class => 'tagColor'+id),
            name: ts.span(:class => 'tagName'+id),
            edit: ts.li(:index => id.to_i).span(:class => 'edit_button')}
  end
  
326 327
  # Return the select containing the preset selector in the graph
  def preset_selector
328
    return scatterplot.select_list(:class => 'axis_select_preset_select')
329 330
  end

331 332
  # Return the div containing the tag selector
  def tag_selector
Marc Duez's avatar
Marc Duez committed
333
    return div(:class => 'tagSelector')
334 335 336 337 338 339 340 341 342 343 344 345 346 347
  end

  # Return the close button for tag selector
  def tag_selector_close
    return tag_selector.span(:class => 'closeButton')
  end

  # Return the field for editing tag name in the tag selector
  def tag_selector_edit_name
    return tag_selector.text_field(:id => 'new_tag_name')
  end

  # Return the field for editing tag name in the tag selector
  def tag_selector_edit_normalisation
348
    return tag_selector.text_field(:id => 'norm_button')
349 350 351 352 353 354 355 356 357 358 359 360
  end

  # Return the button that validates the changes in the tag selector
  def tag_selector_name_validator
    return tag_selector.a(:id => 'btnSaveTag')
  end

  # Return the button that validates the changes in the tag selector
  def tag_selector_normalisation_validator
    return tag_selector.button(:text => 'ok')
  end

361
  # Unselect everything, both on clones, and move away from menus (as if we click on the back)
362
  def unselect
363
    $b.execute_script('m.unselectAll()')
364
    $b.execute_script('showSelector("x")')
365 366 367 368 369 370 371
  end
  
  # Return the div of the list of clones
  def list
    return div(:id => 'list_clones')
  end
  
372 373 374 375 376 377
  def until(extra = {})
    default = {timeout: 3}
    default.merge(extra)
    Watir::Wait.until(default) { yield }
  end

378 379
  protected

380 381 382 383 384
  def scatterplot_id(number=1)
    if number <= 1
      return 'visu'
    end
    return 'visu' + number.to_s
385 386 387 388 389 390
  end

  def segmenter_id
    return 'bot-container'
  end

391 392
  def scatterplot_axis(axis, number = 1)
    return element(:id => scatterplot_id(number)+'_axis_'+axis+'_container')
393 394
  end

395 396
  def scatterplot_labels(number = 1)
    return element(:id => scatterplot_id(number)+'_axis_container').elements(:class => 'sp_legend2')
397 398
  end

399 400
  def scatterplot_legend(axis, index, number=1)
    return scatterplot_axis(axis, number).element(:class => 'sp_legend', :index => index)
401 402 403 404
  end


end