class Object

Public Instance Methods

call_step(str_step) click to toggle source

Call another step

# File lib/anhpham/methods/core.rb, line 9
def call_step str_step
  put_log "\n-=> call step: #{str_step}"
  step %{#{str_step}}
end
check_alert_text(text) click to toggle source

method to check javascript pop-up alert text

# File lib/anhpham/methods/javascript_handling_methods.rb, line 42
def check_alert_text(text)
  if get_alert_text != text
    raise TestCaseFailed,  "Text on alert pop up not matched, Actual Text : #{get_alert_text}, Expected Text : #{text}"
  end
end
check_element_enable(element, test_case) click to toggle source

Element enabled checking param 1 : String : Expected element text param 2 : Boolean : test case [true or flase]

# File lib/anhpham/methods/web_methods.rb, line 220
def check_element_enable(element, test_case)
  result = is_element_enabled(element)

  if test_case
    raise TestCaseFailed, 'Element Not Enabled' unless result
  else
    raise TestCaseFailed, 'Element Enabled' unless !result
  end
end
check_partial_title(partial_text_title, test_case) click to toggle source

Method to verify partial title param 1 : String : partial title string param 2 : Boolean : test case [true or flase]

# File lib/anhpham/methods/web_methods.rb, line 30
def check_partial_title(partial_text_title, test_case)
  page_title = get_page_title
  if test_case
    if not page_title.include? "#{partial_text_title}"
      raise TestCaseFailed, 'Partial Page Title Not Present'
    end
  else
    if page_title.include? "#{partial_text_title}"
      raise TestCaseFailed, 'Page Title Matched'
    end
  end
end
check_title(title, test_case) click to toggle source

Method to verify title param 1 : String : expected title param 2 : Boolean : test case [true or flase]

# File lib/anhpham/methods/web_methods.rb, line 14
def check_title(title, test_case)
  page_title = get_page_title
  if test_case
    if page_title != "#{title}"
      raise TestCaseFailed, "Page Title Not Matched, Actual Page Title : #{page_title}, Expected Page Title : #{title}"
    end
  else
    if page_title == "#{title}"
      raise TestCaseFailed, "Page Title Matched, Actual Page Title: #{page_title}"
    end
  end
end
close_windows() click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 19
def close_windows
  page.driver.browser.close
  page.driver.browser.switch_to.window(page.driver.browser.window_handles[0])
end
double_click(element) click to toggle source
# File lib/anhpham/methods/web_methods.rb, line 259
def double_click(element)
  foundElement = find_object(element)
  page.driver.browser.mouse.double_click(foundElement.native)
end
execute_checkexists(negate, element, timeout) click to toggle source

Check exists

# File lib/anhpham/methods/web_methods.rb, line 156
def execute_checkexists negate, element, timeout
  origin_timeout = $_CFWEB['Wait Time']
  set_time_out(timeout)
  foundElement = find_object(element)
  set_time_out(origin_timeout)
  #put_log "\nexecute_checkexists : #{foundElement}"
  check = false
  if foundElement != nil
    check = true
  end

  negate = negate.strip if negate != nil
  #puts "---------->#{negate}"
  if negate == "not"
    # check.should_not eq true
    expect(check).not_to eql true
  elsif check.should eq true
    expect(check).to eq true
  end
end
execute_checkproperty(element, property, negate, value, isSpecialChar=false) click to toggle source

Check object property

# File lib/anhpham/methods/core.rb, line 196
def execute_checkproperty element, property, negate, value, isSpecialChar=false
  Capybara.configure do |config|
    config.ignore_hidden_elements = false
  end
  foundElement = find_object(element)

  check = false
  if foundElement == nil and value == ""
    check = true
    # check.should eq true
    expect(check).to eq true
  else
    put_log "\n\n\t>>> execute_checkproperty: finish to found element"
    if foundElement != nil
      if property.upcase == 'VALUE'
        actual_value = foundElement.value()

      elsif property.upcase == 'TEXT'
        actual_value = foundElement.text()

      elsif property.upcase == 'SPECIAL CHAR'
        actual_value = foundElement.text()
        isSpecialChar = true

      elsif property.upcase == 'TAGNAME'
        actual_value = foundElement.tag_name()

      elsif property.upcase == 'STYLE'
        actual_value = foundElement[:style]

      elsif property.upcase == 'DISABLED'
        actual_value = foundElement[:disabled]

      elsif property.upcase == 'WIDTH'
        actual_value = foundElement[:width]

      elsif property.upcase == 'HEIGHT'
        actual_value = foundElement[:height]

      elsif property.upcase == 'ID'
        actual_value = foundElement[:id]

      elsif property.upcase == 'NAME'
        actual_value = foundElement[:name]

      elsif property.upcase == 'CLASS'
        actual_value = foundElement[:class]

      elsif property.upcase == 'HREF'
        actual_value = foundElement[:href]

      elsif property.upcase == 'TITLE'
        actual_value = foundElement[:title]

      elsif property.upcase == 'TYPE'
        actual_value = foundElement[:type]

      elsif property.upcase == 'CHECKED'
        actual_value = "true" if foundElement.checked? == true
        actual_value = "false" if foundElement.checked? == false
      else
        actual_value = foundElement["#{property}"]
      end

      if actual_value == nil
        actual_value = ''
      end
    else
      put_log "\nError >> Not found object: #{element}"
    end

    Capybara.configure do |config|
      config.ignore_hidden_elements = true
    end

    if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
      check = true
    end

    put_log "\n#{property} :: Actual result is '#{actual_value}' -- Expected result is '#{value}'"

    if negate == " not"
      # check.should_not eq true
      expect(check).not_to eql true
    elsif
      # check.should eq true
    expect(check).to eq true
    end
  end
end
execute_click(element) click to toggle source

Click on element

# File lib/anhpham/methods/web_methods.rb, line 62
def execute_click element
  foundElement = find_object(element)
  if foundElement != nil
    page.driver.execute_script('window.focus();')
    startTime = Time.new.to_i
    begin
      sleep(0.5)
      currentTime = Time.new.to_i
    end while (foundElement.native.enabled? == false and (currentTime - startTime) < $_CFWEB['Wait Time'])
    page.driver.browser.execute_script("arguments[0].scrollIntoView(true);", foundElement.native)
    page.driver.browser.mouse.click(foundElement.native)
  else
    put_log "\nError >> Not found object: #{element}"
  end
end
execute_click_to_upload(object, file_name) click to toggle source
# File lib/anhpham/methods/web_methods.rb, line 142
def execute_click_to_upload object, file_name
  upload_file = ($test_data_dir + file_name).gsub!(/\//, "\\")
  foundElement = find_object(object)
  if foundElement != nil
    call_step("I click on \"#{object}\"")
    window = RAutomation::Window.new(:title => /File Upload/)
    window.text_field(:class => "Edit").set(upload_file)
    window.button(:value => "&Open").click
  else
    raise "Error >> Object #{object} not found.!"
  end
end
execute_drag_to_new_object(from_element, element) click to toggle source
# File lib/anhpham/methods/web_methods.rb, line 124
def execute_drag_to_new_object from_element, element
  found_from_element = find_object(from_element)
  foundElement = find_object(element)
  if foundElement != nil and found_from_element != nil
    found_from_element.drag_to(foundElement)
  end
end
execute_gettext(element) click to toggle source

Get text from web element

# File lib/anhpham/methods/core.rb, line 288
def execute_gettext element
  foundElement = find_object(element)
  if foundElement != nil
    tagname = foundElement.tag_name()

    if tagname.upcase == 'SELECT'
      #@text = page.evaluate_script("$(\"##{foundElement[:id]}\").text()")
    else
      actual_text = foundElement.text()
      if (actual_text == nil or actual_text.length == 0) and (tagname.upcase == 'INPUT' or tagname.upcase == 'TEXTAREA')
        actual_text = foundElement.value()
      end
    end

    put_log "\nText is '" + actual_text + "' of object '" + element + "'"
    $context_value = actual_text
  else
    put_log "\nError >> Not found object: #{element}"
    exit
  end
end
execute_hover_mouse_on(element) click to toggle source
# File lib/anhpham/methods/web_methods.rb, line 132
def execute_hover_mouse_on element
  foundElement = find_object(element)
  if foundElement != nil
    page.driver.browser.mouse.move_to(foundElement.native, element)
    sleep 1
  else
    put_log "\nError >> Not found object: #{element}"
  end
end
execute_mousehoverandclick(element) click to toggle source

Move mouse to element then click

# File lib/anhpham/methods/web_methods.rb, line 113
def execute_mousehoverandclick element
  foundElement = find_object(element)
  if foundElement != nil
    page.driver.browser.mouse.move_to(foundElement.native, element)
    page.driver.browser.mouse.click(foundElement.native)
    sleep(2)
  else
    put_log "\nError >> Not found object: #{element}"
  end
end
execute_openbrowser(url_site) click to toggle source

Open Browser with config-able maximize browser option

# File lib/anhpham/methods/web_methods.rb, line 45
def execute_openbrowser url_site #, redirect
  begin
    if $_CFWEB['Maximize Browser'] == true
      page.driver.browser.manage.window.maximize
    end
  rescue StandardError => myStandardError
    put_log "\n>>> Error: #{myStandardError}"
  end

  if url_site == ""
    visit("")
  else
    visit(url_site)
  end
end
execute_sendkeys(element, text) click to toggle source

Send Key

# File lib/anhpham/methods/web_methods.rb, line 178
def execute_sendkeys element, text
  foundElement = find_object(element)
  if foundElement != nil
    if foundElement[:disabled] == ''
      if text == ":down"
        foundElement.native.send_keys([:down])
      elsif text == ":enter"
        foundElement.native.send_keys([:enter])
      elsif text == ":tab"
        foundElement.native.send_keys([:tab])
      else
        foundElement.native.send_keys(text)
      end
    end
  else
    put_log "\nError >> Not found object: #{element}"
    exit
  end
end
execute_setstate(element, state) click to toggle source

Set option state with state value True/False

# File lib/anhpham/methods/web_methods.rb, line 79
def execute_setstate element, state
  foundElement = find_object(element)
  if foundElement != nil
    if state.upcase == "TRUE"
      foundElement.set(true)
    else
      foundElement.set(false)
    end
  else
    put_log "\nError >> Not found object: #{element}"
    exit
  end
end
execute_settext(element, text) click to toggle source

Enter text to element

# File lib/anhpham/methods/web_methods.rb, line 94
def execute_settext element, text
  foundElement = find_object(element)
  if foundElement != nil
    begin
      foundElement.set(text)
        #page.driver.browser.mouse.click(foundElement.native)
        #foundElement.native.send_keys(text)
        # put_log "\nfoundElement.value: #{foundElement.value}"
        #foundElement.native.send_keys([:tab])
    rescue StandardError => myStandardError
      put_log "\n>>> Error: #{myStandardError}"
    end
  else
    put_log "\nError >> Not found object: #{element}"
    exit
  end
end
find_object(string_object) click to toggle source

Find object by Xpath

# File lib/anhpham/methods/core.rb, line 15
def find_object string_object
  startTime = Time.new.to_i
  string_object = string_object.gsub(/"/, "'")
  # puts "String_object: #{string_object}"
  locator_matching = /(.*?)(\{.*?\})/.match(string_object)
  # puts "locator_matching : #{locator_matching}"
  dyn_pros = {}
  if locator_matching != nil
    string_object = locator_matching[1]
    eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
      dyn_pros[k.to_s.upcase] = v
    }
  end

  # put_log "\n---dyn_pros: #{dyn_pros}"
  hash_object = $_RP_OBJECT[string_object]
  if hash_object == nil
    put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
    # true.should eq false
    expect(true).to eq(false)
  end
  upcase_attrb = {}
  if hash_object != nil
    hash_object.each { |k, v|
      k = k.to_s.upcase
      # put_log "\n#{k} =~ /ph_/i and dyn_pros[#{k}]: #{k =~ /ph_/i and dyn_pros[k] != nil}"
      if k =~ /ph_/i
        if dyn_pros[k] != nil
          # Assign place holder value to place holder property, also remove prefix ph_ from property key,
          # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation
          if v =~ /<ph_value>/i
            upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
          else
            upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
          end

          dyn_pros.delete(k)
        end
      else
        upcase_attrb[k.to_s.upcase] = v
      end

    }
  end
  if upcase_attrb.size > 0
    strId = ""
    strClass = ""
    strName = ""
    strTagname = ""
    strXpathSelector = ""
    strText = ""

    index = nil
    upcase_attrb.each { |key, value|
      upcase_key = key.to_s.upcase
      if upcase_key == "XPATH_SELECTOR"
        strXpathSelector = value
      end
    }
    continue_run = true;

    if continue_run == true
      begin
        if strXpathSelector != nil and strXpathSelector.length > 0
          foundElements = get_objects_by_XpathSelector(strXpathSelector)
        else
          #Generate Selector
          strGenerateXpathSel = ""
          strGenerateXpathSel = generate_xpath_selector(strId, strClass, strName, strTagname)
          if strGenerateXpathSel.length > 0
            foundElements = get_objects_by_XpathSelector(strGenerateXpathSel)
          end
        end

        if foundElements == nil or foundElements.length == 0
          currentTime = Time.new.to_i
        else
          # put_log "\nBREAK!!!"
          break
        end
        test = currentTime - startTime
        # put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}"
        sleep(0.5)
      end while (currentTime - startTime) < $_CFWEB['Wait Time']

      if foundElements != nil or foundElements.length != 0
        if index != nil and index.to_i >= 0
          matched_index = 0;
          return_element = nil
          foundElements.each { |cur_element|
            passCheck = find_object_check_object(cur_element, strId, strText)
            if passCheck
              if matched_index == index.to_i
                return_element = cur_element
                break
              else
                matched_index = matched_index + 1
              end
            end
          }
          return return_element
        else
          return_element = nil
          foundElements.each { |cur_element|
            passCheck = find_object_check_object(cur_element, strId, strText)
            if passCheck
              return_element = cur_element
              break
            end
          }
          return return_element
        end # if index != nil and index.to_i >= 0
      end #if foundElements != nil or foundElements.length != 0
    end #if continue = true
  end

  return nil
end
find_object_check_object(cur_element, strId, strText) click to toggle source

Find/Check the object by ID and Text

# File lib/anhpham/methods/core.rb, line 172
def find_object_check_object cur_element, strId, strText
  passCheck = true
  if cur_element != nil

    # Check ID
    if strId != nil and strId.length > 0
      if strId =~ /^#/
        strId = strId[1..-1]
      end
    end

    # Check Text
    if passCheck and strText != nil and strText.length > 0
      if (strText =~ /^#/)
        strText = strText[1..-1]
      end
    end
    return passCheck
  end

  return false
end
generate_xpath_selector(strId, strClass, strName, strTagname) click to toggle source

Generate Xpath Selector

# File lib/anhpham/methods/core.rb, line 135
def generate_xpath_selector(strId, strClass, strName, strTagname)
  strGenerateXpathSel = ""
  if strId != nil and strId.length > 0 and (strId =~ /^#/) == nil
    strGenerateXpathSel = "[@id='#{strId}']"
  end
  if strClass != nil and strClass.length > 0 and (strClass =~ /^#/) == nil
    strGenerateXpathSel = "#{strGenerateXpathSel}[@class='#{strClass}']"
  end
  if strName != nil and strName.length > 0 and (strName =~ /^#/) == nil
    strGenerateXpathSel = "#{strGenerateXpathSel}[@name='#{strName}']"
  end

  if strGenerateXpathSel.length > 0
    if strTagname != nil and strTagname.length > 0
      strGenerateXpathSel = "//#{strTagname}#{strGenerateXpathSel}"
    else
      strGenerateXpathSel = "//*#{strGenerateXpathSel}"
    end
  end

  return strGenerateXpathSel
end
getTestData(testdataid) click to toggle source

Get data from the ‘testdata file’. if not valid, then testdataid is passed back

# File lib/anhpham/methods/core.rb, line 333
def getTestData(testdataid)
  begin
    sTestDataidArr = testdataid.downcase.split('.')
    testdata = $testdata[sTestDataidArr.first][sTestDataidArr.last]
    puts (testdata)
    return testdata
  rescue Exception
    return testdataid
  end
end
get_alert_text() click to toggle source

method to get javascript pop-up alert text

# File lib/anhpham/methods/javascript_handling_methods.rb, line 37
def get_alert_text
  page.driver.browser.switch_to.alert.text
end
get_browser_back() click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 24
def get_browser_back
  page.evaluate_script('window.history.back()')
end
get_element_attribute(access_type, access_name, attribute_name) click to toggle source

method to get attribute value param 1 : String : Locator type (id, name, class, xpath, css) param 2 : String : Expected element text param 3 : String : atrribute name

# File lib/anhpham/methods/core.rb, line 328
def get_element_attribute(access_type, access_name, attribute_name)
  $driver.find_element(:"#{access_type}" => "#{access_name}").attribute("#{attribute_name}")
end
get_objects_by_XpathSelector(strXpathSelector) click to toggle source

Get object by XpathSelector

# File lib/anhpham/methods/core.rb, line 159
def get_objects_by_XpathSelector(strXpathSelector)
  # put_log "\nstrXpathSelector: #{strXpathSelector}"
  foundElements = nil
  begin
    foundElements = page.all(:xpath, strXpathSelector)
  rescue StandardError => myStandardError
    put_log "\n>>> Error: #{myStandardError}"
  end

  return foundElements
end
get_page_title() click to toggle source

Method to return page title

# File lib/anhpham/methods/web_methods.rb, line 7
def get_page_title
  page.title
end
handle_alert(decision) click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 3
def handle_alert(decision)
  if decision == 'accept'
    page.driver.browser.switch_to.alert.accept
  else
        page.driver.browser.switch_to.alert.dismiss
  end
end
is_checkbox_checked(element, should_be_checked = true) click to toggle source

method to assert checkbox check/uncheck param 1 : String : Locator value param 2 : Boolean : test case [true or flase]

# File lib/anhpham/methods/web_methods.rb, line 234
def is_checkbox_checked(element, should_be_checked = true)
  foundElement = find_object(element)
  checkbox = expect(foundElement).to be_checked

  if !checkbox && should_be_checked
    raise TestCaseFailed, 'Checkbox is not checked'
  elsif checkbox && !should_be_checked
    raise TestCaseFailed, 'Checkbox is checked'
  end
end
is_element_enabled(element) click to toggle source

Method to return element status - enabled? param 1 : String : Locator type (id, name, class, xpath, css) param 2 : String : Locator value

# File lib/anhpham/methods/web_methods.rb, line 212
def is_element_enabled(element)
  foundElement = find_object(element)
  expect(foundElement).to be_visible
end
is_radio_button_selected(element, should_be_selected = true) click to toggle source

method to assert radio button selected/unselected param 1 : String : Locator value param 2 : Boolean : test case [true or flase]

# File lib/anhpham/methods/web_methods.rb, line 248
def is_radio_button_selected(element, should_be_selected = true)
  foundElement = find_object(element)
  radio = expect(foundElement).to be_checked

  if !radio && should_be_selected
    raise TestCaseFailed, 'Radio Button not selected'
  elsif radio && !should_be_selected
    raise TestCaseFailed, 'Radio Button is selected'
  end
end
maximize_browser() click to toggle source

Method to maximize browser

# File lib/anhpham/methods/web_methods.rb, line 265
def maximize_browser
  page.driver.browser.manage.window.maximize
end
open_new_windows_browser() click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 32
def open_new_windows_browser
  page.driver.execute_script("window.open()")
end
print_error_android(browser_type, app_path) click to toggle source

print error for android

print_error_android_app() click to toggle source

print error for android app

print_error_android_web() click to toggle source

print error for android web

print_error_desktop() click to toggle source

print error for desktop

print_error_ios() click to toggle source

print error for ios

print_error_ios_app() click to toggle source

print error for ios app

print_error_ios_web() click to toggle source

print error for ios web

print_invalid_platform() click to toggle source

print error if invalid platform

put_log(str) click to toggle source

Print script log to console

# File lib/anhpham/methods/core.rb, line 4
def put_log str
  puts str if $_CFWEB['Print Log'] == true
end
read_file(filename) click to toggle source
# File lib/anhpham/methods/core.rb, line 310
def read_file(filename)
  data = ''
  f = File.open(filename, "r")
  f.each_line do |line|
    data += line
  end
  return data.strip;
end
refresh_page() click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 28
def refresh_page
  visit page.driver.browser.current_url
end
replace_day(str) click to toggle source
# File lib/anhpham/methods/lib_var.rb, line 37
def replace_day str
  t = Time.now()
  _day = t.day
  if _day < 10
    return str.gsub("{day}", "0#{_day.to_s}")
  else
    return str.gsub("{day}", "#{_day.to_s}")
  end
  return str
end
replace_month(str) click to toggle source
# File lib/anhpham/methods/lib_var.rb, line 26
def replace_month str
  t = Time.now()
  _month = t.month
  if _month < 10
    return str.gsub("{month}", "0#{_month.to_s}")
  else
    return str.gsub("{month}", "#{_month.to_s}")
  end
  return str
end
replace_pipe(str_pipe) click to toggle source
# File lib/anhpham/methods/lib_var.rb, line 48
def replace_pipe str_pipe
  put_log ">>>> #{str_pipe}"
  if str_pipe =~ /^.*{pipe}.*$/
    return str_pipe.gsub("{pipe}", "|")
  end
  return str_pipe
end
replace_year(str) click to toggle source
# File lib/anhpham/methods/lib_var.rb, line 21
def replace_year str
  t = Time.now()
  return str.gsub("{year}", t.year.to_s)
end
resize_browser(width, heigth) click to toggle source

Method to resize browser

# File lib/anhpham/methods/web_methods.rb, line 284
def resize_browser(width, heigth)
  page.driver.browser.manage.window.resize_to(width, heigth)
end
scroll_page(to) click to toggle source

method to scroll page to top or end

# File lib/anhpham/methods/web_methods.rb, line 199
def scroll_page(to)
  if to == 'end'
    page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
  elsif to == 'top'
    page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
  else
    raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
  end
end
set_time_out(timeout) click to toggle source
# File lib/anhpham/methods/core.rb, line 319
def set_time_out(timeout)
  $_CFWEB['Wait Time'] = timeout
  Capybara.default_wait_time = $_CFWEB['Wait Time']
end
switch_to_window_by_title(window_title) click to toggle source

Method to switch to window by title

# File lib/anhpham/methods/web_methods.rb, line 270
def switch_to_window_by_title window_title
  $previous_window = page.driver.browser.window_handle
  window_found = false
  page.driver.browser.window_handles.each{ |handle|
    page.driver.browser.switch_to.window handle
    if page.title == window_title
      window_found = true
      break
    end
  }
  raise "Window having title \"#{window_title}\" not found" if not window_found
end
switch_to_windows(decision) click to toggle source
# File lib/anhpham/methods/javascript_handling_methods.rb, line 11
def switch_to_windows(decision)
  if decision == 'last'
    page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
  else
    page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
  end
end
take_screenshot() click to toggle source
# File lib/anhpham/methods/web_methods.rb, line 288
def take_screenshot
  cur_time = Time.now.strftime('%Y%m%d%H%M%S%L')
  page.driver.browser.save_screenshot($test_data_dir + '/screenshots/screenshot' + cur_time + '.png')
end
validate_parameters(platform, browser_type, app_path) click to toggle source

Method to check browser type

# File lib/anhpham/methods/error_handling_methods.rb, line 4
def validate_parameters(platform, browser_type, app_path)
  if platform == 'desktop'
    if !%w(ff ie chrome safari opera).include? browser_type
      print_error_desktop
    end
  elsif platform == 'android'
      print_error_android browser_type, app_path
  elsif platform == 'iOS'
    puts "Not Implemented..."
    # print_error_ios browser_type, app_path
  else
    print_invalid_platform
  end
end
var_collect(string_var) click to toggle source
# File lib/anhpham/methods/lib_var.rb, line 1
def var_collect string_var
  if string_var =~ /^.*{year}.*$/
    string_var = replace_year(string_var)
  end

  if string_var =~ /^.*{month}.*$/
    string_var = replace_month(string_var)
  end

  if string_var =~ /^.*{day}.*$/
    string_var = replace_day(string_var)
  end

  if string_var =~ /^.*{store_value}.*$/
    string_var = $context_value
  end

  return string_var
end