class Object

Public Instance Methods

bool_no_null(obj) click to toggle source

method to replace nil with false string

# File lib/TNR360/TnrUtilsGeneric.rb, line 14
def bool_no_null obj
  ((obj==nil) ? 'false' : obj)
end
browser(version) click to toggle source
# File lib/TNR360/TnrUtils.rb, line 8
def browser(version)
  # :chrome, :ie, or :ff
  @browser ||= Watir::Browser.new(version)
  @browser.driver.manage.timeouts.implicit_wait=3
  @browser
end
click() click to toggle source
# File lib/TNR360/TnrUtilsInes.rb, line 44
def click
  #@@browser.
  #$browser.div(:class => "fwk-result-contractIe").when_present.double_click
  @browser.button(:text => "Search").when_present.click
end
custom_double_click(brwser,elmnt) click to toggle source
# File lib/TNR360/TnrUtilsGeneric.rb, line 18
def custom_double_click brwser,elmnt
  if (brwser.driver.browser.to_s =='firefox')
    elmnt.when_present.fire_event("ondblclick")
  else
    elmnt.when_present.double_click
  end
end
doubleClick() click to toggle source
# File lib/TNR360/TnrUtilsInes.rb, line 39
def doubleClick
  #@@browser.
  @browser.div(:class => "fwk-result-managementCompany").when_present.double_click
end
findParentWithClass(parent_class_name,current_element) click to toggle source

find a parent class with a class containing expression

# File lib/TNR360/TnrUtilsGeneric.rb, line 27
def findParentWithClass parent_class_name,current_element
  found=false
  element=nil
  previousElement=nil
  while (!found)
    if (element==nil)
      tempElement= element=previousElement=current_element.parent
    else
      previousElement=element
      tempElement=element.parent
    end

    if (tempElement.class_name.include? parent_class_name)
      found=true
    end
    element=tempElement
  end
  return element, previousElement
end
findParentWithId(parent_idElement,current_element) click to toggle source

find a parent class with a id containing expression

# File lib/TNR360/TnrUtilsGeneric.rb, line 49
def findParentWithId parent_idElement,current_element
  found=false
  element=nil
  previousElement=nil
  while (!found)
    if (element==nil)
      tempElement= element=previousElement=current_element.parent
    else
      previousElement=element
      tempElement=element.parent
    end

    if (tempElement.id.include? parent_idElement)
      found=true
    end
    element=tempElement
  end
  return element, previousElement
end
force_find_element(block) click to toggle source
# File lib/TNR360/TnrUtilsGeneric.rb, line 69
def force_find_element  block
  found_element=false
  retries_left = 3
  begin
    found_element= block.call
  rescue Timeout::Error
    puts("Caught a TIMEOUT ERROR!")

    # You may want to wait for a while before retrying.
    sleep(3)

    # Retry the code that generates the exception.
    retries_left -= 1
    retry if retries_left > 0

    # No more retries left - time to bail out! Re-raise the exception.
    raise
  end
  found_element
end
goToAssetSearch() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 31
def goToAssetSearch
  @browser.button(:text , "Asset search".split('/').take(1).first).when_present.click
  @browser.button(:value,"Search").when_present.click#
end
goToContractElementsExpiringSearch() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 46
def goToContractElementsExpiringSearch
  @browser.a(:text => "Parties and Contracts").when_present(60).click
  @browser.button(:value,"Contract elements expiring search").when_present.click
end
goToContractPopulation() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 51
def goToContractPopulation
  @browser.a(:text => "Fleet management").when_present(60).click
  @browser.button(:value,"Contract population search").when_present.click
  @browser.button(:value, "Search").when_present.click#
end
goToDas2Closure() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 25
def goToDas2Closure
  @browser.a(:text => "Interfaces").when_present(60).click
  @browser.button(:value,"DAS2").when_present.click
  @browser.link(:text, "New DAS2 closure").when_present.click
end
goToInvoiceSearch() click to toggle source
# File lib/TNR360/TnrUtilsInes.rb, line 32
def goToInvoiceSearch

  @browser.a(:text => "Main").when_present(60).click#TODO:groupe menu /root title
  @browser.link(:value,"Invoice search").when_present.click#TODO:liste menu

end
goToPartyContractSearch() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 36
def goToPartyContractSearch
  @browser.button(:text , "Party contract search".split('/').take(1).first).when_present.click
  @browser.button(:value, "Search").when_present.click#
end
goToPaymentSearch() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 41
def goToPaymentSearch
  @browser.button(:text , "Payment search".split('/').take(1).first).when_present.click
  @browser.button(:value, "Search").when_present.click#
end
goToWeeksAndMonthsConfiguration() click to toggle source
# File lib/TNR360/TnrUtils.rb, line 57
def goToWeeksAndMonthsConfiguration
  @browser.a(:text => "Setup").when_present(60).click
  @browser.table(:id,"x-auto-165").button(:class,"x-btn-text").click
  @browser.link(:text, "Configuration of week's days and year's months").when_present.click
end
login(url,username, password) click to toggle source
# File lib/TNR360/TnrUtils.rb, line 14
def login(url,username, password)


  @browser.goto url
  @browser.driver.manage.window.maximize

  @browser.text_field(:name => "j_username").when_present.set(username)
  @browser.text_field(:name => "j_password").when_present.set(password )
  @browser.button(:value, "Connection").when_present.click
end
no_null(obj) click to toggle source

method to replace nil with an empty string

# File lib/TNR360/TnrUtilsGeneric.rb, line 9
def no_null obj
  ((obj==nil) ? '' : obj)
end