Before do begin def selenium case $_CONFIG['DeviceName'].upcase.to_sym when :IOS @driver ||= Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities_ios, :url => server_url) when :ANDROID @driver ||= Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities_android, :url => server_url) else puts "\nERROR: *** Invalid Device Nane!. Please check the config from $_CONFIG['DeviceName'] = #{$_CONFIG['DeviceName']}" end end rescue StandardError => myStandardError put_log "\nERROR: *** #{myStandardError}" end end After do begin selenium.quit rescue StandardError => myStandardError puts "\nERROR: *** #{myStandardError}" end end