Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 1.32 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def select_value(type, choice)
  2.     b_clicked = false
  3.     if !is_ddown_open("css", ".item.loading-items")
  4.       Sel_Utils::Sel_Utils.ClickObject("css", ".#{type}-tokenfield>div>div>input")
  5.     end
  6.     begin
  7.       $waiter.until{ !$browser.find_element(:css, ".item.loading-items") }
  8.     rescue
  9.       #do nothing
  10.     end
  11.  
  12.     options = $browser.find_elements(:css, '.item.item-existing')
  13.     options.each{|option|
  14.      if(option.text == choice)
  15.         option.click
  16.         b_clicked = true
  17.       end
  18.     }
  19.     if b_clicked != true
  20.       Sel_Utils::Sel_Utils.Send_Keys("css", ".#{type}-tokenfield>div>div>input", choice + "\xEE\x80\x87")
  21.     end
  22.     verify_value_selection(type, choice)
  23.   end
  24.  
  25.   def is_ddown_open(type, element_locator)
  26.     begin
  27.       $browser.find_element(type.to_sym, element_locator)
  28.     rescue
  29.       return false
  30.     end
  31.     return true
  32.  
  33.   end
  34.   def verify_value_selection(type, choice)
  35.     text_identified = 0
  36.     labels = $browser.find_elements(:css, ".#{type}-tokenfield>.tokenfield-contents>.n-token")
  37.  
  38.     labels.each{|label|
  39.       if (label.text.include?(choice))
  40.         text_identified+=1
  41.       end
  42.     }
  43.     if text_identified == 1
  44.       $Sel_log.result("TRUE", "Choice selected for option #{type}")
  45.     else
  46.       $Sel_log.result("FALSE", "Choice selected for option #{type}", "'#{choice}' was not found")
  47.     end
  48.  
  49.   end