Skip to content

Instantly share code, notes, and snippets.

@jrovegno
Last active December 18, 2015 18:42
Show Gist options
  • Save jrovegno/c16043df8eae4e1a5792 to your computer and use it in GitHub Desktop.
Save jrovegno/c16043df8eae4e1a5792 to your computer and use it in GitHub Desktop.
Reparado problema con dialogo descarga excel
require 'webdrone'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['startup.homepage_welcome_url.additional'] = 'about:blank'
profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream, application/download, application/vnd.ms-excel'
a0 = Webdrone.create browser: :firefox, timeout: 10, firefox_profile: profile
def entrar_dga(a0)
a0.open.url 'http://dgasatel.mop.cl/'
a0.clic.on 'Ingrese Aquí'
a0.clic.on 'Entrar'
end
def marcar_estacion(a0, nombre)
a0.form.set "estacion1", nombre
end
def marcar_datos(a0, temp: false, hume: false, pacu: false, phor: false)
a0.clic.css "input[name='chk_estacion1a']", n:1 if temp
a0.clic.css "input[name='chk_estacion1a']", n:2 if hume
a0.clic.css "input[name='chk_estacion1b']", n:1 if pacu
a0.clic.css "input[name='chk_estacion1b']", n:2 if phor
end
def marcar_periodo(a0, d1: false, w1: false, m1: false, m3: false)
a0.clic.css "input[name='period']", n:1 if d1
a0.clic.css "input[name='period']", n:2 if m3
a0.clic.css "input[name='period']", n:3 if w1
a0.clic.css "input[name='period']", n:5 if m1
end
def marcar_rango(a0, ini, fin)
a0.clic.css "input[name='period']", n:4
a0.form.set 'fecha_ini', ini
a0.form.set 'fecha_finP', fin
end
def marcar_tipo(a0, insta: false, sinop: false)
a0.clic.css "input[name='tiporep']", n:1 if insta
a0.clic.css "input[name='tiporep']", n:2 if sinop
end
def bajar_excel_dga(a0)
a0.clic.on 'Ver Tabla'
a0.clic.on 'Excel'
a0.clic.on '« Volver'
end
entrar_dga(a0)
marcar_estacion(a0, 'Visviri')
marcar_datos(a0, temp: true)
marcar_rango(a0, "01/09/2014", "01/12/2014")
marcar_tipo(a0, sinop: true)
bajar_excel_dga(a0)
marcar_tipo(a0, insta: true)
bajar_excel_dga(a0)
marcar_periodo(a0, m3: true)
bajar_excel_dga(a0)
Webdrone.irb_console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment