Class: LdsColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/TNR360/components/lds_column.rb

Instance Method Summary collapse

Constructor Details

#initialize(browser, idColumn, block, orderInVisible = nil) ⇒ LdsColumn

constructor



14
15
16
17
18
19
20
21
# File 'lib/TNR360/components/lds_column.rb', line 14

def initialize(browser, idColumn, block, orderInVisible=nil)
  @browser =browser
  @parentBlock=block
  @idColumn=idColumn
  @orderInVisible=orderInVisible
  update
  @exists
end

Instance Method Details

#changeVisibility(columnLabel, elementTobeDisplayedLabel) ⇒ Object



109
110
111
112
113
114
# File 'lib/TNR360/components/lds_column.rb', line 109

def changeVisibility columnLabel ,elementTobeDisplayedLabel
  @current_element.hover
  @current_element.a(:index=>0).when_present.click
  @browser.a(:id, columnLabel+"change-column-visibility").hover
  @browser.div(:id,"Payment-change-visibility-menu").div(:class,"x-menu-list").a(:id,columnLabel+"-change-visibility-"+elementTobeDisplayedLabel).click
end

#displayColumns(columnLabel) ⇒ Object



115
116
117
118
119
# File 'lib/TNR360/components/lds_column.rb', line 115

def displayColumns columnLabel
  @current_element.hover
  @current_element.a(:index=>0).when_present.click
  @browser.a(:id, columnLabel+"change-column-visibility").hover
end

#findElement(idElement) ⇒ Object

method locate current element



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/TNR360/components/lds_column.rb', line 51

def findElement idElement
  begin
    #if element not yet available in screen, wait for some time
    if @parentBlock != nil
      @parentBlock.getElement.div(:class,"std-fieldset-bwrap").tr(:index => 0).td(:xpath => "//td[contains(@class,'"+idElement+"')]").wait_until_present(10)
      @current_element=@parentBlock.getElement.div(:class,"std-fieldset-bwrap").tr(:index => 0).td(:xpath => "//td[contains(@class,'"+idElement+"')]")
      #@[email protected](:index => 2).tr(:index=>0).td(:class => "x-grid3-header x-grid3-hd x-grid3-cell x-grid3-td-"+idElement)
    end
  rescue

    raise "Column "+idElement+" Not Found"

  ensure
    #rien dans finally pour ce cas
    if @parentBlock == nil
      if @browser.td(:xpath => "//td[contains(@class,'"+idElement+"')]").wait_until_present(10)
        count=@browser.tds(:xpath => "//td[contains(@class,'"+idElement+"')]").length
      end
      if count==0
        raise "Column "+idElement+" Not Found"
      else
        if count >1
          raise "Several Elements with id "+idElement+"  Found, specify block"
        end
      end
      @current_element=@browser.td(:xpath => "//td[contains(@class,'"+idElement+"')]").when_present
    end
  end
  @current_element
end

#getClassColumnObject



130
131
132
# File 'lib/TNR360/components/lds_column.rb', line 130

def getClassColumn
  @idColumn
end

#getElementObject

Getters



122
123
124
# File 'lib/TNR360/components/lds_column.rb', line 122

def getElement
  @current_element
end

#getIdBlockObject



126
127
128
# File 'lib/TNR360/components/lds_column.rb', line 126

def getIdBlock
  @idBlock
end

#getLabelObject



134
135
136
# File 'lib/TNR360/components/lds_column.rb', line 134

def getLabel
  @label
end

#isExist?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/TNR360/components/lds_column.rb', line 143

def isExist?
  @exists
end

#isVisible?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/TNR360/components/lds_column.rb', line 138

def isVisible?
  @isVisible
end

#refreshObject

refresh object status from browser



25
26
27
28
29
30
31
# File 'lib/TNR360/components/lds_column.rb', line 25

def refresh
  #Look for element in browser
  @current_element= findElement @idColumn
  #update other data
  update
  @exists
end

#sortAscending(label) ⇒ Object



97
98
99
100
101
# File 'lib/TNR360/components/lds_column.rb', line 97

def sortAscending label
  @current_element.hover
  @current_element.a(:index=>0).when_present.click
  @browser.a(:id, label+"sort-asc-text").when_present.click
end

#sortDescending(label) ⇒ Object



103
104
105
106
107
# File 'lib/TNR360/components/lds_column.rb', line 103

def sortDescending label
  @current_element.hover
  @current_element.a(:index=>0).when_present.click
  @browser.a(:id, label+"sort-desc-text").when_present.click
end

#to_sObject

print object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/TNR360/components/lds_column.rb', line 83

def to_s

  "\n***** Column *****"+
      "\nIdParentBlock : "+(no_null(@parentBlock)=="" ? "" : @parentBlock.getIdBlock)+
      "\nIdColumn: "+ no_null(@idColumn)+
      "\nLabel : "+ no_null(@label)+
      "\nIsVisible : "+ bool_no_null(@visible.to_s)+
      "\nOrderInVisible :"+ no_null(@orderInVisible.to_s)+
      "\n**********"


end