Module: MercurySelectorsHelpers

Defined in:
lib/mercury/cucumber/support/mercury_selectors.rb

Instance Method Summary collapse

Instance Method Details

#mercury_button_mapping_for(locator) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/mercury/cucumber/support/mercury_selectors.rb', line 69

def mercury_button_mapping_for(locator)
  case locator.downcase

    # primary toolbar
    when 'save' then 'save'
    when 'preview' then 'preview'
    when 'undo' then 'undo'
    when 'redo' then 'redo'
    when 'link', 'insert link' then 'insertLink'
    when 'media', 'insert media' then 'insertMedia'
    when 'table', 'insert table' then 'insertTable'
    when 'character', 'insert character' then 'insertCharacter'
    when 'snippet', 'insert snippet' then 'snippetPanel'
    when 'history', 'view history' then 'historyPanel'
    when 'notes', 'view notes' then 'notesPanel'

    # editor toolbar
    when 'predefined styles' then 'style'
    when 'block format' then 'formatblock'
    when 'backcolor', 'background color' then 'backColor'
    when 'forecolor', 'foreground color' then 'foreColor'
    when 'italicize' then 'italic'
    when 'overline' then 'overline'
    when 'strike through' then 'strikethrough'
    when 'underline' then 'underline'
    when 'subscript' then 'subscript'
    when 'superscript' then 'superscript'
    when 'justify left', 'left justify' then 'justifyLeft'
    when 'justify center', 'center justify' then 'justifyCenter'
    when 'justify right', 'right justify' then 'justifyRight'
    when 'justify full', 'full justification' then 'justifyFull'
    when 'unordered list', 'insert unordered list' then 'insertUnorderedList'
    when 'ordered list', 'insert ordered list' then 'insertOrderedList'
    when 'hr', 'insert hr', 'horizontal rule', 'insert horizontal rule' then 'horizontalRule'
    when 'clean formatting', 'remove formatting' then 'removeFormatting'
    when 'html editor' then 'htmlEditor'

    # table context buttons
    when 'add row before', 'insert row before' then 'insertRowBefore'
    when 'add row after', 'insert row after' then 'insertRowAfter'
    when 'delete row' then 'deleteRow'
    when 'add column before', 'insert column before' then 'insertColumnBefore'
    when 'add column after', 'insert column after' then 'insertColumnAfter'
    when 'delete column' then 'deleteColumn'
    when 'increase colspan' then 'increaseColspan'
    when 'decrease colspan' then 'decreaseColspan'
    when 'increase rowspan' then 'increaseRowspan'
    when 'decrease rowspan' then 'decreaseRowspan'

    # snippet toolbar
    when 'edit snippet settings', 'edit snippet' then 'editSnippet'
    when 'remove snippet' then 'removeSnippet'

    else locator
  end
end

#mercury_selector_for(locator) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/mercury/cucumber/support/mercury_selectors.rb', line 3

def mercury_selector_for(locator)
  case locator

    # toolbar selectors
    when 'the toolbar' then '.mercury-toolbar-container'

    when /^the "(.*?)" button$/
      ".mercury-primary-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"

    when /^the (.*?) editor (button|dropdown|palette)$/
      ".mercury-editable-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"

    when /^the (.*?) toolbar button$/
      ".mercury-snippet-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"

    when /^the (.*?) select$/
      ".mercury-#{mercury_button_mapping_for($1)}-select"

    when /^the (.*?) palette$/
      ".mercury-#{mercury_button_mapping_for($1)}-palette"

    # palette / select dropdown
    when 'the color red' then '.mercury-palette .picker:nth-child(22n)'

    when 'the red style' then '.mercury-select-options .red'
    when 'the heading 2 block' then '.mercury-select-options h2'

    # statusbar selectors
    when 'the statusbar' then '.mercury-statusbar'
    when 'the about the editor link' then 'a.mercury-statusbar-about'

    # panel selectors
    when 'the panel', /^the (.*?) panel$/ then '.mercury-panel'

    # modal window selectors
    when 'the modal', 'the modal window', /^the (.*?) modal$/ then '.mercury-modal'
    when 'the modal overlay' then '.mercury-modal-overlay'
    when 'the modal title' then '.mercury-modal h1.mercury-modal-title'
    when 'the modal close button' then '.mercury-modal h1.mercury-modal-title a'

    when 'the sweet snowman' then '.mercury-modal .character:nth-child(247n)'

    when 'the first cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(1n)'
    when 'the third cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(3n)'
    when 'the forth cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(4n)'
    when 'the second cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(2n)'
    when 'the forth cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(4n)'

    when 'a selected cell' then '.mercury-modal td.selected'

    # lightview selectors
    when 'the lightview', 'the lightview window', /^the (.*?) lightview$/ then '.mercury-lightview'
    when 'the lightview overlay' then '.mercury-lightview-overlay'
    when 'the lightview title' then '.mercury-lightview h1.mercury-lightview-title'
    when 'the lightview close button' then '.mercury-lightview h1.mercury-lightview-title a'

    # snippet selectors
    when 'the snippet toolbar' then '.mercury-snippet-toolbar'
    when 'the snippet', 'that snippet' then "div[data-snippet=#{@snippet_id || 'snippet_42'}]"

    # other selectors
    when 'the first image' then 'img:nth-child(1n)'

  end
end