class LdsArea

Public Class Methods

new(browser, idArea, block=nil) click to toggle source

constructor

# File lib/TNR360/components/lds_area.rb, line 17
def initialize(browser, idArea, block=nil)
  @browser =browser
  @idArea=idArea
  @parentBlock=block
  update
  @exists
end

Public Instance Methods

collapse() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 117
def collapse
  if (@collapsible && !@collapsed)
    @current_element.legend(:index => 0).div(:index => 0).when_present.click
  end
  update
end
expand() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 124
def expand
  if (@collapsible && @collapsed)
    @current_element.legend(:index => 0).div(:index => 0).when_present.click
  end
  update
end
findElement(idElement) click to toggle source

method locate current element

# File lib/TNR360/components/lds_area.rb, line 64
def findElement idElement
  begin
    #if element not yet available in screen, wait for some time
    if @parentBlock != nil
      @parentBlock.getElement.div(:index => 2).fieldset(:id, idElement).wait_until_present(10)
      @current_element=@parentBlock.getElement.div(:index => 2).fieldset(:id, idElement)
    end
  rescue

    raise "Element "+idElement+" Not Found"

  ensure
    #rien dans finally pour ce cas
    if @parentBlock == nil
      if @browser.fieldset(:id, idElement).wait_until_present(10)
        count=@browser.fieldsets(:id, idElement).length
      end
      if count==0
        raise "Element "+idElement+" Not Found"
      else
        if count >1
          raise "Several Elements with id "+idElement+"  Found, specify block"
        end
      end
      @current_element=@browser.fieldset(:id, idElement).when_present
    end
  end
  @current_element
end
getElement() click to toggle source

Getters

# File lib/TNR360/components/lds_area.rb, line 133
def getElement
  @current_element
end
getIdArea() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 137
def getIdArea
  @idArea
end
getParentBloc() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 141
def getParentBloc
  @parentBlock
end
getTitle() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 145
def getTitle
  @title
end
isCollapsed?() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 153
def isCollapsed?
  @collapsed
end
isCollapsible?() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 149
def isCollapsible?
  @collapsible
end
isExist?() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 161
def isExist?
  @exists
end
isVisible?() click to toggle source
# File lib/TNR360/components/lds_area.rb, line 157
def isVisible?
  @visible
end
refresh() click to toggle source

refresh object status from browser

# File lib/TNR360/components/lds_area.rb, line 27
def refresh
  #Look for element in browser
  @current_element= findElement @idArea
  #update other data
  update
  @exists
end
reverse_collapse() click to toggle source

LdsScreen Actions

# File lib/TNR360/components/lds_area.rb, line 110
def reverse_collapse
  if (@collapsible)
    @current_element.legend(:index => 0).div(:index => 0).when_present.click
  end
  update
end
to_s() click to toggle source

print object

# File lib/TNR360/components/lds_area.rb, line 96
def to_s
  "\n***** Area *****"+
      "\nIdArea : "+ no_null(@idArea)+
      "\nIdParentBlock : "+(no_null(@parentBlock)=="" ? "" : @parentBlock.getIdBlock)+
      "\nTitle : "+ no_null(@title)+
      "\nCollapsible :"+ bool_no_null(@collapsible.to_s)+
      "\nCollapsed :"+ bool_no_null(@collapsed.to_s)+
      "\nVisible : "+ bool_no_null(@visible.to_s)+
      "\nExists : "+ bool_no_null(@exists.to_s)+
      "\n**********"
end

Private Instance Methods

update() click to toggle source

private method to update/save the status of the object

# File lib/TNR360/components/lds_area.rb, line 36
def update
  @exists=false

  #Look for element in browser
  @current_element||= findElement @idArea

  #fill @title
  @title=@current_element.legend(:index => 0).span(:index => 0).text
  #fill visible
  @visible=@current_element.visible?
  #fill isCollapsible
  if @current_element.legend(:index => 0).divs.length>0
    @collapsible=true
  else
    @collapsible=false
  end
  #fill isCollapsed
  if @collapsible
    @collapsed=@current_element.class_name.include? "collapsed"
  else
    @collapsed=false
  end

  #everything exists
  @exists=true
end