class Magnesium::Testcase
Public Class Methods
new(p,c)
click to toggle source
# File lib/magnesium/factor/test_case.rb, line 21 def initialize(p,c) @prefix = p @caseno = c new_folder("#{Config.config["temp"]}nodes_hierarchy") #new folder id new_folder("#{Config.config["temp"]}#{TestLink.find_path(@prefix,@caseno).split(/\//)[0]}/#{TestLink.find_path(@prefix,@caseno).split(/\//)[1]}") #download attachment ssh = SSH.new ssh.host = Config.config["testlink"]["host"] ssh.username = Config.config["testlink"]["host_account"] ssh.pwd = Config.config["testlink"]["host_pwd"] ssh.local ="#{Config.config["temp"]}#{TestLink.find_path(@prefix,@caseno).split(/\//)[0]}/#{TestLink.find_path(@prefix,@caseno).split(/\//)[1]}/" ssh.server = "#{Config.config["testlink"]["install_path"]}upload_area/#{TestLink.find_path(@prefix,@caseno)}" ssh.download_file #factor @data = generate_data(@prefix,@caseno) # @data.prefix = @prefix # @data.caseno = @caseno # @data.generate @ui = generate_UI(@prefix,@caseno) @site = generate_site(@prefix,@caseno) @step = generate_step(@prefix,@caseno) @expected_result = get_expected_result(@prefix,@caseno) end
Public Instance Methods
new_folder(path)
click to toggle source
# File lib/magnesium/factor/test_case.rb, line 49 def new_folder(path) if (File.exist? path) puts "folder exist!" else Dir.mkdir(path) end end
run()
click to toggle source
# File lib/magnesium/factor/test_case.rb, line 57 def run() #1 begin #2 @data.each do |data_key,data_value| #3 browser_type = Config.config["browser"]["value"] @browser = Watir::Browser.new :chrome if browser_type == "chrome" @step.each do |step_key,step_value| #4 @tempdata = data_value.hash[step_key] unless data_value.hash[step_key].nil? unless step_value.to_s.eql? 'goto' #5 @ui.each do |ui_key,ui_value| @temptype = ui_value.container_type @temptitle = ui_value.container_title #if popup # unless ui_value.hash_element[step_key].nil? @tempelement = ui_value.hash_element[step_key] @templocate = ui_value.hash_locate[step_key] @tempvalue = ui_value.hash_value[step_key] @tempaction = ui_value.hash_action[step_key] unless ui_value.hash_box[step_key].nil? @tempbox = ui_value.hash_box[step_key] else @tempbox = Array.new end break end # end #ui #real run unless @tempelement.eql? 'js' fa = Factory.creator(@tempelement) fa.box = @tempbox fa.browser = @browser fa.generate fa.element(@templocate,@tempvalue) if @temptype == 'common' fa.execute(@tempaction,@tempdata) else dealpopup(@browser,@temptitle,fa,@tempaction,@tempdata) end else #if js has nothing to do with frame #if popip has no js #TODO execute_js(@browser,@tempvalue) end #unless js #end of real run else #5 @browser.goto @site[step_key].to_s #gotoBrowser(@browser,@site[step_key].to_s) end #5 end #4 #generate result get_real_result(@prefix,@caseno,@browser) #end of per data test @browser.close # closeBrowser(@browser) end #3 #delete temp fodler FileUtils.rm_rf "#{Config.config["temp"]}nodes_hierarchy/" #end #3 # rescue # error end #2 end