global
def raw_execute(command, opts = {}, command_hash = nil)
def raw_execute(command, opts = {}, command_hash = nil) verb, path = Selenium::WebDriver::Remote::COMMANDS[command] || raise(ArgumentError, "unknown command: #{command.inspect}") path = path.dup path[':session_id'] = @session_id if path.include?(':session_id') begin opts.each { |key, value| path[key.inspect] = escaper.escape(value.to_s) } rescue IndexError raise ArgumentError, "#{opts.inspect} invalid for #{command.inspect}" end # convert /// into / path.gsub! /\/+/, '/' # change path from session/efac972c-941a-499c-803c-d7d008749/execute # to /execute # path may be nil, session, or not have anything after the session_id. path_str = '' path_match = path.match /.*\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/ path_str = path.sub(path_match[0], '') unless path_match.nil? puts "#{verb} #{path_str}" unless command_hash.nil? || command_hash.length == 0 print_command = command_hash.clone print_command.delete :args if print_command[:args] == [] mobile_find = 'mobile: find' if print_command[:script] == mobile_find args = print_command[:args] puts "#{mobile_find}"#" #{args}" # [[[[3, "sign"]]]] => [[[3, "sign"]]] # # [[[[4, "android.widget.EditText"], [7, "z"]], [[4, "android.widget.EditText"], [3, "z"]]]] # => [[[4, "android.widget.EditText"], [7, "z"]], [[4, "android.widget.EditText"], [3, "z"]]] args = args[0] option = args[0].to_s.downcase has_option = ! option.match(/all|scroll/).nil? puts option if has_option start = has_option ? 1 : 0 start.upto(args.length-1) do |selector_index| selectors = args[selector_index] selectors_size = selectors.length selectors.each_index do |pair_index| pair = selectors[pair_index] res = $driver.dynamic_code_to_string pair[0], pair[1] if selectors_size == 1 || pair_index >= selectors_size - 1 puts res elsif selectors_size > 1 && pair_index < selectors_size print res + '.' end end end # start.upto else ap print_command end end delay = $driver.global_webdriver_http_sleep sleep delay if !delay.nil? && delay > 0 # puts "verb: #{verb}, path #{path}, command_hash #{command_hash.to_json}" http.call verb, path, command_hash end # def