class LdsVue360

Public Class Methods

new(browser, idNode) click to toggle source

constructor

# File lib/TNR360/components/lds_vue360.rb, line 19
def initialize(browser, idNode)
  @browser =browser
  @idNode=idNode
  update
  @exists
end

Public Instance Methods

click() click to toggle source

LdsScreen Actions

# File lib/TNR360/components/lds_vue360.rb, line 146
 def click
   success=false
if(@current_element.present? && @current_element.visible?)
  @current_element.click
  sleep($small_wait_time)
  #wait for screen to become visible
  proc=Proc.new { @current_element.visible? }
  success=@exists=force_find_element(proc)

else
  if(@parentRootTab!=nil && @parentRootTab.present?)
    @parentRootTab.click
    #wait for screen to become visible
    proc=Proc.new { @current_element.visible? }
    success=@exists=force_find_element(proc)
    @current_element.click
    success=@current_element.visible?
  end
end
   success
 end
closeRootTab() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 184
  def closeRootTab
  @current_element.a(:class => 'x-tab-strip-close').click
  if(!@isRootTab)
    @parentRootTab.a(:class => 'x-tab-strip-close').click
  end
  done=false
  #make sure screen closed : Trigger Action => any action on it throws a not found error
  begin
    update
  rescue
    done=true
  ensure
    done
  end
end
closeTab() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 168
def closeTab
  @current_element.a(:class => 'x-tab-strip-close').click
  if(!@isRootTab)
    @parentRootTab.a(:class => 'x-tab-strip-close').click
  end
  done=false
  #make sure screen closed : Trigger Action => any action on it throws a not found error
  begin
    update
  rescue
    done=true
  ensure
    done
  end
end
getElement() click to toggle source

Getters

# File lib/TNR360/components/lds_vue360.rb, line 201
def getElement
  @current_element
end
getIdScreen() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 205
def getIdScreen
  @idScreen
end
getRootTitle() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 213
def getRootTitle
  @rootTitle
end
getTitle() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 209
def getTitle
  @title
end
getType() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 216
def getType
  @type
end
isExist?() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 224
def isExist?
  @exists
end
isVisible?() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 220
def isVisible?
  @visible
end
refresh() click to toggle source

refresh object status from browser

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

print object

# File lib/TNR360/components/lds_vue360.rb, line 131
def to_s
  "\n***** Screen *****"+
      "\nIdScreen : "+ no_null(@idScreen) +
      "\nTitle : "+ no_null(@title)+
      "\nVisible : "+ bool_no_null(@visible.to_s)+
      "\nExists : "+ bool_no_null(@exists.to_s)+
      "\nType :"+ no_null(@type.to_s)+
      "\nIsRootTab : "+ bool_no_null(@isRootTab.to_s)+
      "\nRootTitle : "+ ((no_null(@rootTitle.to_s)=='')?(@title.to_s):(@rootTitle.to_s))+
      "\nType :"+ no_null(@type.to_s)+
       "\n**********"
end

Private Instance Methods

elementExists?(idElement) click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 116
def elementExists?(idElement)
  #this method assumes the screen/tab is already loaded
  oneIsThere=false
  #if element not yet available in screen, wait for some time
  if (!@browser.li(:xpath => "//li[contains(@id,'"+idElement+"')]").exists?)
    @browser.li(:xpath => "//li[contains(@id,'"+idElement+"')]").when_present($wait_time.to_i)
    oneIsThere=true
  else
    oneIsThere=true
  end
  oneIsThere
end
extractSubTabs(idElement) click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 68
def extractSubTabs idElement
  if (!@isRootTab)
    ind=0

    #find parent of current element that holds all frame contents of the tab
    element, previousElement = findParentWithClass "x-tab-panel-body x-tab-panel-body-top",@current_element

    #find the correct order of this frame, in order to identify the order of the tab
    element.divs(:xpath =>'*').each do |adiv|
     if(adiv.class_name==previousElement.class_name)
       break;
      end
     ind=ind+1
    end

    #now that we have the order, navigate through root tabs, and find the one with the same order ind
    @browser.divs(:xpath =>'//div[contains(@class,"x-tab-panel-header")]').each do |divr|
      if(!(divr.li.id.start_with? 'GLOBALMENU') && !(divr.li.id.start_with? 'functionTab'))
        @parentRootTab=divr.li(:index => ind)
        break
      end
    end

    #get the title of that root tab
    @rootTitle=@parentRootTab.text
  end
end
extractTitle() click to toggle source
# File lib/TNR360/components/lds_vue360.rb, line 64
def extractTitle
  @title=@current_element.text
end
extractType() click to toggle source

internal methods

# File lib/TNR360/components/lds_vue360.rb, line 59
def extractType

end
findElement(idElement) click to toggle source

method locate current element

# File lib/TNR360/components/lds_vue360.rb, line 100
def findElement idElement
  @isRootTab=true
  @parentRootTab=nil
  @rootTitle=nil
  #wait for screen to become visible (find screen forcefully)
  proc=Proc.new { elementExists?(idElement) }
  found=@exists=force_find_element(proc)

  #show proof
  puts 'Tab Element ' +idElement+' found = '+@exists.to_s

  @current_element=@browser.li(:xpath => "//li[contains(@id,'"+idElement+"')]").when_present($wait_time.to_i)
  @current_element
end
update() click to toggle source

private method to update/save the status of the object

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

  #Look for element in browser
  @current_element||= findElement @idScreen
  #fill @title
  extractTitle
  #fill visible
  @visible=@current_element.visible?

  #deal with subtabs
  @isRootTab=!@current_element.id.to_s.include?('functionTab')
  extractSubTabs @idScreen

  #fill type
  extractType
  #everything exists
  @exists=true
end